Skip to content

Commit 6ce8f09

Browse files
committed
chore: update files
1 parent be8a8a1 commit 6ce8f09

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ theme:
6363

6464
plugins:
6565
- tags
66-
- meta
6766
- blog:
6867
archive: false
6968
post_date_format: short
@@ -78,6 +77,8 @@ plugins:
7877
token: !!python/object/apply:os.getenv ["MKDOCS_GIT_COMMITTERS_APIKEY"]
7978
- git-revision-date-localized:
8079
enable_creation_date: true
80+
timezone: Asia/Shanghai
81+
type: iso_datetime
8182

8283

8384
markdown_extensions:

overrides/main.html

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,22 @@
1212
{% endblock %}
1313

1414
{% block content %}
15-
<!-- 先渲染原始内容 -->
16-
{{ super() }}
15+
{# --- 过期检测逻辑 --- #}
16+
{% if page and page.meta.revision_date %}
17+
{% set now = (none).timestamp() | int %}
18+
{% set last_modified = page.meta.revision_date.timestamp() | int %}
19+
{% set days_since_update = ((now - last_modified) / 86400) | int %}
1720

18-
<!-- 添加过时警告逻辑 -->
19-
{% if page and page.meta.date %}
20-
{% set doc_date = page.meta.date %}
21-
{% set today = "" | as_datetime("%Y-%m-%d") %}
22-
{% set diff_days = (today | date("%s") - doc_date | date("%s")) // 86400 %}
21+
{% set stale_after_days = 365 %} {# 可自定义阈值 #}
2322

24-
{% if diff_days > 365 %}
25-
<div class="md-typeset">
26-
<div class="md-admonition warning outdated-warning">
27-
<p class="md-admonition__title">
28-
⚠️ 文档过时提醒
29-
</p>
30-
<p>
31-
本文档最后更新于 <strong>{{ doc_date }}</strong>({{ diff_days }} 天前),
32-
可能包含过时信息,请结合最新文档参考使用。
33-
</p>
34-
</div>
23+
{% if days_since_update > stale_after_days %}
24+
<div class="md-banner">
25+
⚠️ 本文档最后更新于 {{ page.meta.revision_date | date('%Y-%m-%d') }},
26+
已超过 {{ stale_after_days }} 天未更新,内容可能已过时,请注意核实。
3527
</div>
3628
{% endif %}
3729
{% endif %}
30+
31+
{# 继续原始内容 #}
32+
{{ super() }}
3833
{% endblock %}

0 commit comments

Comments
 (0)