diff --git a/public/doc/_sidebar.md b/public/doc/_sidebar.md index c6c368f5..ed4a5178 100644 --- a/public/doc/_sidebar.md +++ b/public/doc/_sidebar.md @@ -7,6 +7,7 @@ - **Integration** - [Docsify](/integration/docsify.md) - [Hexo](https://blog.cusdis.com/integate-cusdis-in-hexo/) + - [Mkdocs](/integration/mkdocs.md) - **Features** - [Email Notification](/features/notification.md) - [Webhook](/advanced/webhook.md) diff --git a/public/doc/integration/docsify.md b/public/doc/integration/docsify.md index 2b5179ec..a591cca2 100644 --- a/public/doc/integration/docsify.md +++ b/public/doc/integration/docsify.md @@ -1,4 +1,4 @@ -# Integrate with Docsify +# Integrate Cusdis into Docsify [Docsify](https://docsify.js.org) is a powerful document site generator, which also powers this Cusdis document. Cusdis has a built-in Docsify plugin. diff --git a/public/doc/integration/mkdocs.md b/public/doc/integration/mkdocs.md new file mode 100644 index 00000000..eb163c0c --- /dev/null +++ b/public/doc/integration/mkdocs.md @@ -0,0 +1,99 @@ +# Integrate Cusdis into Mkdocs + +[MkDocs](https://www.mkdocs.org/) is a **fast**, **simple** and **convenient** static site generator geared towards building project documentation. Documentation source files are written in Markdown, and configured with a single YAML configuration file. + +[Material for MkDocs](https://squidfunk.github.io/mkdocs-material/) is the most commonly used theme for [MkDocs](https://www.mkdocs.org/). + +Once you have [Python](https://www.python.org/) installed on your system, as well as [pip](https://pip.readthedocs.io/en/stable/installing/), you can easily install mkdocs with material-mkdocs and start building your own site. For more detail, follow the documentation of [Getting started](https://squidfunk.github.io/mkdocs-material/getting-started/) + +## Usage + +Here's the tutorial for integrating Cusdis into [Material for MkDocs] following its [comment system configuratin](https://squidfunk.github.io/mkdocs-material/setup/adding-a-comment-system/). As for other [themes](https://github.com/mkdocs/mkdocs/wiki/MkDocs-Themes), you can achieve it in a similar way! + +### Configure the `mkdocs.yml` + +We need add more kv pairs to `mkdocs.yml` with [`extra`](https://www.mkdocs.org/user-guide/configuration/#extra) setting: + +```yaml +extra: + disqus: + cusdis: + host: + app_id: + lang: +``` + +The `lang` setting aims to support [cusdis i18n](../advanced/i18n.md?id=current-support-language). + +### Rewrite the template + +We need first extend the theme and [override the `disqus block`](https://squidfunk.github.io/mkdocs-material/customization/#extending-the-theme) to support Cusdis comment system. + +Inorder to override, we can replace it with a file of the same `disqus.html` name and locate in the `overrides directory`: + +```txt +. +├─ overrides/ +│ └─ partials/ +| └─ partials/ +│ └─ disqus.html +└─ mkdocs.yml +``` + +Add the following line to `disqus.html`: + +```html +{% set cusdis = config.extra.cusdis %} +{% if page and page.meta and page.meta.cusdis is string %} +{% set cusdis = page.meta.cusdis %} +{% endif %} +{% if not page.is_homepage %} +