Skip to content

Autogenerate TOC #432

Description

@dimaip

Currently we statically define TOC in files like this one: https://github.com/dimaip/calendar/blob/master/app/containers/Service/Texts/Vespers/TOC.tsx

It relies on ids on the page and simply scrolls you to the right heading. The problem is that throughout the year a service may have some parts missing, but we still have TOC entries lingering in place.

There may be two possible solutions:

  1. have some special component like <TOCEntry id="nachalo" label="Начало"/>. Then we could statically parse these files at build time and extract all such headings and build up some JSON file with information that we have extracted from them. We could do it either as a Babel plugin, webpack plugin, MDX plugin or even standalone shell script that we'd manually hook up to the build script. The tricky part here is that this component may exist not only in the main service file, but also in any of its sub components... But we can gather all such components from the current service folder...
  2. gather the TOC directly from DOM in useEffect. Like our grandfathers did it...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions