mkdocs-recently-updated-docs 1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mkdocs_recently_updated_docs/__init__.py +0 -0
- mkdocs_recently_updated_docs/plugin.py +50 -0
- mkdocs_recently_updated_docs/templates/recently_updated_group.html +181 -0
- mkdocs_recently_updated_docs-1.4.dist-info/METADATA +94 -0
- mkdocs_recently_updated_docs-1.4.dist-info/RECORD +9 -0
- mkdocs_recently_updated_docs-1.4.dist-info/WHEEL +5 -0
- mkdocs_recently_updated_docs-1.4.dist-info/entry_points.txt +2 -0
- mkdocs_recently_updated_docs-1.4.dist-info/licenses/LICENSE +22 -0
- mkdocs_recently_updated_docs-1.4.dist-info/top_level.txt +1 -0
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from jinja2 import Environment, FileSystemLoader, select_autoescape
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from mkdocs.plugins import BasePlugin
|
|
4
|
+
from mkdocs.config import config_options
|
|
5
|
+
from mkdocs_document_dates.utils import load_git_last_updated_date, get_recently_updated_files
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class RecentlyUpdatedPlugin(BasePlugin):
|
|
9
|
+
config_scheme = (
|
|
10
|
+
('limit', config_options.Type(int, default=10)),
|
|
11
|
+
('exclude', config_options.Type(list, default=[]))
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
def __init__(self):
|
|
15
|
+
super().__init__()
|
|
16
|
+
|
|
17
|
+
self.recent_docs_html = None
|
|
18
|
+
|
|
19
|
+
def on_env(self, env, config, files):
|
|
20
|
+
limit = self.config.get('limit')
|
|
21
|
+
exclude_list = self.config.get('exclude')
|
|
22
|
+
|
|
23
|
+
docs_dir = Path(config['docs_dir'])
|
|
24
|
+
git_updated_dates = load_git_last_updated_date(docs_dir)
|
|
25
|
+
recently_updated_data = get_recently_updated_files(git_updated_dates, files, exclude_list, limit, True)
|
|
26
|
+
|
|
27
|
+
# 渲染HTML
|
|
28
|
+
self.recent_docs_html = self._render_recently_updated_html(recently_updated_data)
|
|
29
|
+
|
|
30
|
+
return env
|
|
31
|
+
|
|
32
|
+
def _render_recently_updated_html(self, recently_updated_data):
|
|
33
|
+
default_template_path = Path(__file__).parent / 'templates' / 'recently_updated_group.html'
|
|
34
|
+
template_dir = default_template_path.parent
|
|
35
|
+
template_file = default_template_path.name
|
|
36
|
+
|
|
37
|
+
# 加载模板
|
|
38
|
+
env = Environment(
|
|
39
|
+
loader = FileSystemLoader(str(template_dir)),
|
|
40
|
+
autoescape = select_autoescape(["html", "xml"])
|
|
41
|
+
)
|
|
42
|
+
template = env.get_template(template_file)
|
|
43
|
+
|
|
44
|
+
# 渲染模板
|
|
45
|
+
return template.render(recent_docs=recently_updated_data)
|
|
46
|
+
|
|
47
|
+
def on_post_page(self, output, page, config):
|
|
48
|
+
if '\n<!-- RECENTLY_UPDATED_DOCS -->' in output:
|
|
49
|
+
output = output.replace('\n<!-- RECENTLY_UPDATED_DOCS -->', self.recent_docs_html or '')
|
|
50
|
+
return output
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
<style>
|
|
2
|
+
.article-layout-switcher {
|
|
3
|
+
display: flex;
|
|
4
|
+
justify-content: flex-end;
|
|
5
|
+
margin-bottom: 12px;
|
|
6
|
+
}
|
|
7
|
+
.article-layout-switcher button + button {
|
|
8
|
+
margin-left: 8px;
|
|
9
|
+
}
|
|
10
|
+
.article-layout-switcher button {
|
|
11
|
+
background: transparent;
|
|
12
|
+
border: none;
|
|
13
|
+
cursor: pointer;
|
|
14
|
+
padding: 4px;
|
|
15
|
+
border-radius: 4px;
|
|
16
|
+
display: flex;
|
|
17
|
+
align-items: center;
|
|
18
|
+
color: var(--md-typeset-color, #1c1c1c);
|
|
19
|
+
opacity: 0.4;
|
|
20
|
+
transition: all 0.2s;
|
|
21
|
+
}
|
|
22
|
+
.article-layout-switcher button:hover {
|
|
23
|
+
background: rgba(142, 142, 142, 0.1);
|
|
24
|
+
opacity: 0.8;
|
|
25
|
+
}
|
|
26
|
+
.article-layout-switcher button.is-active {
|
|
27
|
+
opacity: 1;
|
|
28
|
+
color: var(--md-accent-fg-color, blue);
|
|
29
|
+
background: rgba(142, 142, 142, 0.1);
|
|
30
|
+
}
|
|
31
|
+
.article-layout-switcher .material-icons {
|
|
32
|
+
font-size: 20px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* --- 网格模式 (默认) --- */
|
|
36
|
+
.article-grid {
|
|
37
|
+
display: grid;
|
|
38
|
+
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
|
39
|
+
gap: 20px;
|
|
40
|
+
margin: 20px 0;
|
|
41
|
+
/* transition: all 0.2s ease; */
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* --- 详情模式 (is-detail) --- */
|
|
45
|
+
.article-grid.is-detail {
|
|
46
|
+
grid-template-columns: 1fr;
|
|
47
|
+
margin-left: auto;
|
|
48
|
+
margin-right: auto;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* --- 列表模式 (is-list) --- */
|
|
52
|
+
.article-grid.is-list {
|
|
53
|
+
margin-left: auto;
|
|
54
|
+
margin-right: auto;
|
|
55
|
+
|
|
56
|
+
border: 1px solid rgba(142, 142, 142, 0.2);
|
|
57
|
+
border-radius: 8px;
|
|
58
|
+
row-gap: 0;
|
|
59
|
+
padding: 11px;
|
|
60
|
+
}
|
|
61
|
+
.article-grid.is-list .card-body {
|
|
62
|
+
display: none;
|
|
63
|
+
}
|
|
64
|
+
.article-grid.is-list .article-card {
|
|
65
|
+
border: none;
|
|
66
|
+
border-radius: 0;
|
|
67
|
+
padding: 8px;
|
|
68
|
+
}
|
|
69
|
+
.article-grid.is-list .card-title {
|
|
70
|
+
font-weight: 400;
|
|
71
|
+
color: #0077cc;
|
|
72
|
+
/* color: var(--md-typeset-color, #1c1c1c); */
|
|
73
|
+
}
|
|
74
|
+
.article-grid.is-list .card-date {
|
|
75
|
+
margin-right: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
.article-card {
|
|
80
|
+
border: 1px solid rgba(142, 142, 142, 0.2);
|
|
81
|
+
border-radius: 8px;
|
|
82
|
+
padding: 16px;
|
|
83
|
+
font-family: sans-serif;
|
|
84
|
+
box-sizing: border-box;
|
|
85
|
+
display: flex;
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* --- 第一行:标题与时间 --- */
|
|
90
|
+
.card-header {
|
|
91
|
+
display: flex;
|
|
92
|
+
justify-content: space-between;
|
|
93
|
+
align-items: center;
|
|
94
|
+
text-decoration: none;
|
|
95
|
+
}
|
|
96
|
+
.card-title {
|
|
97
|
+
font-weight: 700;
|
|
98
|
+
line-height: 1.4;
|
|
99
|
+
color: var(--md-typeset-color, #1c1c1c);
|
|
100
|
+
margin-right: 16px;
|
|
101
|
+
}
|
|
102
|
+
.card-date {
|
|
103
|
+
font-size: 0.84em;
|
|
104
|
+
color: rgba(100, 100, 100, 0.4);
|
|
105
|
+
white-space: nowrap;
|
|
106
|
+
margin-right: 10px;
|
|
107
|
+
}
|
|
108
|
+
.card-header:hover .card-title {
|
|
109
|
+
color: var(--md-accent-fg-color, blue);
|
|
110
|
+
text-decoration: underline;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* --- 第二行:摘要与封面图 --- */
|
|
114
|
+
.card-body {
|
|
115
|
+
display: flex;
|
|
116
|
+
justify-content: space-between;
|
|
117
|
+
align-items: center;
|
|
118
|
+
margin-top: 12px;
|
|
119
|
+
}
|
|
120
|
+
.card-summary {
|
|
121
|
+
flex: 1;
|
|
122
|
+
color: rgba(142, 142, 142, 1);
|
|
123
|
+
font-size: 0.7rem;
|
|
124
|
+
line-height: 1.6;
|
|
125
|
+
letter-spacing: 0.02rem;
|
|
126
|
+
word-break: break-all;
|
|
127
|
+
|
|
128
|
+
/* 3 行文字截断,超出显示省略号 */
|
|
129
|
+
display: -webkit-box;
|
|
130
|
+
-webkit-box-orient: vertical;
|
|
131
|
+
-webkit-line-clamp: 3;
|
|
132
|
+
overflow: hidden;
|
|
133
|
+
}
|
|
134
|
+
.card-cover {
|
|
135
|
+
width: 120px;
|
|
136
|
+
height: 80px;
|
|
137
|
+
border-radius: 8px;
|
|
138
|
+
flex-shrink: 0;
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
overflow: hidden;
|
|
143
|
+
margin-left: 10px;
|
|
144
|
+
}
|
|
145
|
+
.card-cover a {
|
|
146
|
+
display: block;
|
|
147
|
+
width: 100%;
|
|
148
|
+
height: 100%;
|
|
149
|
+
}
|
|
150
|
+
.card-cover img {
|
|
151
|
+
width: 100%;
|
|
152
|
+
height: 100%;
|
|
153
|
+
object-fit: cover;
|
|
154
|
+
margin: 0 !important;
|
|
155
|
+
}
|
|
156
|
+
</style>
|
|
157
|
+
|
|
158
|
+
<div class="article-layout-switcher">
|
|
159
|
+
<button class="layout-list-btn" title="List View"><span class="material-icons">view_list</span></button>
|
|
160
|
+
<button class="layout-detail-btn" title="Detail View"><span class="material-icons">view_day</span></button>
|
|
161
|
+
<button class="layout-grid-btn" title="Grid View"><span class="material-icons">view_module</span></button>
|
|
162
|
+
</div>
|
|
163
|
+
|
|
164
|
+
<div class="article-grid">
|
|
165
|
+
{%- for mtime, rel_path, title, url, cover, summary in recent_docs %}
|
|
166
|
+
<div class="article-card">
|
|
167
|
+
<a class="card-header" href="{{ url }}" target="_blank">
|
|
168
|
+
<div class="card-title">{{ title }}</div>
|
|
169
|
+
<time class="dd-timeago card-date" datetime="{{ mtime }}">{{ mtime[:10] }}</time>
|
|
170
|
+
</a>
|
|
171
|
+
<div class="card-body">
|
|
172
|
+
<div class="card-summary">{{ summary }}</div>
|
|
173
|
+
{%- if cover %}
|
|
174
|
+
<div class="card-cover">
|
|
175
|
+
<img src="{{ cover }}" alt="{{ title }}">
|
|
176
|
+
</div>
|
|
177
|
+
{%- endif %}
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
{%- endfor %}
|
|
181
|
+
</div>
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mkdocs-recently-updated-docs
|
|
3
|
+
Version: 1.4
|
|
4
|
+
Summary: A MkDocs plugin to show recently updated documents
|
|
5
|
+
Author-email: Aaron Wang <aaronwqt@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/jaywhj/mkdocs-recently-updated-docs
|
|
8
|
+
Project-URL: Documentation, https://jaywhj.netlify.app/document-dates-en
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: mkdocs>=1.1.0
|
|
15
|
+
Requires-Dist: mkdocs-document-dates>=3.5
|
|
16
|
+
Dynamic: license-file
|
|
17
|
+
|
|
18
|
+
# mkdocs-recently-updated-docs
|
|
19
|
+
|
|
20
|
+
English | [简体中文](README_zh.md)
|
|
21
|
+
|
|
22
|
+
<br />
|
|
23
|
+
|
|
24
|
+
Display a list of recently updated documents anywhere on your MkDocs site with a single line of code. This is ideal for sites **with a large number of documents**, so that **readers can quickly see what's new**.
|
|
25
|
+
|
|
26
|
+
## Features
|
|
27
|
+
|
|
28
|
+
- Display recently updated documents in descending order by update time, list items are dynamically updated
|
|
29
|
+
- Support multiple view modes such as list, detail and grid
|
|
30
|
+
- Support automatic extraction of article summaries
|
|
31
|
+
- Support custom display quantity
|
|
32
|
+
- Support exclude specified files or folders
|
|
33
|
+
- Works well for any environment (no-Git, Git, Docker, all CI/CD build systems, etc.)
|
|
34
|
+
|
|
35
|
+
## Preview
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install mkdocs-recently-updated-docs
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
Just add the plugin to your `mkdocs.yml`:
|
|
48
|
+
|
|
49
|
+
```yaml
|
|
50
|
+
plugins:
|
|
51
|
+
- recently-updated
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Or, full configuration:
|
|
55
|
+
|
|
56
|
+
```yaml
|
|
57
|
+
plugins:
|
|
58
|
+
- recently-updated:
|
|
59
|
+
limit: 10 # Limit the number of docs displayed
|
|
60
|
+
exclude: # List of excluded files
|
|
61
|
+
- index.md # Exclude specific file
|
|
62
|
+
- blog/* # Exclude all files in blog folder, including subfolders
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
Simply write this line anywhere in your md document:
|
|
68
|
+
|
|
69
|
+
```markdown
|
|
70
|
+
<!-- RECENTLY_UPDATED_DOCS -->
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
<br />
|
|
74
|
+
|
|
75
|
+
## Other Projects
|
|
76
|
+
|
|
77
|
+
- [**MaterialX**](https://github.com/jaywhj/mkdocs-materialx), the next generation of mkdocs-material, is based on `mkdocs-material-9.7.0` and is named `X`. I'll be maintaining this branch continuously (since mkdocs-material will stop being maintained).
|
|
78
|
+
Updates have been released that refactor and add a lot of new features, see https://github.com/jaywhj/mkdocs-materialx/releases/
|
|
79
|
+
|
|
80
|
+
<br />
|
|
81
|
+
|
|
82
|
+
- [**mkdocs-document-dates**](https://github.com/jaywhj/mkdocs-document-dates), a new generation MkDocs plugin for displaying exact **creation date, last updated date, authors, email** of documents
|
|
83
|
+
|
|
84
|
+

|
|
85
|
+
|
|
86
|
+
<br />
|
|
87
|
+
|
|
88
|
+
## Chat Group
|
|
89
|
+
|
|
90
|
+
**Discord**: https://discord.gg/cvTfge4AUy
|
|
91
|
+
|
|
92
|
+
**Wechat**:
|
|
93
|
+
|
|
94
|
+
<img src="wechat-group.jpg" width="140" />
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
mkdocs_recently_updated_docs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mkdocs_recently_updated_docs/plugin.py,sha256=sVUr-f_nwSziuHWs2J98_C4EqiTAMni5CxP4j5XTaYk,1855
|
|
3
|
+
mkdocs_recently_updated_docs/templates/recently_updated_group.html,sha256=dXCfhQ7BNQQKJKL64N1Bd4On8cMeKyK_RZCGFln3YDg,4381
|
|
4
|
+
mkdocs_recently_updated_docs-1.4.dist-info/licenses/LICENSE,sha256=U214AUYxlWBRMcXtMCIHKPyd744Wc7YWu40eKZb8r68,1068
|
|
5
|
+
mkdocs_recently_updated_docs-1.4.dist-info/METADATA,sha256=4zlzjpflGK8JhxBR2GuIiSi2Ll1lEoUsWL13f4B3FtA,2731
|
|
6
|
+
mkdocs_recently_updated_docs-1.4.dist-info/WHEEL,sha256=qELbo2s1Yzl39ZmrAibXA2jjPLUYfnVhUNTlyF1rq0Y,92
|
|
7
|
+
mkdocs_recently_updated_docs-1.4.dist-info/entry_points.txt,sha256=deX7xyDvYRa4SaqfZl0yPHCjMEkpjzn4hU4shOMlT_M,94
|
|
8
|
+
mkdocs_recently_updated_docs-1.4.dist-info/top_level.txt,sha256=dAsrTPV8Yfy-0mkOcD6uASogl-WleHLrp1AiC4HV2n0,29
|
|
9
|
+
mkdocs_recently_updated_docs-1.4.dist-info/RECORD,,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Aaron Wang
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mkdocs_recently_updated_docs
|