Rust library to generate static websites
1use chrono::NaiveDate;
2use maud::{PreEscaped, Render};
3use maudit::content::{
4 ContentSources, MarkdownOptions, glob_markdown, glob_markdown_with_options, markdown_entry,
5};
6use maudit::content_sources;
7use serde::Deserialize;
8
9#[derive(Deserialize, Eq, PartialEq, PartialOrd, Hash, Clone)]
10#[serde(rename_all = "kebab-case")]
11pub enum DocsSection {
12 GettingStarted,
13 CoreConcepts,
14 Guide,
15 Advanced,
16}
17
18impl Render for DocsSection {
19 fn render(&self) -> PreEscaped<String> {
20 match self {
21 DocsSection::GettingStarted => PreEscaped("Getting Started".to_string()),
22 DocsSection::CoreConcepts => PreEscaped("Core Concepts".to_string()),
23 DocsSection::Guide => PreEscaped("Guide".to_string()),
24 DocsSection::Advanced => PreEscaped("Advanced".to_string()),
25 }
26 }
27}
28
29#[markdown_entry]
30pub struct DocsContent {
31 pub title: String,
32 pub description: Option<String>,
33 pub section: Option<DocsSection>,
34}
35
36#[markdown_entry]
37pub struct NewsContent {
38 pub title: String,
39 pub description: Option<String>,
40 pub date: NaiveDate,
41 pub author: Option<String>,
42}
43
44pub fn content_sources() -> ContentSources {
45 content_sources!["docs" => glob_markdown_with_options::<DocsContent>("content/docs/*.md", MarkdownOptions {
46 highlight_theme: "base16-eighties.dark".into(),
47 ..Default::default()
48 }), "news" => glob_markdown::<NewsContent>("content/news/*.md")]
49}