AgentSkillsCN

zensical-customizer

通过交互式页面、自定义模板、JavaScript小部件与CSS样式,对Zensical文档站点进行个性化定制与功能扩展。在进行文档站点定制时使用:(1) 创建自定义或交互式文档页面;(2) 在文档中引入JavaScript小部件或第三方库;(3) 覆盖模板或部分组件;(4) 添加或修改CSS样式;(5) 设计自定义页面布局(落地页、演示页、仪表盘);(6) 配置zensical.toml设置;(7) 将外部JS框架集成到文档页面中。可通过“文档站点”“文档页面”“交互式演示”“自定义模板”“Zensical”“extra_css”“extra_javascript”“覆盖”“模板区块”“页面布局”“小部件集成”等操作触发。切勿用于:撰写或编辑Markdown文档内容、解答MkDocs通用问题(此为Zensical专属功能),或阅读/查看现有文档页面。

SKILL.md
--- frontmatter
name: zensical-customizer
description: >-
  Customize and extend Zensical documentation sites with interactive pages, custom templates,
  JavaScript widgets, and CSS styling. Use when working on documentation site customization
  including: (1) creating custom or interactive doc pages, (2) adding JavaScript widgets or
  third-party libraries to docs, (3) overriding templates or partials, (4) adding/modifying
  CSS styles, (5) creating custom page layouts (landing pages, demos, dashboards),
  (6) configuring zensical.toml settings, (7) integrating external JS frameworks into doc pages.
  Triggers on: docs site, documentation page, interactive demo, custom template, zensical,
  extra_css, extra_javascript, overrides, template block, page layout, widget integration.
  Do NOT use for: writing or editing markdown documentation content, general MkDocs questions
  (this is Zensical-specific), or reading/viewing existing docs pages.

Zensical Customizer

Zensical is the successor to Material for MkDocs, built by the same team. Config file: zensical.toml (TOML format, all settings under [project]). Template engine: MiniJinja (Rust). Dev server: uv run poe docs-serve. Build: uv run poe docs-build.

Use DeepWiki (mcp__deepwiki__ask_question with repo zensical/zensical) for questions about Zensical internals not covered here.

Decision Tree

  1. Add styles to existing pages -> Edit docs/stylesheets/extra.css or create a new stylesheet and register in extra_css. See project-setup.md.

  2. Add JavaScript to all pages -> Place script in docs/javascripts/, register in extra_javascript in zensical.toml. See javascript.md.

  3. Add interactive widget to specific page -> Add <div id="mount"> in markdown, create JS that uses document$ to mount on that element. See "Pattern 1" in javascript.md.

  4. Create a fully custom page layout -> Set up overrides/ directory, create custom template extending base.html, reference via page frontmatter template: field. See templates.md.

  5. Override header/footer/nav -> Override partials in overrides/partials/. See "Overridable Partials" in templates.md.

  6. Embed a JS framework app (React, Vue, Svelte) -> Build externally, output bundle to docs/javascripts/, mount via document$ or custom template. See "Pattern 2" and "Pattern 3" in javascript.md.

Quick Start: Add an Interactive Page

Step 1: Enable template overrides (one-time)

Add to zensical.toml under [project.theme]:

toml
custom_dir = "overrides"

Create the directory: overrides/

Step 2: Create a custom template

Create overrides/interactive.html:

jinja2
{% extends "base.html" %}

{% block content %}
  {{ page.content }}
  <div id="app-mount"></div>
{% endblock %}

{% block scripts %}
  {{ super() }}
  <script type="module" src="{{ base_url }}/javascripts/my-app.js"></script>
{% endblock %}

Step 3: Create the page

Create a markdown file (e.g., docs/demos/my-demo.md):

yaml
---
template: interactive.html
icon: lucide/play
---

# Interactive Demo

Description of the demo.

Step 4: Add JavaScript

Place docs/javascripts/my-app.js with initialization logic.

Step 5: Register in navigation

Add to nav in zensical.toml:

toml
{ "Demos" = ["demos/my-demo.md"] },

Key Constraints

  • No full plugin/module system - extensibility is limited to templates, JS, CSS
  • MiniJinja, not Jinja2 - mostly compatible, but complex Jinja2 patterns may differ
  • 125% root font-size - Zensical sets html { font-size: 125% } (20px); third-party libraries with rem-based sizing render 25% larger. Fix with explicit pixel values.
  • Markdown extensions are all-or-nothing - defining any custom extensions requires configuring ALL extensions (defaults don't apply partially)
  • navigation.instant not enabled in this project - window.load works for site-wide scripts, but page-specific widgets should still use document$ for forward compatibility

References

  • templates.md - Template blocks, custom page templates, partials, context variables, MiniJinja syntax
  • javascript.md - JS/CSS injection, document$ observable, instant navigation, interactive component patterns
  • project-setup.md - This project's directory structure, existing customizations, ISCC brand colors, Zensical quirks