Skip to content

Conversation

@sspaeti
Copy link
Contributor

@sspaeti sspaeti commented Feb 20, 2024

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:

struct FrontMatter {
    title: String,
    description: String,
    featured_image_url: String,
}

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?

@szabgab
Copy link
Contributor

szabgab commented Apr 3, 2025

Hi, would you have time to rebase this to make it easier to review it, please?

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that --- can appear anywhere in a regular markdown content, I'd restrict this to the case when the file starts with ---.

@rustbot
Copy link
Collaborator

rustbot commented Apr 30, 2025

☔ The latest upstream changes (possibly #2681) made this pull request unmergeable. Please resolve the merge conflicts.

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.

3 participants