rs_web/
lib.rs

1//! # rs-web - Static Site Generator
2//!
3//! A fast, opinionated static site generator built in Rust with support for:
4//!
5//! - **Markdown processing** with syntax highlighting, external link handling
6//! - **Content encryption** (full post or partial `:::encrypted` blocks)
7//! - **Link graph** with backlinks and visualization (Obsidian-style)
8//! - **RSS feed** generation with section filtering
9//! - **Parallel processing** for fast builds
10//!
11//! ## Quick Start
12//!
13//! ```bash
14//! # Build the site
15//! rs-web build
16//!
17//! # Build to custom output directory
18//! rs-web build --output public
19//! ```
20//!
21//! ## Configuration
22//!
23//! Configure via `config.toml`:
24//!
25//! ### Required Settings
26//!
27//! ```toml
28//! [site]
29//! title = "My Site"                    # Site title
30//! description = "Site description"     # Site description
31//! base_url = "https://example.com"     # Base URL (no trailing slash)
32//! author = "Your Name"                 # Author name
33//!
34//! [seo]
35//! twitter_handle = "@username"         # Optional: Twitter handle
36//! default_og_image = "/static/og.png"  # Optional: Default OG image
37//!
38//! [build]
39//! output_dir = "dist"                  # Output directory
40//! minify_css = true                    # Default: true
41//!
42//! [images]
43//! quality = 85.0                       # WebP quality (default: 85.0)
44//! scale_factor = 1.0                   # Image scale (default: 1.0)
45//! ```
46//!
47//! ### Optional Settings (have defaults)
48//!
49//! ```toml
50//! [paths]
51//! content = "content"                  # Content directory (default: "content")
52//! styles = "styles"                    # Styles directory (default: "styles")
53//! static_files = "static"              # Static files (default: "static")
54//! templates = "templates"              # Templates (default: "templates")
55//! home = "index.md"                    # Home page file (default: "index.md")
56//! exclude = ["drafts", "private"]      # Directories to exclude (default: [])
57//!
58//! [highlight]
59//! names = ["John Doe", "Jane Doe"]     # Names to highlight (default: [])
60//! class = "me"                         # CSS class for highlights (default: "me")
61//!
62//! [templates]
63//! blog = "post.html"                   # Section -> template mapping
64//! projects = "project.html"            # (default: uses {section}.html or post.html)
65//!
66//! [permalinks]
67//! blog = "/:year/:month/:slug/"        # Section -> URL pattern
68//! projects = "/:slug/"                 # Placeholders: :year :month :day :slug :title :section
69//!
70//! [encryption]
71//! password_command = "pass show site"  # Command to get password (optional)
72//! password = "secret"                  # Raw password (optional, less secure)
73//!                                      # Priority: SITE_PASSWORD env > command > password
74//!
75//! [graph]
76//! enabled = true                       # Enable graph generation (default: true)
77//! template = "graph.html"              # Graph page template (default: "graph.html")
78//! path = "graph"                       # URL path (default: "graph" -> /graph/)
79//!
80//! [rss]
81//! enabled = true                       # Enable RSS generation (default: true)
82//! filename = "rss.xml"                 # Output filename (default: "rss.xml")
83//! sections = ["blog"]                  # Sections to include (default: [] = all)
84//! limit = 20                           # Max items (default: 20)
85//! exclude_encrypted_blocks = false     # Exclude posts with :::encrypted (default: false)
86//! ```
87//!
88//! ## Frontmatter
89//!
90//! Post frontmatter options (YAML or TOML):
91//!
92//! ```yaml
93//! ---
94//! title: "Post Title"           # Required
95//! description: "Description"    # Optional
96//! date: 2024-01-15              # Optional (YAML date or string)
97//! tags: ["tag1", "tag2"]        # Optional
98//! draft: false                  # Optional (default: false, excluded from build)
99//! image: "/static/post.png"     # Optional: OG image
100//! template: "custom.html"       # Optional: Override template
101//! slug: "custom-slug"           # Optional: Override URL slug
102//! permalink: "/custom/url/"     # Optional: Full URL override
103//! encrypted: false              # Optional: Encrypt entire post
104//! password: "post-secret"       # Optional: Post-specific password
105//! ---
106//! ```
107//!
108//! ## Partial Encryption
109//!
110//! Use `:::encrypted` blocks for partial content encryption:
111//!
112//! ```markdown
113//! Public content here.
114//!
115//! :::encrypted
116//! This content is encrypted with the global/post password.
117//! :::
118//!
119//! :::encrypted password="custom"
120//! This block has its own password.
121//! :::
122//! ```
123//!
124//! ## Template Variables
125//!
126//! ### Home Template (`home.html`)
127//! - `site` - Site config (title, description, base_url, author)
128//! - `page` - Page info (title, description, url, image)
129//! - `sections` - All sections with posts (`sections.blog.posts`)
130//! - `content` - Rendered markdown content
131//!
132//! ### Post Template (`post.html`)
133//! - `site` - Site config
134//! - `post` - Post info (title, url, date, tags, reading_time, etc.)
135//! - `page` - Page info for head.html compatibility
136//! - `content` - Rendered markdown content
137//! - `backlinks` - Posts linking to this post (url, title, section)
138//! - `graph` - Local graph data (nodes, edges) for visualization
139//!
140//! ### Graph Template (`graph.html`)
141//! - `site` - Site config
142//! - `page` - Page info
143//! - `graph` - Full graph data (nodes, edges)
144//!
145//! ## Modules
146//!
147//! - [`config`] - Configuration loading and structures
148//! - [`content`] - Content discovery and post/page models
149//! - [`markdown`] - Markdown processing pipeline
150//! - [`templates`] - Tera template rendering
151//! - [`encryption`] - AES-GCM encryption for protected content
152//! - [`links`] - Link graph and backlink generation
153//! - [`rss`] - RSS feed generation
154//! - [`assets`] - CSS building and image optimization
155//! - [`build`] - Main build orchestrator
156
157pub mod assets;
158pub mod build;
159pub mod config;
160pub mod content;
161pub mod encryption;
162pub mod links;
163pub mod markdown;
164pub mod rss;
165pub mod templates;