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

Add data property to chapter struct #2149

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bgotink
Copy link

@bgotink bgotink commented Jul 31, 2023

This data property makes it possible to share data between pre-processors, or between pre-processors and the renderer, including the "html" renderer which exposes the chapter data as "data" in the .hbs files.

I've explicitly not provided a built-in way to configure data. Any built-in approach for parsing data would have to be discussed. While I consider hugo/jekyll style front-matter pretty standard for this kind of thing, others might disagree. Even if everyone agreed, the question would then become "what flavours of front-matter do we support?"

I've also explicitly not created any data properties that are used out of the box by mdBook itself.

I'm assuming this PR would need to go in 0.5.0, as it changes the JSON model and any pre-processors compiled with older versions of mdBook would strip the property.

For reference, my use case: I have (many) large JSON files containing data, and I want to use a pre-processor to insert the correct data in every chapter, to then use it in our theme's .hbs file to generate a metadata table, links, that kind of stuff.

Related:

@rustbot rustbot added the S-waiting-on-review Status: waiting on a review label Jul 31, 2023
This data property makes it possible to share data
between pre-processors, or between pre-processors
and the renderer, including the "html" renderer
which exposes the chapter data as "data" in the
.hbs files.
@CakeVR
Copy link

CakeVR commented Dec 4, 2023

Hello, the lack of front matter support in mdBook is unfortunate, and this pull request seems to add great power for preprocessors.
If I were able to parse the front matter of each chapter, I would be able to generate Open Graph Meta Tags per chapter in the index.hbs.
This allows for great link embed previews.

I'm sorry to see your work has not been looked into yet.
I do hope it gets reviewed and evaluated, thanks for your effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: waiting on a review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants