krz/orgo
Lightning fast org-mode static site generator.
clone: git clone https://gitbay.org/krz/orgo.git
1//! Built-in site themes: whole stylesheets compiled into the binary.
2//!
3//! A theme is one CSS file and nothing else. It styles the markup the RENDER stage
4//! emits — org's headings, tags, TODO keywords, checkbox lists, footnotes — plus the
5//! chrome the built-in layout and the starter templates put around it. There is no
6//! theme-specific HTML, so a theme can be switched, or removed, without touching a
7//! template.
8//!
9//! Compiled in for the same reason the syntax definitions are: `cargo install orgo`
10//! gives you one binary, and a site that needs a stylesheet fetched from somewhere else
11//! before it looks like anything is not that. The chosen theme is written to the output
12//! root as `theme.css` on every build, the way [`crate::render::syntax_css`] writes
13//! `syntax.css`.
14//!
15//! Nothing here is a wrapper you have to work through: `site.theme` empty emits no
16//! stylesheet at all, and a `base.html` of your own can ignore `theme.css` and link
17//! whatever it likes.
18
19/// Every built-in theme, as `(name, stylesheet)`, in the order they are offered.
20///
21/// - `plain` — readable defaults with no design opinion, to build your own CSS on.
22/// - `blog` — dated writing: serif prose, a masthead, styled listing pages.
23/// - `wiki` — a dense reference site: wide, sidebar contents, tables and TODO states.
24/// - `docs` — a guide read in order: prominent contents, code-forward, `#+LEDE:`.
25pub const THEMES: &[(&str, &str)] = &[
26 ("plain", include_str!("../themes/plain.css")),
27 ("blog", include_str!("../themes/blog.css")),
28 ("wiki", include_str!("../themes/wiki.css")),
29 ("docs", include_str!("../themes/docs.css")),
30];
31
32/// The stylesheet for a built-in theme, or `None` if no theme goes by that name.
33pub fn theme_css(name: &str) -> Option<&'static str> {
34 THEMES
35 .iter()
36 .find(|(theme, _)| *theme == name)
37 .map(|(_, css)| *css)
38}
39
40/// Every theme name [`theme_css`] accepts, for error messages and documentation.
41pub fn available_themes() -> Vec<&'static str> {
42 THEMES.iter().map(|(name, _)| *name).collect()
43}