Frontmatter Gen (frontmatter-gen)
A high-performance Rust library for parsing and serialising frontmatter in YAML, TOML, and JSON formats. Built for safety, efficiency, and ease of use.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
Overview 🚀
frontmatter-gen is a comprehensive Rust library that provides robust handling of frontmatter in content files. It delivers a type-safe, efficient solution for extracting, parsing, and serialising frontmatter in multiple formats. Whether you're building a static site generator, content management system, or any application requiring structured metadata, frontmatter-gen offers the tools you need.
Key Features 🎯
- Zero-Copy Parsing: Parse YAML, TOML, and JSON frontmatter efficiently with zero memory copying
- Safe Extraction: Extract frontmatter using standard delimiters (
---for YAML,+++for TOML) with comprehensive error handling - Type Safety: Leverage Rust's type system with the
Valueenum for safe frontmatter manipulation - High Performance: Optimised for speed with minimal allocations and efficient algorithms
- Memory Safety: Guaranteed memory safety through Rust's ownership system
- Rich Error Handling: Detailed error types with context for effective debugging
- Async Support: First-class asynchronous operation support
- Flexible Configuration: Customisable parsing behaviour to match your needs
Available Features 🛠️
This crate provides several feature flags to customise its functionality:
- default: Core frontmatter parsing functionality only
- cli: Command-line interface tools for quick operations
- ssg: Static Site Generator functionality (includes CLI features)
- logging: Debug logging capabilities
Getting Started 📦
Add this to your Cargo.toml:
[]
# Basic frontmatter parsing only
= "0.0.3"
# With Static Site Generator functionality
= { = "0.0.3", = ["ssg"] }
Basic Usage 🔨
Extract and Parse Frontmatter
use extract;
Format Conversion
use ;
Advanced Features 🚀
Handle Complex Nested Structures
use ;
Documentation 📚
For comprehensive API documentation and examples, visit:
CLI Tool 🛠️
The library includes a powerful command-line interface for quick frontmatter operations:
# Generate a static site
# Extract frontmatter in various formats
# Save extracted frontmatter to files
# Validate frontmatter with required fields
Running from Source
You can also run the CLI tool directly from the source code:
# Generate a static site
# Extract and validate frontmatter
Error Handling 🚨
The library provides detailed error handling with context:
use ;
Contributing 🤝
We welcome contributions! Please see our Contributing Guidelines for details on:
- Code of Conduct
- Development Process
- Submitting Pull Requests
- Reporting Issues
Licence 📝
This project is dual-licensed under either:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT licence (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Acknowledgements 🙏
Special thanks to all contributors and the Rust community for their invaluable support and feedback.