Crates.io | staticdatagen |
lib.rs | staticdatagen |
version | 0.0.1 |
source | src |
created_at | 2024-10-27 21:22:45.66832 |
updated_at | 2024-10-27 21:22:45.66832 |
description | A Rust library for generating structured data files and metadata for static sites, including HTML, RSS feeds, sitemaps, and SEO-optimized meta tags. |
homepage | https://staticdatagen.com/ |
repository | https://github.com/sebastienrousseau/staticdatagen |
max_upload_size | |
id | 1425028 |
size | 721,749 |
A fast, secure, and comprehensive static site structured data generator library written in Rust.
• Website • Documentation • Report Bug • Request Feature • Contributing Guidelines
staticdatagen
is a robust Rust library that streamlines the generation of structured data and metadata for static sites. It provides a comprehensive suite of tools for creating HTML files, RSS feeds, sitemaps, and SEO-friendly metadata, with built-in security features and multi-language support.
Markdown to HTML Conversion
Metadata Generation
Navigation System
Multi-language Support
Sitemaps
Feed Generation
Security Features
Data Validation
Error Handling
Performance
Add staticdatagen
to your Cargo.toml
:
[dependencies]
staticdatagen = "0.0.1"
Create the following directory structure for your project:
your-project/
├── content/ # Your Markdown content
├── templates/ # HTML templates
├── build/ # Temporary build directory
└── site/ # Final output directory
use staticdatagen::compiler::service::compile;
use std::path::Path;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Define paths for your static site
let build_dir = Path::new("examples/build"); // Temporary build directory
let content_dir = Path::new("examples/content"); // Source content directory
let site_dir = Path::new("examples/site"); // Output directory
let template_dir = Path::new("examples/templates"); // HTML templates directory
// Compile the static site
compile(
build_dir,
content_dir,
site_dir,
template_dir,
)?;
Ok(())
}
The library generates the following files:
HTML Files
Metadata Files
security.txt
- Security policy (RFC 9116)humans.txt
- Site credits and informationrobots.txt
- Crawler instructionsmanifest.json
- PWA manifestSEO Files
sitemap.xml
- Standard sitemapnews-sitemap.xml
- Google News sitemaprss.xml
- Content syndication feedThe library uses the anyhow
crate for error handling, providing detailed error messages and context. All public functions return Result
types with comprehensive error information:
use anyhow::Result;
fn main() -> Result<()> {
// Your code here
Ok(())
}
For full API documentation, please visit docs.rs/staticdatagen.
To explore more examples, clone the repository and run the following command:
cargo run --example example_name
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under either of
at your option.
Special thanks to all contributors who have helped build the staticdatagen
library.