Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerate TOC #432

Open
dimaip opened this issue Apr 7, 2021 · 0 comments
Open

Autogenerate TOC #432

dimaip opened this issue Apr 7, 2021 · 0 comments

Comments

@dimaip
Copy link
Owner

dimaip commented Apr 7, 2021

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...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant