Expand description
Bamboo is a fast static site generator written in Rust.
This crate is the library that powers the bamboo CLI. Most users will
prefer the CLI (cargo install bamboo-cli), but the library is useful when
you want to embed site generation into your own tool, generate output in
multiple passes, or compose custom post-processing around the render step.
See the project README for the authoring-side documentation — content directory layout, frontmatter fields, shortcodes, and the Tera template context.
§Entry points
SiteBuilderreads a site directory (bamboo.toml,content/,data/,static/,templates/) and produces an in-memorySitetree.ThemeEnginerenders aSiteto an output directory using Tera templates from the built-in default theme or a custom theme.
§Example
use bamboo_ssg::{SiteBuilder, ThemeEngine};
let site = SiteBuilder::new("./my-site")
.base_url("https://example.com")
.include_drafts(false)
.build()?;
let theme = ThemeEngine::new("default")?;
theme.render_site(&site, std::path::Path::new("./dist"))?;Re-exports§
pub use cache::BuildState;pub use cache::ChangeClassification;pub use cache::RenderTarget;pub use cache::classify_changes;pub use cache::compute_content_hashes;pub use cache::expand_targets;pub use cache::load_cache;pub use cache::save_cache;pub use cache::should_render;pub use error::BambooError;pub use error::IoContext;pub use error::Result;pub use links::LinkWarning;pub use links::validate_internal_links;pub use parsing::MarkdownRenderer;pub use parsing::RenderedMarkdown;pub use parsing::extract_excerpt;pub use parsing::extract_frontmatter;pub use parsing::parse_date_from_filename;pub use parsing::reading_time;pub use parsing::slugify;pub use parsing::word_count;pub use site::SiteBuilder;pub use theme::ThemeEngine;pub use theme::clean_output_dir;pub use types::Asset;pub use types::Collection;pub use types::CollectionItem;pub use types::Content;pub use types::Frontmatter;pub use types::Page;pub use types::Post;pub use types::Site;pub use types::SiteConfig;pub use types::TaxonomyDefinition;pub use types::TocEntry;
Modules§
- assets
- Post-build asset processing: Sass/SCSS compilation, CSS/JS/HTML minification, and content-hash fingerprinting of static files.
- cache
- Incremental build cache: content hashing and change classification so
bamboo servecan rebuild only what actually changed between edits. - error
- The
BambooErrortype and the crate-wideResultalias. - feeds
- RSS 2.0 and Atom feed generation for a built
Site. - images
- Responsive image generation: resizes source images to configured widths
and emits
<picture>/srcset-ready output alongside the originals. - links
- Post-build internal link validation: walks the generated HTML and reports references that resolve nowhere in the output tree.
- parsing
- Markdown rendering with syntect-powered syntax highlighting, plus the helper functions that back common content-processing needs: frontmatter extraction, filename-date parsing, slugification, word count, reading time, and excerpt generation.
- redirects
- Generates HTML redirect stubs for every
redirect_fromentry declared in frontmatter, so old URLs continue to resolve after a content move. - search
- Client-side search index generation. Produces a
search-index.jsonfile that the Fuse.js-based search page in the default theme consumes. - shortcodes
- Shortcode processor: expands inline
{{< name arg="..." >}}and block{{% name %}}...{{% /name %}}tags in markdown content by rendering Tera templates undertemplates/shortcodes/. - site
- Site assembly: loads
bamboo.toml, walks the content directory, parses frontmatter, expands shortcodes, and produces an in-memorySitetree ready to hand to thethemerenderer. - sitemap
sitemap.xmlgeneration covering every page, post, taxonomy index, and pagination slice in a builtSite.- theme
- The
ThemeEnginethat renders aSiteto disk using Tera templates from the built-in default theme (embedded viainclude_str!) or a user-supplied theme directory. - types
- Data types that describe a loaded site:
Site,SiteConfig,Page,Post,Collection,Content,Frontmatter, and supporting metadata. These types appear in the Tera template context, so every field is effectively part of the authoring-side API. - xml
- Minimal XML entity escape/unescape helpers used by the feed and sitemap generators. Not a general-purpose XML library.