Skip to main content

typstify_core/
lib.rs

1//! Typstify Core Library
2//!
3//! Core types, configuration, and error handling for the Typstify static site generator.
4
5pub mod config;
6pub mod content;
7pub mod error;
8pub mod frontmatter;
9pub mod utils;
10
11pub use config::Config;
12pub use content::{ContentPath, ContentType, Page, ParsedContent};
13pub use error::{CoreError, Result};
14pub use frontmatter::Frontmatter;
15
16/// Shared test fixtures for use across workspace test modules.
17///
18/// Enable the `testing` feature on `typstify-core` in `[dev-dependencies]` to access:
19///
20/// ```toml
21/// [dev-dependencies]
22/// typstify-core = { workspace = true, features = ["testing"] }
23/// ```
24#[cfg(feature = "testing")]
25pub mod test_fixtures {
26    use std::{collections::HashMap, path::PathBuf};
27
28    use crate::{
29        Page,
30        config::{
31            BuildConfig, Config, RobotsConfig, RssConfig, SearchConfig, SiteConfig, TaxonomyConfig,
32        },
33    };
34
35    /// Create a standard test configuration.
36    pub fn test_config() -> Config {
37        Config::from_parts(
38            SiteConfig {
39                title: "Test Site".to_string(),
40                host: "https://example.com".to_string(),
41                base_path: String::new(),
42                default_language: "en".to_string(),
43                description: Some("A test site".to_string()),
44                author: Some("Test Author".to_string()),
45            },
46            BuildConfig::default(),
47            SearchConfig::default(),
48            RssConfig::default(),
49            RobotsConfig::default(),
50            TaxonomyConfig::default(),
51            HashMap::new(),
52        )
53    }
54
55    /// Create a standard test page.
56    pub fn test_page() -> Page {
57        Page {
58            url: "/test-page".to_string(),
59            title: "Test Page".to_string(),
60            description: Some("A test page".to_string()),
61            date: None,
62            updated: None,
63            draft: false,
64            lang: "en".to_string(),
65            is_default_lang: true,
66            canonical_id: "test-page".to_string(),
67            tags: vec![],
68            categories: vec![],
69            content: "<p>Hello, World!</p>".to_string(),
70            summary: None,
71            reading_time: None,
72            word_count: None,
73            toc: vec![],
74            custom_js: vec![],
75            custom_css: vec![],
76            aliases: vec![],
77            template: None,
78            weight: 0,
79            source_path: Some(PathBuf::from("test-page.md")),
80        }
81    }
82}