use std::collections::{BTreeMap, HashMap, HashSet}; use std::error::Error; use std::fs; use std::path::Path; use std::sync::Arc; use crate::db::DbConnection as Connection; use chrono::{Datelike, Local, TimeZone, Utc}; use rayon::prelude::*; use serde_json::{Value, json}; use crate::db::queries; use crate::engine::generation::{GenerationSection, classify_generated_path}; use crate::engine::menu::{self, MenuItemKind}; use crate::model::{ CategorySettings, Media, Post, PostStatus, ProjectMetadata, ScriptKind, Tag, Template, TemplateKind, TemplateStatus, }; use crate::render::{ PostLanguageVariant, RenderCategorySettings, RenderTemplateLookup, blog_page_title, build_canonical_post_path, render_liquid_template_with_host, resolve_post_template, select_post_language_variant, }; use crate::scripting::{CoreHost, HostApi, UnavailableHost}; use crate::util::frontmatter::{read_script_file, read_template_file, read_translation_file}; use crate::util::{slugify, year_month_from_unix_ms}; const STARTER_SINGLE_POST_TEMPLATE: &str = include_str!("../../../../assets/starter-templates/single-post.liquid"); const STARTER_POST_LIST_TEMPLATE: &str = include_str!("../../../../assets/starter-templates/post-list.liquid"); const STARTER_NOT_FOUND_TEMPLATE: &str = include_str!("../../../../assets/starter-templates/not-found.liquid"); const STARTER_HEAD_PARTIAL: &str = include_str!("../../../../assets/starter-templates/partials/head.liquid"); const STARTER_MENU_PARTIAL: &str = include_str!("../../../../assets/starter-templates/partials/menu.liquid"); const STARTER_LANGUAGE_SWITCHER_PARTIAL: &str = include_str!("../../../../assets/starter-templates/partials/language-switcher.liquid"); const STARTER_MENU_ITEMS_PARTIAL: &str = include_str!("../../../../assets/starter-templates/partials/menu-items.liquid"); #[derive(Debug, Clone, PartialEq, Eq)] pub struct SitePage { pub language: String, pub relative_path: String, pub url_path: String, pub html: String, } #[derive(Debug, Clone, PartialEq, Eq)] pub struct PagefindDocument { pub language: String, pub relative_path: String, pub url_path: String, pub html: String, } #[derive(Debug, Clone, Default)] pub struct SiteRenderArtifacts { pub pages: Vec, pub pagefind_documents: Vec, pub route_manifest: Vec, } #[derive(Debug, Clone, PartialEq, Eq)] pub struct PreviewRenderResult { pub status_code: u16, pub html: String, } #[derive(Clone)] struct TemplateBundle { post_templates: Vec