Add default templates, styles, and scripts for documentation site

This commit is contained in:
yhirose
2026-03-01 20:19:32 -05:00
parent 7444646627
commit b2d76658fc
11 changed files with 190 additions and 11 deletions

View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="{{ lang }}" data-base-path="{{ site.base_path }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ page.title }} - {{ site.title }}</title>
<link rel="stylesheet" href="{{ site.base_path }}/css/main.css">
<script>
(function() {
var t = localStorage.getItem('preferred-theme');
if (!t) t = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
if (t === 'light') document.documentElement.setAttribute('data-theme', 'light');
})();
</script>
</head>
<body>
<header class="header">
<div class="header-inner">
<a href="{{ site.base_path }}/{{ lang }}/" class="header-title">{{ site.title }}{% if site.version %} <span style="font-size:0.75em;font-weight:normal;margin-left:4px">v{{ site.version }}</span>{% endif %}</a>
<div class="header-spacer"></div>
<nav class="header-nav">
<a href="{{ site.base_path }}/{{ lang }}/">Home</a>
<a href="{{ site.base_path }}/{{ lang }}/tour/">Tour</a>
<a href="https://github.com/yhirose/cpp-httplib">GitHub</a>
</nav>
<div class="header-tools">
<button class="theme-toggle" aria-label="Toggle theme"></button>
<div class="lang-selector">
<button class="lang-btn" aria-label="Language">{{ lang | upper }}</button>
<ul class="lang-popup">
{% for l in site.langs %}
<li><a href="#" data-lang="{{ l }}">{{ l | upper }}</a></li>
{% endfor %}
</ul>
</div>
</div>
{% block sidebar_toggle %}{% endblock %}
</div>
</header>
{% if page.status == "draft" %}
<div class="draft-banner">DRAFT</div>
{% endif %}
<div class="layout {% block layout_class %}{% endblock %}">
{% block body %}{% endblock %}
</div>
<footer class="footer">
&copy; 2026 yhirose. All rights reserved.
</footer>
<script src="{{ site.base_path }}/js/main.js"></script>
</body>
</html>

View File

@@ -0,0 +1,30 @@
{% extends "base.html" %}
{% block layout_class %}has-sidebar{% endblock %}
{% block sidebar_toggle %}<button class="sidebar-toggle" aria-label="Menu">&#9776;</button>{% endblock %}
{% block body %}
<aside class="sidebar">
<nav class="sidebar-nav">
{% for section in nav %}
<div class="nav-section">
<a href="{{ section.url }}" class="nav-section-title {% if section.active %}active{% endif %}">{{ section.title }}</a>
{% if section.children %}
<ul class="nav-list">
{% for item in section.children %}
<li><a href="{{ item.url }}" class="{% if item.active %}active{% endif %}">{{ item.title }}</a></li>
{% endfor %}
</ul>
{% endif %}
</div>
{% endfor %}
</nav>
</aside>
<main class="content">
<article>
<h1>{{ page.title }}</h1>
{{ content | safe }}
</article>
</main>
{% endblock %}

View File

@@ -0,0 +1,12 @@
{% extends "base.html" %}
{% block layout_class %}no-sidebar{% endblock %}
{% block body %}
<main class="content portal">
<article>
<h1>{{ page.title }}</h1>
{{ content | safe }}
</article>
</main>
{% endblock %}