/` (respecting `localStorage` preference).
+The root `index.html` is generated automatically and redirects to the default language, respecting the user's `localStorage` language preference.
-## Local Debugging vs GitHub Pages
+### Sidebar Navigation
-To preview locally with the same URL structure as GitHub Pages, set `base_path = "/cpp-httplib"` in `config.toml`, then:
-
-```bash
-./docs-gen/target/release/docs-gen docs-src --out /tmp/test/cpp-httplib
-cd /tmp/test && python3 -m http.server
-# Open http://localhost:8000/cpp-httplib/
-```
-
-For a plain local preview (no prefix), set `base_path = ""` and open `http://localhost:8000/`.
-
-## Navigation
-
-Navigation is generated automatically from the directory structure:
+Sidebar navigation is generated automatically:
- Each subdirectory under a language becomes a **section**
- The section's `index.md` title is used as the section heading
- Pages within a section are sorted by `order`, then by filename
-- `portal.html` template is used for root `index.md` (no sidebar)
-- `page.html` template is used for all other pages (with sidebar)
+- `index.md` at the language root uses `portal.html` (no sidebar)
+- All other pages use `page.html` (with sidebar)
+
+---
+
+## Customizing Templates and Assets
+
+When `templates/` or `static/` directories exist in the source, files there override the built-in defaults. Use `docs-gen init` to generate the defaults as a starting point.
+
+Three templates are available:
+
+| Template | Used for |
+|----------|----------|
+| `base.html` | Shared layout: ``, header, footer, scripts |
+| `page.html` | Content pages with sidebar |
+| `portal.html` | Homepage (`index.md` at language root), no sidebar |
+
+---
## Template Variables
@@ -139,37 +220,33 @@ Templates use [Tera](https://keats.github.io/tera/) syntax. Available variables:
### All templates
-| Variable | Type | Description |
-|---------------|--------|-------------|
-| `page.title` | string | Page title from frontmatter |
-| `page.url` | string | Page URL path |
+| Variable | Type | Description |
+|----------|------|-------------|
+| `page.title` | string | Page title from frontmatter |
+| `page.url` | string | Page URL path |
| `page.status` | string? | `"draft"` or null |
-| `content` | string | Rendered HTML content (use `{{ content \| safe }}`) |
-| `lang` | string | Current language code |
-| `site.title` | string | Site title from config |
-| `site.base_url` | string | Base URL from config |
-| `site.base_path` | string | Base path prefix (e.g. `"/cpp-httplib"` or `""`) |
-| `site.langs` | list | Available language codes |
+| `content` | string | Rendered HTML (use `{{ content \| safe }}`) |
+| `lang` | string | Current language code |
+| `site.title` | string | Site title |
+| `site.version` | string? | Site version |
+| `site.base_url` | string | Full base URL (`hostname` + `base_path`) |
+| `site.base_path` | string | URL path prefix |
+| `site.langs` | list | All language codes |
+| `site.nav` | list | Toolbar button entries |
+| `site.nav[].label` | string | Button label |
+| `site.nav[].url` | string? | External URL (if set) |
+| `site.nav[].path` | string? | Internal section path (if set) |
+| `site.nav[].icon_svg` | string? | Inline SVG icon (if set) |
-### page.html only
+### `page.html` only
-| Variable | Type | Description |
-|--------------------|--------|-------------|
-| `nav` | list | Navigation sections |
-| `nav[].title` | string | Section title |
-| `nav[].url` | string | Section URL |
-| `nav[].active` | bool | Whether this section contains the current page |
-| `nav[].children` | list | Child pages |
+| Variable | Type | Description |
+|----------|------|-------------|
+| `nav` | list | Sidebar sections |
+| `nav[].title` | string | Section title |
+| `nav[].url` | string | Section index URL |
+| `nav[].active` | bool | True if this section contains the current page |
+| `nav[].children` | list | Pages within this section |
| `nav[].children[].title` | string | Page title |
-| `nav[].children[].url` | string | Page URL |
-| `nav[].children[].active` | bool | Whether this is the current page |
-
-## Dependencies
-
-- [pulldown-cmark](https://crates.io/crates/pulldown-cmark) — Markdown parsing
-- [tera](https://crates.io/crates/tera) — Template engine
-- [syntect](https://crates.io/crates/syntect) — Syntax highlighting
-- [walkdir](https://crates.io/crates/walkdir) — Directory traversal
-- [serde](https://crates.io/crates/serde) / [serde_yml](https://crates.io/crates/serde_yml) / [toml](https://crates.io/crates/toml) — Serialization
-- [clap](https://crates.io/crates/clap) — CLI argument parsing
-- [anyhow](https://crates.io/crates/anyhow) — Error handling
+| `nav[].children[].url` | string | Page URL |
+| `nav[].children[].active` | bool | True if this is the current page |
diff --git a/docs-gen/defaults/config.toml b/docs-gen/defaults/config.toml
index 47a780d..19b544e 100644
--- a/docs-gen/defaults/config.toml
+++ b/docs-gen/defaults/config.toml
@@ -1,7 +1,7 @@
[site]
title = "My Docs"
-base_url = "https://example.com"
-base_path = ""
+hostname = "https://example.github.io"
+base_path = "/my-project"
# [[nav]]
# label = "Guide"
@@ -10,12 +10,10 @@ base_path = ""
# [[nav]]
# label = "GitHub"
# url = "https://github.com/your/repo"
-# icon = "github"
+# icon_svg = ''
[i18n]
-default_lang = "en"
-langs = ["en", "ja"]
+langs = ["en"]
[highlight]
theme = "base16-ocean.dark"
-theme_light = "InspiredGitHub"
diff --git a/docs-gen/defaults/pages/en/index.md b/docs-gen/defaults/pages/en/index.md
index 2ccfc54..858230b 100644
--- a/docs-gen/defaults/pages/en/index.md
+++ b/docs-gen/defaults/pages/en/index.md
@@ -3,7 +3,7 @@ title: Welcome
order: 0
---
-# Welcome
+## Welcome
This is the home page of your documentation site.
diff --git a/docs-gen/defaults/pages/ja/index.md b/docs-gen/defaults/pages/ja/index.md
index 96312d7..3c792c0 100644
--- a/docs-gen/defaults/pages/ja/index.md
+++ b/docs-gen/defaults/pages/ja/index.md
@@ -3,7 +3,7 @@ title: ようこそ
order: 0
---
-# ようこそ
+## ようこそ
ドキュメントサイトのトップページです。
diff --git a/docs-gen/defaults/static/css/main.css b/docs-gen/defaults/static/css/main.css
index cd99f44..60e3c3e 100644
--- a/docs-gen/defaults/static/css/main.css
+++ b/docs-gen/defaults/static/css/main.css
@@ -304,7 +304,7 @@ a:hover {
}
.content article pre {
- background: var(--bg-code) !important;
+ background: var(--bg-code);
color: var(--text-code);
padding: 16px;
border-radius: 4px;
@@ -426,13 +426,6 @@ a:hover {
--nav-section-active: #333;
}
-/* Code block theme switching */
-.code-light { display: none; }
-.code-dark { display: block; }
-
-[data-theme="light"] .code-light { display: block; }
-[data-theme="light"] .code-dark { display: none; }
-
/* Theme toggle */
.theme-toggle {
display: flex;
diff --git a/docs-gen/src/builder.rs b/docs-gen/src/builder.rs
index 18e5cef..7d6621b 100644
--- a/docs-gen/src/builder.rs
+++ b/docs-gen/src/builder.rs
@@ -55,7 +55,7 @@ struct Page {
pub fn build(src: &Path, out: &Path) -> Result<()> {
let config = SiteConfig::load(src)?;
- let renderer = MarkdownRenderer::new(config.highlight_theme(), config.highlight_theme_light());
+ let renderer = MarkdownRenderer::new(config.highlight_theme());
// Build Tera: start with embedded defaults, then override with user templates
let tera = build_tera(src)?;
@@ -125,7 +125,7 @@ pub fn build(src: &Path, out: &Path) -> Result<()> {
ctx.insert("site", &SiteContext {
title: config.site.title.clone(),
version: config.site.version.clone(),
- base_url: config.site.base_url.clone(),
+ base_url: config.site.base_url(),
base_path: config.site.base_path.clone(),
langs: config.i18n.langs.clone(),
nav: config.nav.clone(),
@@ -351,7 +351,7 @@ fn generate_root_redirect(out: &Path, config: &SiteConfig) -> Result<()> {
Redirecting to {base_path}/{default_lang}/...