Merged
Conversation
This adds support for extracting metadata from YAML frontmatter in markdown files,
eliminating the need to manually maintain data.json files.
Changes:
- Added serde, serde_yaml, and toml dependencies for parsing
- Created new frontmatter.rs handler to extract YAML frontmatter from .md files
- Modified templates.rs to support both .data.toml (new) and .data.json (legacy)
- TOML file lists which markdown files to include and in what order
- Frontmatter fields become template variables (${title}, ${date}, etc.)
- Auto-generates --entry-path, --result-path, and link fields
- Only 'title' field is required in frontmatter
- Updated README with comprehensive documentation for the new feature
File structure example:
src/data/Posts/Posts.data.toml # Lists files and order
src/data/Posts/my-post.md # Contains YAML frontmatter + content
The system falls back to .data.json if .data.toml doesn't exist, maintaining
backwards compatibility.
This commit fixes the issue where YAML frontmatter was being rendered as part of the markdown content, and adds a complete working example demonstrating the frontmatter feature. Changes: - Modified entries.rs to strip frontmatter before wrapping content in <markdown> tags - Falls back to original content if frontmatter extraction fails (for files without frontmatter) - Added comprehensive example directory with: - 3 sample blog posts with different frontmatter fields - TOML configuration file for file ordering - Template and frame files for rendering - Index page demonstrating the template system - Complete README with usage instructions The example demonstrates: - YAML frontmatter extraction - TOML-based file ordering - Auto-generated paths and links - Template variable substitution - Proper markdown rendering without frontmatter - Backwards compatibility Tested and verified: all files build correctly and frontmatter fields are properly substituted in both list view and individual post pages.
Removed the 'Key Features Demonstrated' section from README.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces first-class support for using YAML frontmatter in markdown files as a replacement for JSON data files, making it easier to manage and template content such as blog posts. The changes add TOML-based configuration for file ordering, automatic extraction of metadata from markdown frontmatter, and backwards compatibility with the legacy JSON workflow. Extensive documentation and an example project are also included to demonstrate the new workflow.
Frontmatter and Data Loading Improvements:
src/handlers/frontmatter.rswith functions to extract YAML frontmatter from markdown files and to load data from a list of markdown files specified in a TOML file. This enables automatic extraction of metadata for templating, with validation that each file contains atitlefield.src/handlers/templates.rsto first attempt loading data from a.data.tomlfile and associated markdown frontmatter, falling back to the legacy.data.jsonif TOML is not present.Cargo.tomlto includeserde,serde_yaml, andtomlfor frontmatter and TOML parsing.Markdown Processing Enhancements:
src/handlers/entries.rsto strip YAML frontmatter from markdown content before rendering, ensuring that only the actual content is displayed on generated pages.Documentation and Example Project:
example/README.mdand supporting files to demonstrate the new frontmatter-based workflow, including a sample TOML configuration, markdown files with frontmatter, templates, and a styled index page. [1] [2] [3] [4] [5] [6] [7] [8]README.mdto document the new recommended frontmatter workflow, including file structure, required fields, and auto-generated variables for templates.These changes make it much easier and more flexible to manage content-driven sites, allowing users to use markdown files with frontmatter for both content and metadata, while maintaining compatibility with existing JSON-based data.