Skip to content

Commit 98944a3

Browse files
author
dompling
committed
Add SEO metadata and sitemap plugin support, configure custom theme directory and extra SEO settings in mkdocs.yml
1 parent 0d004f4 commit 98944a3

File tree

3 files changed

+55
-3
lines changed

3 files changed

+55
-3
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ jobs:
163163
164164
- name: Install dependencies
165165
run: |
166-
pip install mkdocs-material
166+
pip install mkdocs-material mkdocs-sitemap-plugin
167167
168168
- name: Prepare Workspace
169169
run: |
@@ -177,4 +177,4 @@ jobs:
177177
178178
179179
- name: Build and Deploy
180-
run: mkdocs gh-deploy --force
180+
run: mkdocs gh-deploy --force

mkdocs.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
site_name: TrollScript
22
site_url: https://trollscript.qzz.io
33
site_description: TrollScript 官方文档与 API 参考
4+
site_author: TrollScript Team
45
repo_url: https://github.com/dompling/TrollScript-Release
56

67
theme:
78
name: material
9+
custom_dir: overrides
810
language: zh
911
palette:
1012
# 自动切换深色/浅色模式
@@ -64,12 +66,26 @@ nav:
6466
- iCloud: iCloud.md
6567
- 常见问题: FAQ.md
6668

69+
plugins:
70+
- search:
71+
lang:
72+
- zh
73+
- en
74+
- sitemap
75+
76+
extra:
77+
seo:
78+
keywords: TrollScript, iOS automation, TrollStore, JavaScript API, iOS scripting, iOS docs
79+
og_image: https://trollscript.qzz.io/AppIcon.png
80+
twitter_card: summary_large_image
81+
6782

6883
markdown_extensions:
84+
- meta
6985
- toc:
7086
permalink: true
7187
- admonition # 警告/提示框
7288
- pymdownx.details # 折叠详情
7389
- pymdownx.superfences # 嵌套代码块
7490
- pymdownx.tabbed: # 选项卡
75-
alternate_style: true
91+
alternate_style: true

overrides/main.html

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% extends "base.html" %}
2+
3+
{% block extrahead %}
4+
{{ super() }}
5+
6+
{% set seo_title = config.site_name %}
7+
{% if page and page.title %}
8+
{% set seo_title = page.title ~ " - " ~ config.site_name %}
9+
{% endif %}
10+
11+
{% set seo_description = config.site_description %}
12+
{% if page and page.meta and page.meta.description %}
13+
{% set seo_description = page.meta.description %}
14+
{% endif %}
15+
16+
{% set seo_url = config.site_url %}
17+
{% if page and page.canonical_url %}
18+
{% set seo_url = page.canonical_url %}
19+
{% endif %}
20+
21+
<meta name="robots" content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1" />
22+
<meta name="author" content="{{ config.site_author }}" />
23+
<meta name="keywords" content="{{ config.extra.seo.keywords }}" />
24+
25+
<meta property="og:type" content="website" />
26+
<meta property="og:site_name" content="{{ config.site_name }}" />
27+
<meta property="og:title" content="{{ seo_title }}" />
28+
<meta property="og:description" content="{{ seo_description }}" />
29+
<meta property="og:url" content="{{ seo_url }}" />
30+
<meta property="og:image" content="{{ config.extra.seo.og_image }}" />
31+
32+
<meta name="twitter:card" content="{{ config.extra.seo.twitter_card }}" />
33+
<meta name="twitter:title" content="{{ seo_title }}" />
34+
<meta name="twitter:description" content="{{ seo_description }}" />
35+
<meta name="twitter:image" content="{{ config.extra.seo.og_image }}" />
36+
{% endblock %}

0 commit comments

Comments
 (0)