Adding Frontmatter Reader: Support summary card (OG. Twitter)#2321
Adding Frontmatter Reader: Support summary card (OG. Twitter)#2321sspaeti wants to merge 4 commits intorust-lang:masterfrom
Conversation
|
Hi, would you have time to rebase this to make it easier to review it, please? |
Cargo.toml
Outdated
| toml = "0.5.11" # Do not update, see https://github.com/rust-lang/mdBook/issues/2037 | ||
| topological-sort = "0.2.2" | ||
| gray_matter = "0.2" #Fronmatter | ||
| serde_yaml = "0.9" |
There was a problem hiding this comment.
serde_yaml was deprecated recently, please use serde_yml
| use serde::Deserialize; | ||
|
|
||
| fn extract_frontmatter(content: &str) -> Option<&str> { | ||
| let start = content.find("---")? + 3; // Find the end of the first `---` + 3 to move past it |
There was a problem hiding this comment.
Given that --- can appear anywhere in a regular markdown content, I'd restrict this to the case when the file starts with ---.
This comment has been minimized.
This comment has been minimized.
Adds a `frontmatter` feature flag that parses YAML frontmatter from chapter content and injects OG/Twitter meta tag data into the Handlebars template context. All custom code is isolated in a single module (frontmatter.rs) with 3 one-liner integration points behind #[cfg(feature = "frontmatter")] for easy future upgrades. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
4777b3a to
c3e8b00
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@szabgab I finally updated my book, and therefore also rebased this branch. The pre-processor https://github.com/sspaeti/mdbook-frontmatter-reader is no longer needed and has been integrated directly into Again, in my chapters in my mdbook, I can now add this in the frontmatter and that gets rendered in the HTML header: FYI, if anyone is doing similar things - I added these hard-coded to my You can check the outcome in my book live at https://dedp.online/part-2/4-ce/semantic-layer-business-intelligence.html. I hope that works, not sure if I have thought about everything, as this is my first mdBook submission, but it works great for my book for a long time :) |

See issues #1416 and specific description in my comment: #1416 (comment).
This works for my site dedp.online, but I'd appreciate some help to integrate it nicely. It's more hackable and hard-coded to these frontmatter I used:
Would be nice to read them dynamically. Also, I'm not sure if I added it at the right points.
PS: I also tried to implement a preprocessor (see #1416 (comment)), but with this PR that one is not needed anymore. Also, I guess this should be integrated into mdBook, and can't be as Preprocessor only?