mkdocs-document-dates 3.2.1__tar.gz → 3.3__tar.gz

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.
Files changed (43) hide show
  1. {mkdocs_document_dates-3.2.1/mkdocs_document_dates.egg-info → mkdocs_document_dates-3.3}/PKG-INFO +75 -61
  2. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/README.md +73 -59
  3. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/plugin.py +128 -81
  4. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/config/user.config.css +25 -4
  5. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/config/user.config.js +1 -1
  6. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/core/core.css +55 -7
  7. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/core/core.js +49 -1
  8. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3/mkdocs_document_dates.egg-info}/PKG-INFO +75 -61
  9. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/setup.py +3 -3
  10. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/LICENSE +0 -0
  11. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/MANIFEST.in +0 -0
  12. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/__init__.py +0 -0
  13. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/cache_manager.py +0 -0
  14. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/hooks/pre-commit +0 -0
  15. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/hooks_installer.py +0 -0
  16. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/core/timeago-load.js +0 -0
  17. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/core/timeago.full.min.js +0 -0
  18. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/core/timeago.min.js +0 -0
  19. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/ar.json +0 -0
  20. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/de.json +0 -0
  21. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/en.json +0 -0
  22. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/es.json +0 -0
  23. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/fr.json +0 -0
  24. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/ja.json +0 -0
  25. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/ko.json +0 -0
  26. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/ru.json +0 -0
  27. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/zh.json +0 -0
  28. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/languages/zh_TW.json +0 -0
  29. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/backdrop.css +0 -0
  30. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/light.css +0 -0
  31. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/material.css +0 -0
  32. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/popper.min.js +0 -0
  33. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/scale.css +0 -0
  34. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/shift-away.css +0 -0
  35. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/tippy.css +0 -0
  36. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/static/tippy/tippy.umd.min.js +0 -0
  37. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates/utils.py +0 -0
  38. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates.egg-info/SOURCES.txt +0 -0
  39. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates.egg-info/dependency_links.txt +0 -0
  40. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates.egg-info/entry_points.txt +0 -0
  41. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates.egg-info/requires.txt +0 -0
  42. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/mkdocs_document_dates.egg-info/top_level.txt +0 -0
  43. {mkdocs_document_dates-3.2.1 → mkdocs_document_dates-3.3}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.2.1
4
- Summary: A new generation MkDocs plugin for displaying exact meta-info of documents, such as creation time, last update time, authors, email, etc.
3
+ Version: 3.3
4
+ Summary: A new generation MkDocs plugin for displaying exact meta-info, such as creation time, last update time, authors, email, etc
5
5
  Home-page: https://github.com/jaywhj/mkdocs-document-dates
6
6
  Author: Aaron Wang
7
7
  Author-email: aaronwqt@gmail.com
@@ -30,7 +30,7 @@ English | [简体中文](README_zh.md)
30
30
 
31
31
 
32
32
 
33
- A new generation MkDocs plugin for displaying exact meta-info of documents, such as **creation time, last update time, authors, email**, etc.
33
+ A new generation MkDocs plugin for displaying exact meta-info of documents, such as **creation time, last update time, authors, email**, etc
34
34
 
35
35
  ## Features
36
36
 
@@ -40,10 +40,16 @@ A new generation MkDocs plugin for displaying exact meta-info of documents, such
40
40
  - Flexible display position (top or bottom)
41
41
  - Elegant styling (fully customizable)
42
42
  - Supports Tooltip Hover Tips
43
- - Intelligent repositioning to always float optimally in view
43
+ - Intelligent dynamic positioning, always floating optimally in view
44
44
  - Supports automatic theme switching following Material's light/dark color scheme
45
45
  - Multi-language support, cross-platform support (Windows, macOS, Linux)
46
- - Ultimate build efficiency O(1), typically less than 0.2 seconds, regardless of whether the number of documents is 1,000 or 10,000
46
+ - **Ultimate build efficiency**: O(1), typically less than 0.2 seconds
47
+
48
+ | PK of Build Efficiency: | 100 md: | 1000 md: | Time Complexity: |
49
+ | --------------------------- | :-----: | :------: | :----------: |
50
+ | git-revision-date-localized | > 3 s | > 30 s | O(n) |
51
+ | document-dates | < 0.1 s | < 0.15 s | O(1) |
52
+
47
53
 
48
54
  ## Showcases
49
55
 
@@ -69,52 +75,78 @@ Or, personalize the configuration:
69
75
  ```yaml
70
76
  plugins:
71
77
  - document-dates:
72
- position: top # Display position: top (after title) bottom (end of document), default: bottom
78
+ position: top # Display position: top (after title) bottom (end of document)
73
79
  type: date # Date type: date datetime timeago, default: date
80
+ exclude: # List of excluded files
81
+ - temp.md # Exclude specific file
82
+ - drafts/* # Exclude all files in drafts folder, including subfolders
74
83
  locale: en # Localization: en zh zh_TW es fr de ar ja ko ru, default: en
75
84
  date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
76
85
  time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
77
- exclude: # List of excluded files
78
- - temp.md # Exclude specific file
79
- - private/* # Exclude all files in private folder, including subfolders
80
86
  show_author: true # Show author or not, default: true
81
87
  ```
82
88
 
83
89
  ## Specify time manually
84
90
 
85
- The plugin will automatically get the exact time of the document, will automatically cache the creation time, but of course, you can also specify it manually in `Front Matter`
86
-
87
- Priority order: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
88
-
89
- ```yaml
90
- ---
91
- created: 2023-01-01
92
- modified: 2025-02-23
93
- ---
94
-
95
- # Document Title
96
- ```
91
+ By default, the plugin will **automatically** get the exact time of the document, and will automatically cache the creation time, without manual intervention
97
92
 
93
+ - **Priority**: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
94
+ - If you want to customize it, you can specify it manually in Front Matter:
95
+ ```markdown
96
+ ---
97
+ created: 2023-01-01
98
+ modified: 2025-02-23
99
+ ---
100
+
101
+ ```
98
102
  - `created` can be replaced with: `created, date, creation`
99
103
  - `modified` can be replaced with: `modified, updated, last_modified, last_updated`
100
104
 
101
- ## Specify author manually
102
-
103
- The plugin will automatically get the author of the document, will parse the email and make a link, also you can specify it manually in `Front Matter`
105
+ ## Configure Author
104
106
 
105
- Priority order: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
107
+ By default, the plugin will **automatically** get the author of the document, and will automatically parse the email and then do the link, without manual intervention
106
108
 
107
- ```yaml
108
- ---
109
- author: any-name
110
- email: e-name@gmail.com
111
- ---
112
-
113
- # Document Title
114
- ```
109
+ - **Priority**: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
110
+ - If you want to customize it, you can configure an author in Front Matter with the field `name`:
111
+ ```markdown
112
+ ---
113
+ name: any-name
114
+ email: e-name@gmail.com
115
+ ---
116
+
117
+ ```
115
118
 
116
- - `author` can be replaced with: `author, name`
117
- - `email` can be replaced with: `email, mail`
119
+ ## Configure Avatar
120
+
121
+ By default, the plugin will **automatically** loads the author avatar, without manual intervention
122
+
123
+ **Priority**: `Custom Avatar` > `GitHub Avatar` > `Character Avatar`
124
+
125
+ 1. Character avatar: will be automatically generated based on the author's name with the following rules
126
+ - Extract initials: English takes the combination of initials, other languages take the first character
127
+ - Dynamic background color: Generate HSL color based on the hash of the name
128
+ 2. GitHub avatar: will be automatically loaded by parsing the `repo_url` property in mkdocs.yml
129
+ 3. Custom avatar: can be customized by customizing the author's `avatar` field in Front Matter
130
+ ```markdown
131
+ ---
132
+ # Way 1: Configure a full author
133
+ author:
134
+ name: jay
135
+ email: jay@qq.com
136
+ avatar: https://xxx.author-avatar-URL.com/xxx.png
137
+ url: https://xxx.website-URL.com/xxx
138
+ description: author description
139
+
140
+ # Way 2: Configure multiple authors
141
+ authors:
142
+ - jaywhj
143
+ - squidfunk
144
+ - sunny
145
+
146
+ ---
147
+ ```
148
+ - If you want to configure complete information for multiple authors, you can create a separate configuration file `.authors.yml` in the `docs/` or `docs/blog/` directory, see the [.authors.yml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/.authors.yml) for its format
149
+ - If the URL avatar fails to load, it falls back to the character avatar
118
150
 
119
151
  ## Customization
120
152
 
@@ -136,16 +168,7 @@ The plugin supports deep customization, such as **icon style, theme color, font,
136
168
  - assets/document_dates/core/timeago-load.js
137
169
  ```
138
170
 
139
- **Demo Images**:
140
-
141
- ![01-default-w](mkdocs_document_dates/demo_images/01-default-w.png)
142
- ![02-change-icon](mkdocs_document_dates/demo_images/02-change-icon.png)
143
- ![02-change-icon-color](mkdocs_document_dates/demo_images/02-change-icon-color.png)
144
- ![04-default-pop-up](mkdocs_document_dates/demo_images/04-default-pop-up.png)
145
- ![05-change-theme](mkdocs_document_dates/demo_images/05-change-theme.png)
146
-
147
- ![06-change-theme](mkdocs_document_dates/demo_images/06-change-theme.png)
148
- ![08-pop-up-from-bottom](mkdocs_document_dates/demo_images/08-pop-up-from-bottom.png)
171
+ ![customization](customization.gif)
149
172
 
150
173
  ## Template Variables
151
174
 
@@ -154,24 +177,13 @@ You can access the meta-info of a document in a template using the following var
154
177
  - page.meta.document_dates_created
155
178
  - page.meta.document_dates_modified
156
179
  - page.meta.document_dates_authors
180
+ - page.meta.document_dates_locale
181
+ - page.meta.document_dates_translation
157
182
 
158
- For example like this:
159
-
160
- ```jinja2
161
- <div><span>{{ page.meta.document_dates_created }}</span></div>
162
- <div><span>{{ page.meta.document_dates_modified }}</span></div>
163
- {% set authors = page.meta.document_dates_authors %}
164
- {% if authors %}
165
- <div>
166
- {% for author in authors %}
167
- {% if author.email %}<a href="mailto:{{ author.email }}">{{ author.name }}</a>
168
- {% else %}<span>{{ author.name }}</span>{% endif %}
169
- {% endfor %}
170
- </div>
171
- {% endif %}
172
- ```
183
+ Usage examples:
173
184
 
174
- **Full example**: set the correct lastmod for [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/sitemap.xml) so that search engines can better handle SEO and thus increase your site's exposure (override path: `docs/overrides/sitemap.xml`)
185
+ - **Example 1**: Set the correct `lastmod` for your site's `sitemap.xml` so that search engines can better handle SEO and thus increase your site's exposure (download [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/sitemap.xml) and override this path: `docs/overrides/sitemap.xml`)
186
+ - **Example 2**: Using the template to re-customize the plugin, you have full control over the rendering logic and the plugin is only responsible for providing the data (download [source-file.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/source-file.html) and override this path: `docs/overrides/partials/source-file.html`)
175
187
 
176
188
  ## Other Tips
177
189
 
@@ -201,6 +213,8 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
201
213
  - Solution: I considered using a shell script, but since I'd have to call back to python eventually, it's easier to use a python script. We can detect the user's python environment when the hook is installed, and then dynamically set the hook's shebang line to set the correct python interpreter
202
214
  4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
203
215
  - Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
216
+ 5. How to reduce build time when there are a lot of documents ( >1000 )? Getting git information about a document is usually a file I/O operation, and if there are a lot of files, the efficiency of the operation will plummet. 1,000 documents can be expected to take more than 30 seconds, which is intolerable to the user
217
+ - Solution: Reduce the number of I/Os + Use caching + Replace less efficient system functions
204
218
  - **Improve**:
205
219
  - Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
206
220
  - **Ease of use**: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
@@ -4,7 +4,7 @@ English | [简体中文](README_zh.md)
4
4
 
5
5
 
6
6
 
7
- A new generation MkDocs plugin for displaying exact meta-info of documents, such as **creation time, last update time, authors, email**, etc.
7
+ A new generation MkDocs plugin for displaying exact meta-info of documents, such as **creation time, last update time, authors, email**, etc
8
8
 
9
9
  ## Features
10
10
 
@@ -14,10 +14,16 @@ A new generation MkDocs plugin for displaying exact meta-info of documents, such
14
14
  - Flexible display position (top or bottom)
15
15
  - Elegant styling (fully customizable)
16
16
  - Supports Tooltip Hover Tips
17
- - Intelligent repositioning to always float optimally in view
17
+ - Intelligent dynamic positioning, always floating optimally in view
18
18
  - Supports automatic theme switching following Material's light/dark color scheme
19
19
  - Multi-language support, cross-platform support (Windows, macOS, Linux)
20
- - Ultimate build efficiency O(1), typically less than 0.2 seconds, regardless of whether the number of documents is 1,000 or 10,000
20
+ - **Ultimate build efficiency**: O(1), typically less than 0.2 seconds
21
+
22
+ | PK of Build Efficiency: | 100 md: | 1000 md: | Time Complexity: |
23
+ | --------------------------- | :-----: | :------: | :----------: |
24
+ | git-revision-date-localized | > 3 s | > 30 s | O(n) |
25
+ | document-dates | < 0.1 s | < 0.15 s | O(1) |
26
+
21
27
 
22
28
  ## Showcases
23
29
 
@@ -43,52 +49,78 @@ Or, personalize the configuration:
43
49
  ```yaml
44
50
  plugins:
45
51
  - document-dates:
46
- position: top # Display position: top (after title) bottom (end of document), default: bottom
52
+ position: top # Display position: top (after title) bottom (end of document)
47
53
  type: date # Date type: date datetime timeago, default: date
54
+ exclude: # List of excluded files
55
+ - temp.md # Exclude specific file
56
+ - drafts/* # Exclude all files in drafts folder, including subfolders
48
57
  locale: en # Localization: en zh zh_TW es fr de ar ja ko ru, default: en
49
58
  date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
50
59
  time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
51
- exclude: # List of excluded files
52
- - temp.md # Exclude specific file
53
- - private/* # Exclude all files in private folder, including subfolders
54
60
  show_author: true # Show author or not, default: true
55
61
  ```
56
62
 
57
63
  ## Specify time manually
58
64
 
59
- The plugin will automatically get the exact time of the document, will automatically cache the creation time, but of course, you can also specify it manually in `Front Matter`
60
-
61
- Priority order: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
62
-
63
- ```yaml
64
- ---
65
- created: 2023-01-01
66
- modified: 2025-02-23
67
- ---
68
-
69
- # Document Title
70
- ```
65
+ By default, the plugin will **automatically** get the exact time of the document, and will automatically cache the creation time, without manual intervention
71
66
 
67
+ - **Priority**: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
68
+ - If you want to customize it, you can specify it manually in Front Matter:
69
+ ```markdown
70
+ ---
71
+ created: 2023-01-01
72
+ modified: 2025-02-23
73
+ ---
74
+
75
+ ```
72
76
  - `created` can be replaced with: `created, date, creation`
73
77
  - `modified` can be replaced with: `modified, updated, last_modified, last_updated`
74
78
 
75
- ## Specify author manually
76
-
77
- The plugin will automatically get the author of the document, will parse the email and make a link, also you can specify it manually in `Front Matter`
79
+ ## Configure Author
78
80
 
79
- Priority order: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
81
+ By default, the plugin will **automatically** get the author of the document, and will automatically parse the email and then do the link, without manual intervention
80
82
 
81
- ```yaml
82
- ---
83
- author: any-name
84
- email: e-name@gmail.com
85
- ---
86
-
87
- # Document Title
88
- ```
83
+ - **Priority**: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
84
+ - If you want to customize it, you can configure an author in Front Matter with the field `name`:
85
+ ```markdown
86
+ ---
87
+ name: any-name
88
+ email: e-name@gmail.com
89
+ ---
90
+
91
+ ```
89
92
 
90
- - `author` can be replaced with: `author, name`
91
- - `email` can be replaced with: `email, mail`
93
+ ## Configure Avatar
94
+
95
+ By default, the plugin will **automatically** loads the author avatar, without manual intervention
96
+
97
+ **Priority**: `Custom Avatar` > `GitHub Avatar` > `Character Avatar`
98
+
99
+ 1. Character avatar: will be automatically generated based on the author's name with the following rules
100
+ - Extract initials: English takes the combination of initials, other languages take the first character
101
+ - Dynamic background color: Generate HSL color based on the hash of the name
102
+ 2. GitHub avatar: will be automatically loaded by parsing the `repo_url` property in mkdocs.yml
103
+ 3. Custom avatar: can be customized by customizing the author's `avatar` field in Front Matter
104
+ ```markdown
105
+ ---
106
+ # Way 1: Configure a full author
107
+ author:
108
+ name: jay
109
+ email: jay@qq.com
110
+ avatar: https://xxx.author-avatar-URL.com/xxx.png
111
+ url: https://xxx.website-URL.com/xxx
112
+ description: author description
113
+
114
+ # Way 2: Configure multiple authors
115
+ authors:
116
+ - jaywhj
117
+ - squidfunk
118
+ - sunny
119
+
120
+ ---
121
+ ```
122
+ - If you want to configure complete information for multiple authors, you can create a separate configuration file `.authors.yml` in the `docs/` or `docs/blog/` directory, see the [.authors.yml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/.authors.yml) for its format
123
+ - If the URL avatar fails to load, it falls back to the character avatar
92
124
 
93
125
  ## Customization
94
126
 
@@ -110,16 +142,7 @@ The plugin supports deep customization, such as **icon style, theme color, font,
110
142
  - assets/document_dates/core/timeago-load.js
111
143
  ```
112
144
 
113
- **Demo Images**:
114
-
115
- ![01-default-w](mkdocs_document_dates/demo_images/01-default-w.png)
116
- ![02-change-icon](mkdocs_document_dates/demo_images/02-change-icon.png)
117
- ![02-change-icon-color](mkdocs_document_dates/demo_images/02-change-icon-color.png)
118
- ![04-default-pop-up](mkdocs_document_dates/demo_images/04-default-pop-up.png)
119
- ![05-change-theme](mkdocs_document_dates/demo_images/05-change-theme.png)
120
-
121
- ![06-change-theme](mkdocs_document_dates/demo_images/06-change-theme.png)
122
- ![08-pop-up-from-bottom](mkdocs_document_dates/demo_images/08-pop-up-from-bottom.png)
145
+ ![customization](customization.gif)
123
146
 
124
147
  ## Template Variables
125
148
 
@@ -128,24 +151,13 @@ You can access the meta-info of a document in a template using the following var
128
151
  - page.meta.document_dates_created
129
152
  - page.meta.document_dates_modified
130
153
  - page.meta.document_dates_authors
154
+ - page.meta.document_dates_locale
155
+ - page.meta.document_dates_translation
131
156
 
132
- For example like this:
133
-
134
- ```jinja2
135
- <div><span>{{ page.meta.document_dates_created }}</span></div>
136
- <div><span>{{ page.meta.document_dates_modified }}</span></div>
137
- {% set authors = page.meta.document_dates_authors %}
138
- {% if authors %}
139
- <div>
140
- {% for author in authors %}
141
- {% if author.email %}<a href="mailto:{{ author.email }}">{{ author.name }}</a>
142
- {% else %}<span>{{ author.name }}</span>{% endif %}
143
- {% endfor %}
144
- </div>
145
- {% endif %}
146
- ```
157
+ Usage examples:
147
158
 
148
- **Full example**: set the correct lastmod for [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/sitemap.xml) so that search engines can better handle SEO and thus increase your site's exposure (override path: `docs/overrides/sitemap.xml`)
159
+ - **Example 1**: Set the correct `lastmod` for your site's `sitemap.xml` so that search engines can better handle SEO and thus increase your site's exposure (download [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/sitemap.xml) and override this path: `docs/overrides/sitemap.xml`)
160
+ - **Example 2**: Using the template to re-customize the plugin, you have full control over the rendering logic and the plugin is only responsible for providing the data (download [source-file.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/source-file.html) and override this path: `docs/overrides/partials/source-file.html`)
149
161
 
150
162
  ## Other Tips
151
163
 
@@ -175,6 +187,8 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
175
187
  - Solution: I considered using a shell script, but since I'd have to call back to python eventually, it's easier to use a python script. We can detect the user's python environment when the hook is installed, and then dynamically set the hook's shebang line to set the correct python interpreter
176
188
  4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
177
189
  - Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
190
+ 5. How to reduce build time when there are a lot of documents ( >1000 )? Getting git information about a document is usually a file I/O operation, and if there are a lot of files, the efficiency of the operation will plummet. 1,000 documents can be expected to take more than 30 seconds, which is intolerable to the user
191
+ - Solution: Reduce the number of I/Os + Use caching + Replace less efficient system functions
178
192
  - **Improve**:
179
193
  - Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
180
194
  - **Ease of use**: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
@@ -1,5 +1,6 @@
1
1
  import os
2
2
  import json
3
+ import yaml
3
4
  import shutil
4
5
  import logging
5
6
  from datetime import datetime
@@ -7,6 +8,7 @@ from pathlib import Path
7
8
  from mkdocs.plugins import BasePlugin
8
9
  from mkdocs.config import config_options
9
10
  from mkdocs.structure.pages import Page
11
+ from urllib.parse import urlparse
10
12
  from .utils import get_file_creation_time, load_git_cache, read_jsonl_cache
11
13
 
12
14
  logger = logging.getLogger("mkdocs.plugins.document_dates")
@@ -14,20 +16,20 @@ logger.setLevel(logging.WARNING) # DEBUG, INFO, WARNING, ERROR, CRITICAL
14
16
 
15
17
 
16
18
  class Author:
17
- def __init__(self, name="", email="", **kwargs):
19
+ def __init__(self, name="", email="", avatar="", url="", desc=""):
18
20
  self.name = name
19
21
  self.email = email
20
- # 扩展属性
21
- self.attributes = kwargs
22
-
23
- def __getattr__(self, name):
24
- return self.attributes.get(name)
22
+ self.avatar = avatar
23
+ self.url = url
24
+ self.desc = desc
25
25
 
26
26
  def to_dict(self):
27
27
  return {
28
28
  'name': self.name,
29
29
  'email': self.email,
30
- **self.attributes
30
+ 'avatar': self.avatar,
31
+ 'url': self.url,
32
+ 'description': self.desc
31
33
  }
32
34
 
33
35
 
@@ -37,21 +39,19 @@ class DocumentDatesPlugin(BasePlugin):
37
39
  ('locale', config_options.Type(str, default=None)),
38
40
  ('date_format', config_options.Type(str, default='%Y-%m-%d')),
39
41
  ('time_format', config_options.Type(str, default='%H:%M:%S')),
40
- ('position', config_options.Type(str, default='bottom')),
42
+ ('position', config_options.Type(str, default='top')),
41
43
  ('exclude', config_options.Type(list, default=[])),
42
44
  ('created_field_names', config_options.Type(list, default=['created', 'date', 'creation'])),
43
45
  ('modified_field_names', config_options.Type(list, default=['modified', 'updated', 'last_modified', 'last_updated'])),
44
- ('show_author', config_options.Type(bool, default=True)),
45
- ('author_field_mapping', config_options.Type(dict, default={
46
- 'name': ['name', 'author'],
47
- 'email': ['email', 'mail']
48
- }))
46
+ ('show_author', config_options.Type(bool, default=True))
49
47
  )
50
48
 
51
49
  def __init__(self):
52
50
  super().__init__()
53
51
  self.translation = {}
54
52
  self.dates_cache = {}
53
+ self.authors_yml = {}
54
+ self.github_username = None
55
55
 
56
56
  def on_config(self, config):
57
57
  try:
@@ -63,6 +63,17 @@ class DocumentDatesPlugin(BasePlugin):
63
63
 
64
64
  docs_dir_path = Path(config['docs_dir'])
65
65
 
66
+ # 加载 author 配置
67
+ if self.config['show_author']:
68
+ self._extract_github_username(config.get('repo_url'))
69
+ try:
70
+ blog_config = config['plugins']['material/blog'].config
71
+ authors_file_resolved = blog_config.authors_file.format(blog=blog_config.blog_dir)
72
+ authors_file = docs_dir_path / authors_file_resolved
73
+ except Exception:
74
+ authors_file = docs_dir_path / '.authors.yml'
75
+ self._load_authors_from_yaml(authors_file)
76
+
66
77
  # 加载 json 语言文件
67
78
  self._load_translation(docs_dir_path)
68
79
 
@@ -149,6 +160,9 @@ class DocumentDatesPlugin(BasePlugin):
149
160
  'assets/document_dates/user.config.js'
150
161
  ])
151
162
 
163
+ if self.config['locale'] == 'zh':
164
+ self.config['locale'] = 'zh_CN'
165
+
152
166
  return config
153
167
 
154
168
  def on_page_markdown(self, markdown, page: Page, config, files):
@@ -175,6 +189,8 @@ class DocumentDatesPlugin(BasePlugin):
175
189
  page.meta['document_dates_created'] = created.isoformat()
176
190
  page.meta['document_dates_modified'] = modified.isoformat()
177
191
  page.meta['document_dates_authors'] = authors
192
+ page.meta['document_dates_locale'] = self.config['locale']
193
+ page.meta['document_dates_translation'] = self.translation
178
194
 
179
195
  # 检查是否需要排除
180
196
  if self._is_excluded(rel_path):
@@ -187,6 +203,35 @@ class DocumentDatesPlugin(BasePlugin):
187
203
  return self._insert_date_info(markdown, info_html)
188
204
 
189
205
 
206
+ def _extract_github_username(self, url):
207
+ try:
208
+ parsed = urlparse(url)
209
+ if parsed.netloc != 'github.com':
210
+ return
211
+ path_parts = [p for p in parsed.path.split('/') if p]
212
+ if path_parts:
213
+ self.github_username = path_parts[0]
214
+ except Exception as e:
215
+ logger.info(f"Error parsing URL: {e}")
216
+
217
+ def _load_authors_from_yaml(self, file_path: Path):
218
+ if not file_path.exists():
219
+ return
220
+ try:
221
+ with open(file_path, 'r', encoding='utf-8') as f:
222
+ data = yaml.safe_load(f)
223
+ for key, info in (data or {}).get('authors', {}).items():
224
+ author = Author(
225
+ name=info.get('name', ''),
226
+ email=info.get('email', ''),
227
+ avatar=info.get('avatar', ''),
228
+ url=info.get('url', ''),
229
+ desc=info.get('description', '')
230
+ )
231
+ self.authors_yml[key] = author
232
+ except Exception as e:
233
+ logger.info(f"Error parsing .authors.yml: {e}")
234
+
190
235
  def _load_translation(self, docs_dir_path: Path):
191
236
  # 内置语言文件目录
192
237
  builtin_dir = Path(__file__).parent / 'static' / 'languages'
@@ -271,34 +316,34 @@ class DocumentDatesPlugin(BasePlugin):
271
316
 
272
317
  def _process_meta_author(self, meta):
273
318
  try:
274
- # 1. 处理 author 对象,或 author 字符串
319
+ # 匹配 authors 数组
320
+ author_objs = []
321
+ authors_data = meta.get('authors')
322
+ for key in authors_data or []:
323
+ author = self.authors_yml.get(key)
324
+ if not author:
325
+ author = Author(name=str(key))
326
+ author_objs.append(author)
327
+ if author_objs:
328
+ return author_objs
329
+
330
+ # 匹配 author 对象,或 author 字符串
275
331
  author_data = meta.get('author')
276
332
  if author_data:
277
333
  if isinstance(author_data, dict):
278
- name = str(author_data.get('name', ''))
334
+ name = author_data.get('name')
279
335
  if not name:
280
336
  return None
281
- email = str(author_data.get('email', ''))
282
- # 提取扩展属性
283
- extra_attrs = {k: str(v) for k, v in author_data.items()
284
- if k not in ['name', 'email']}
285
- return [Author(name=name, email=email, **extra_attrs)]
337
+ email = author_data.get('email')
338
+ avatar = author_data.get('avatar')
339
+ url = author_data.get('url')
340
+ desc = author_data.get('description')
341
+ return [Author(name=name, email=email, avatar=avatar, url=url, desc=desc)]
286
342
  return [Author(name=str(author_data))]
287
-
288
- # 2. 处理独立字段,匹配 author_field_mapping 配置
289
- name = ''
290
- email = ''
291
-
292
- for name_field in self.config['author_field_mapping']['name']:
293
- if name_field in meta:
294
- name = str(meta[name_field])
295
- break
296
-
297
- for email_field in self.config['author_field_mapping']['email']:
298
- if email_field in meta:
299
- email = str(meta[email_field])
300
- break
301
-
343
+
344
+ # 匹配独立字段: name, email
345
+ name = meta.get('name')
346
+ email = meta.get('email')
302
347
  if name or email:
303
348
  if not name and email:
304
349
  name = email.partition('@')[0]
@@ -316,60 +361,62 @@ class DocumentDatesPlugin(BasePlugin):
316
361
  return date.strftime(self.config['date_format'])
317
362
 
318
363
  def _generate_html_info(self, created: datetime, modified: datetime, authors=None):
319
- html = ""
320
364
  try:
321
- locale = 'zh_CN' if self.config['locale'] == 'zh' else self.config['locale']
322
- position_class = 'document-dates-top' if self.config['position'] == 'top' else 'document-dates-bottom'
323
-
324
365
  # 构建基本的日期信息 HTML
325
- html += (
326
- f"<div class='document-dates-plugin-wrapper {position_class}'>"
327
- f"<div class='document-dates-plugin'>"
328
- f"<span data-tippy-content='{self.translation.get('created_time', 'Created')}: {created.strftime(self.config['date_format'])}'>"
329
- f"<span class='material-icons' data-icon='doc_created'></span>"
330
- f"<time datetime='{created.isoformat()}' locale='{locale}'>{self._get_formatted_date(created)}</time></span>"
331
- f"<span data-tippy-content='{self.translation.get('modified_time', 'Last Update')}: {modified.strftime(self.config['date_format'])}'>"
332
- f"<span class='material-icons' data-icon='doc_modified'></span>"
333
- f"<time datetime='{modified.isoformat()}' locale='{locale}'>{self._get_formatted_date(modified)}</time></span>"
334
- )
335
-
366
+ html_parts = []
367
+ position_class = 'document-dates-top' if self.config['position'] == 'top' else 'document-dates-bottom'
368
+ html_parts.append(f"<div class='document-dates-plugin-wrapper {position_class}'>")
369
+ html_parts.append(f"<div class='document-dates-plugin'>")
370
+
371
+ def build_time_icon(time_obj: datetime, icon: str, label_key: str, default_label:str):
372
+ formatted = time_obj.strftime(self.config['date_format'])
373
+ tooltip = f"{self.translation.get(label_key, default_label)}: {formatted}"
374
+ return (
375
+ f"<span data-tippy-content='{tooltip}'>"
376
+ f"<span class='material-icons' data-icon='{icon}'></span>"
377
+ f"<time datetime='{time_obj.isoformat()}' locale='{self.config['locale']}'>"
378
+ f"{self._get_formatted_date(time_obj)}</time></span>"
379
+ )
380
+
381
+ html_parts.append(build_time_icon(created, 'doc_created', 'created_time', 'Created'))
382
+ html_parts.append(build_time_icon(modified, 'doc_modified', 'modified_time', 'Last Update'))
383
+
336
384
  # 添加作者信息
337
385
  if self.config['show_author'] and authors:
338
- if len(authors) == 1:
339
- author, = authors
340
- if author.email:
341
- # 使用 HTML 实体编码避免 Tippy.js 转义问题
342
- author_tooltip = f'&lt;a href="mailto:{author.email}"&gt;{author.name}&lt;/a&gt;'
386
+ def get_author_tooltip(author):
387
+ if author.url:
388
+ return f'&lt;a href="{author.url}" target="_blank"&gt;{author.name}&lt;/a&gt;'
389
+ elif author.email:
390
+ return f'&lt;a href="mailto:{author.email}"&gt;{author.name}&lt;/a&gt;'
343
391
  else:
344
- author_tooltip = author.name
345
- html += (
346
- f"<span data-tippy-content='{self.translation.get('author', 'Author')}: {author_tooltip}'>"
347
- f"<span class='material-icons' data-icon='doc_author'></span>"
348
- f"{author.name}</span>"
349
- # f"{author_tooltip}</span>"
350
- )
351
- else:
352
- # 多个作者的情况
353
- authors_info = ', '.join(a.name for a in authors if a.name)
354
- authors_tooltip_parts = []
355
- for a in authors:
356
- if a.email:
357
- authors_tooltip_parts.append(f'&lt;a href="mailto:{a.email}"&gt;{a.name}&lt;/a&gt;')
358
- else:
359
- authors_tooltip_parts.append(a.name)
360
- authors_tooltip = ',&nbsp;'.join(authors_tooltip_parts)
361
- html += (
362
- f"<span data-tippy-content='{self.translation.get('authors', 'Authors')}: {authors_tooltip}'>"
363
- f"<span class='material-icons' data-icon='doc_authors'></span>"
364
- f"{authors_info}</span>"
365
- # f"{authors_tooltip}</span>"
392
+ return author.name
393
+
394
+ def get_avatar_img(author):
395
+ if author.avatar:
396
+ return f"<img class='avatar' src='{author.avatar}' />"
397
+ elif self.github_username and len(authors) == 1:
398
+ return f"<img class='avatar' src='https://avatars.githubusercontent.com/{self.github_username}' />"
399
+ return ""
400
+
401
+ icon = 'doc_author' if len(authors) == 1 else 'doc_authors'
402
+ html_parts.append(f"<span class='material-icons' data-icon='{icon}'></span>")
403
+ html_parts.append("<div class='avatar-group'>")
404
+ for author in authors:
405
+ tooltip = get_author_tooltip(author)
406
+ img_ele = get_avatar_img(author)
407
+ html_parts.append(
408
+ f"<div class='avatar-wrapper' data-name='{author.name}' data-tippy-content='{self.translation.get('author', 'Author')}: {tooltip}'>"
409
+ f"{img_ele}<span class='avatar-text'></span>"
410
+ f"</div>"
366
411
  )
367
-
368
- html += f"</div></div>"
369
-
412
+ html_parts.append("</div>")
413
+
414
+ html_parts.append("</div></div>")
415
+ return ''.join(html_parts)
416
+
370
417
  except Exception as e:
371
418
  logger.warning(f"Error generating HTML info: {e}")
372
- return html
419
+ return ""
373
420
 
374
421
 
375
422
  def _insert_date_info(self, markdown: str, date_info: str):
@@ -34,15 +34,22 @@
34
34
 
35
35
 
36
36
  /* 2. Plug-in wrapper styles
37
- including divider line, margin, padding, etc
38
- for example, remove the divider line like below:
37
+ including divider line, margin, padding, and the hiding of this plugin, etc
39
38
  */
39
+ /* Remove the divider line: */
40
40
  /*
41
- .md-main .document-dates-plugin-wrapper.document-dates-top,
42
- .md-main .document-dates-plugin-wrapper.document-dates-bottom {
41
+ .document-dates-plugin-wrapper.document-dates-top,
42
+ .document-dates-plugin-wrapper.document-dates-bottom {
43
43
  border-bottom: none;
44
44
  } */
45
45
 
46
+ /* Hide this plugin (default build version):
47
+ and then you can reformulate the plugin's arbitrary display position and style based on template variables */
48
+ /*
49
+ .document-dates-plugin-wrapper {
50
+ display: none;
51
+ } */
52
+
46
53
 
47
54
 
48
55
  /* 3. Tooltip styles
@@ -66,3 +73,17 @@
66
73
  .tippy-box[data-theme~='sublime'] > .tippy-arrow::before {
67
74
  color: #474747;
68
75
  } */
76
+
77
+
78
+
79
+ /* 4. Author Avatar styles
80
+ e.g. shape, hover scale, grayscale mode
81
+ */
82
+ /*
83
+ .avatar-wrapper {
84
+ border-radius: 4px;
85
+ filter: grayscale(0%);
86
+ }
87
+ .avatar-wrapper:hover {
88
+ transform: scale(1.08);
89
+ } */
@@ -18,7 +18,7 @@ DocumentDates.setConfig({
18
18
  },
19
19
  tooltip: {
20
20
  placement: 'bottom', // placement: top bottom left right auto
21
- offset: [0, 6], // placement offset: [horizontal, vertical]
21
+ offset: [0, 10], // placement offset: [horizontal, vertical]
22
22
  interactive: true, // content in Tooltip is interactive
23
23
  allowHTML: true, // whether to allow HTML in the tooltip content
24
24
 
@@ -5,22 +5,22 @@
5
5
  .document-dates-plugin {
6
6
  color: #666;
7
7
  font-size: 0.9rem;
8
- padding: 0.2rem 0;
9
8
  display: flex;
10
9
  align-items: center;
11
- margin-bottom: 0.3rem;
10
+ padding: 0.2rem 0;
11
+ margin-bottom: 0.6rem;
12
12
  }
13
13
  .md-main .document-dates-plugin {
14
14
  color: rgba(142, 142, 142, 0.7);
15
15
  font-size: 0.75rem;
16
16
  }
17
- .document-dates-plugin span:not(:first-child) {
18
- margin-left: 1.5rem;
19
- }
20
- .document-dates-plugin span {
17
+ .document-dates-plugin > span {
21
18
  display: inline-flex;
22
19
  align-items: center;
23
20
  }
21
+ .document-dates-plugin > span:not(:first-child) {
22
+ margin-left: 1.5rem;
23
+ }
24
24
  .document-dates-plugin .material-icons {
25
25
  font-size: 1rem;
26
26
  opacity: 0.85;
@@ -59,7 +59,6 @@
59
59
  .document-dates-plugin-wrapper.document-dates-top,
60
60
  .document-dates-plugin-wrapper.document-dates-bottom {
61
61
  margin: 1rem 0;
62
- padding-bottom: 0.3rem;
63
62
  border-bottom: 1px solid rgba(142, 142, 142, 0.15);
64
63
  }
65
64
  .md-main .document-dates-plugin-wrapper.document-dates-top {
@@ -104,3 +103,52 @@ Recommended Colors:
104
103
  -ms-transform: scale(0.75);
105
104
  transform: scale(0.75);
106
105
  }
106
+
107
+
108
+
109
+ /* 4. Author Avatar styles */
110
+ .avatar-group {
111
+ display: flex;
112
+ align-items: center;
113
+ flex-wrap: wrap;
114
+ margin: -0.15rem;
115
+ padding-left: 0.15rem;
116
+ }
117
+ .avatar-wrapper {
118
+ margin: 0.15rem;
119
+ position: relative;
120
+ width: 30px;
121
+ height: 30px;
122
+ border-radius: 50%;
123
+ overflow: hidden;
124
+ flex-shrink: 0;
125
+ opacity: 0.7;
126
+ filter: grayscale(90%);
127
+ transition: transform 0.2s ease, filter 0.2s ease;
128
+ }
129
+ .avatar-wrapper:hover {
130
+ transform: scale(1.08);
131
+ filter: grayscale(0%);
132
+ cursor: pointer;
133
+ }
134
+ .avatar-wrapper img.avatar {
135
+ position: absolute;
136
+ width: 100%;
137
+ height: 100%;
138
+ object-fit: cover;
139
+ z-index: 2;
140
+ }
141
+ .avatar-wrapper .avatar-text {
142
+ position: absolute;
143
+ width: 100%;
144
+ height: 100%;
145
+ color: #fff;
146
+ font-size: 13px;
147
+ font-weight: bold;
148
+ font-family: sans-serif;
149
+ display: flex;
150
+ align-items: center;
151
+ justify-content: center;
152
+ text-transform: capitalize;
153
+ z-index: 1;
154
+ }
@@ -6,7 +6,7 @@ const defaultConfig = {
6
6
  },
7
7
  tooltip: {
8
8
  placement: 'bottom', // placement: top bottom left right auto
9
- offset: [0, 10], // placement offset: [horizontal, vertical]
9
+ offset: [0, 12], // placement offset: [horizontal, vertical]
10
10
  interactive: true, // content in Tooltip is interactive
11
11
  allowHTML: true, // whether to allow HTML in the tooltip content
12
12
 
@@ -160,3 +160,51 @@ window.DocumentDates = {
160
160
  registerHook,
161
161
  setConfig
162
162
  };
163
+
164
+
165
+
166
+ /* Automatically generate avatars based on text */
167
+
168
+ function isLatin(name) {
169
+ return /^[A-Za-z\s]+$/.test(name.trim());
170
+ }
171
+ function extractInitials(name) {
172
+ name = name.trim();
173
+ if (!name) return '?';
174
+ if (isLatin(name)) {
175
+ const parts = name.toUpperCase().split(/\s+/).filter(Boolean);
176
+ return parts.length >= 2 ? parts[0][0] + parts[parts.length - 1][0] : parts[0][0];
177
+ } else {
178
+ return name[0];
179
+ }
180
+ }
181
+ function nameToHSL(name, s = 50, l = 55) {
182
+ let hash = 0;
183
+ for (let i = 0; i < name.length; i++) {
184
+ hash = name.charCodeAt(i) + ((hash << 5) - hash);
185
+ }
186
+ const hue = hash % 360;
187
+ return `hsl(${hue}, ${s}%, ${l}%)`;
188
+ }
189
+ function generateAvatar(){
190
+ document.querySelectorAll('.avatar-wrapper').forEach(wrapper => {
191
+ const name = wrapper.dataset.name || '';
192
+ const initials = extractInitials(name);
193
+ const bgColor = nameToHSL(name);
194
+
195
+ const textEl = wrapper.querySelector('.avatar-text');
196
+ textEl.textContent = initials;
197
+ textEl.style.backgroundColor = bgColor;
198
+
199
+ const imgEl = wrapper.querySelector('img.avatar');
200
+ if (!imgEl) return;
201
+ imgEl.onerror = () => {
202
+ imgEl.style.display = 'none';
203
+ };
204
+ });
205
+ }
206
+ if (typeof window.document$ !== 'undefined' && !window.document$.isStopped) {
207
+ window.document$.subscribe(generateAvatar);
208
+ } else {
209
+ generateAvatar();
210
+ }
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mkdocs-document-dates
3
- Version: 3.2.1
4
- Summary: A new generation MkDocs plugin for displaying exact meta-info of documents, such as creation time, last update time, authors, email, etc.
3
+ Version: 3.3
4
+ Summary: A new generation MkDocs plugin for displaying exact meta-info, such as creation time, last update time, authors, email, etc
5
5
  Home-page: https://github.com/jaywhj/mkdocs-document-dates
6
6
  Author: Aaron Wang
7
7
  Author-email: aaronwqt@gmail.com
@@ -30,7 +30,7 @@ English | [简体中文](README_zh.md)
30
30
 
31
31
 
32
32
 
33
- A new generation MkDocs plugin for displaying exact meta-info of documents, such as **creation time, last update time, authors, email**, etc.
33
+ A new generation MkDocs plugin for displaying exact meta-info of documents, such as **creation time, last update time, authors, email**, etc
34
34
 
35
35
  ## Features
36
36
 
@@ -40,10 +40,16 @@ A new generation MkDocs plugin for displaying exact meta-info of documents, such
40
40
  - Flexible display position (top or bottom)
41
41
  - Elegant styling (fully customizable)
42
42
  - Supports Tooltip Hover Tips
43
- - Intelligent repositioning to always float optimally in view
43
+ - Intelligent dynamic positioning, always floating optimally in view
44
44
  - Supports automatic theme switching following Material's light/dark color scheme
45
45
  - Multi-language support, cross-platform support (Windows, macOS, Linux)
46
- - Ultimate build efficiency O(1), typically less than 0.2 seconds, regardless of whether the number of documents is 1,000 or 10,000
46
+ - **Ultimate build efficiency**: O(1), typically less than 0.2 seconds
47
+
48
+ | PK of Build Efficiency: | 100 md: | 1000 md: | Time Complexity: |
49
+ | --------------------------- | :-----: | :------: | :----------: |
50
+ | git-revision-date-localized | > 3 s | > 30 s | O(n) |
51
+ | document-dates | < 0.1 s | < 0.15 s | O(1) |
52
+
47
53
 
48
54
  ## Showcases
49
55
 
@@ -69,52 +75,78 @@ Or, personalize the configuration:
69
75
  ```yaml
70
76
  plugins:
71
77
  - document-dates:
72
- position: top # Display position: top (after title) bottom (end of document), default: bottom
78
+ position: top # Display position: top (after title) bottom (end of document)
73
79
  type: date # Date type: date datetime timeago, default: date
80
+ exclude: # List of excluded files
81
+ - temp.md # Exclude specific file
82
+ - drafts/* # Exclude all files in drafts folder, including subfolders
74
83
  locale: en # Localization: en zh zh_TW es fr de ar ja ko ru, default: en
75
84
  date_format: '%Y-%m-%d' # Date format strings, e.g., %Y-%m-%d, %b %d, %Y, etc
76
85
  time_format: '%H:%M:%S' # Time format strings (valid only if type=datetime)
77
- exclude: # List of excluded files
78
- - temp.md # Exclude specific file
79
- - private/* # Exclude all files in private folder, including subfolders
80
86
  show_author: true # Show author or not, default: true
81
87
  ```
82
88
 
83
89
  ## Specify time manually
84
90
 
85
- The plugin will automatically get the exact time of the document, will automatically cache the creation time, but of course, you can also specify it manually in `Front Matter`
86
-
87
- Priority order: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
88
-
89
- ```yaml
90
- ---
91
- created: 2023-01-01
92
- modified: 2025-02-23
93
- ---
94
-
95
- # Document Title
96
- ```
91
+ By default, the plugin will **automatically** get the exact time of the document, and will automatically cache the creation time, without manual intervention
97
92
 
93
+ - **Priority**: `Front Matter` > `File System Timestamps(Cached)` > `Git Timestamps`
94
+ - If you want to customize it, you can specify it manually in Front Matter:
95
+ ```markdown
96
+ ---
97
+ created: 2023-01-01
98
+ modified: 2025-02-23
99
+ ---
100
+
101
+ ```
98
102
  - `created` can be replaced with: `created, date, creation`
99
103
  - `modified` can be replaced with: `modified, updated, last_modified, last_updated`
100
104
 
101
- ## Specify author manually
102
-
103
- The plugin will automatically get the author of the document, will parse the email and make a link, also you can specify it manually in `Front Matter`
105
+ ## Configure Author
104
106
 
105
- Priority order: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
107
+ By default, the plugin will **automatically** get the author of the document, and will automatically parse the email and then do the link, without manual intervention
106
108
 
107
- ```yaml
108
- ---
109
- author: any-name
110
- email: e-name@gmail.com
111
- ---
112
-
113
- # Document Title
114
- ```
109
+ - **Priority**: `Front Matter` > `Git Author` > `site_author(mkdocs.yml)` > `PC Username`
110
+ - If you want to customize it, you can configure an author in Front Matter with the field `name`:
111
+ ```markdown
112
+ ---
113
+ name: any-name
114
+ email: e-name@gmail.com
115
+ ---
116
+
117
+ ```
115
118
 
116
- - `author` can be replaced with: `author, name`
117
- - `email` can be replaced with: `email, mail`
119
+ ## Configure Avatar
120
+
121
+ By default, the plugin will **automatically** loads the author avatar, without manual intervention
122
+
123
+ **Priority**: `Custom Avatar` > `GitHub Avatar` > `Character Avatar`
124
+
125
+ 1. Character avatar: will be automatically generated based on the author's name with the following rules
126
+ - Extract initials: English takes the combination of initials, other languages take the first character
127
+ - Dynamic background color: Generate HSL color based on the hash of the name
128
+ 2. GitHub avatar: will be automatically loaded by parsing the `repo_url` property in mkdocs.yml
129
+ 3. Custom avatar: can be customized by customizing the author's `avatar` field in Front Matter
130
+ ```markdown
131
+ ---
132
+ # Way 1: Configure a full author
133
+ author:
134
+ name: jay
135
+ email: jay@qq.com
136
+ avatar: https://xxx.author-avatar-URL.com/xxx.png
137
+ url: https://xxx.website-URL.com/xxx
138
+ description: author description
139
+
140
+ # Way 2: Configure multiple authors
141
+ authors:
142
+ - jaywhj
143
+ - squidfunk
144
+ - sunny
145
+
146
+ ---
147
+ ```
148
+ - If you want to configure complete information for multiple authors, you can create a separate configuration file `.authors.yml` in the `docs/` or `docs/blog/` directory, see the [.authors.yml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/.authors.yml) for its format
149
+ - If the URL avatar fails to load, it falls back to the character avatar
118
150
 
119
151
  ## Customization
120
152
 
@@ -136,16 +168,7 @@ The plugin supports deep customization, such as **icon style, theme color, font,
136
168
  - assets/document_dates/core/timeago-load.js
137
169
  ```
138
170
 
139
- **Demo Images**:
140
-
141
- ![01-default-w](mkdocs_document_dates/demo_images/01-default-w.png)
142
- ![02-change-icon](mkdocs_document_dates/demo_images/02-change-icon.png)
143
- ![02-change-icon-color](mkdocs_document_dates/demo_images/02-change-icon-color.png)
144
- ![04-default-pop-up](mkdocs_document_dates/demo_images/04-default-pop-up.png)
145
- ![05-change-theme](mkdocs_document_dates/demo_images/05-change-theme.png)
146
-
147
- ![06-change-theme](mkdocs_document_dates/demo_images/06-change-theme.png)
148
- ![08-pop-up-from-bottom](mkdocs_document_dates/demo_images/08-pop-up-from-bottom.png)
171
+ ![customization](customization.gif)
149
172
 
150
173
  ## Template Variables
151
174
 
@@ -154,24 +177,13 @@ You can access the meta-info of a document in a template using the following var
154
177
  - page.meta.document_dates_created
155
178
  - page.meta.document_dates_modified
156
179
  - page.meta.document_dates_authors
180
+ - page.meta.document_dates_locale
181
+ - page.meta.document_dates_translation
157
182
 
158
- For example like this:
159
-
160
- ```jinja2
161
- <div><span>{{ page.meta.document_dates_created }}</span></div>
162
- <div><span>{{ page.meta.document_dates_modified }}</span></div>
163
- {% set authors = page.meta.document_dates_authors %}
164
- {% if authors %}
165
- <div>
166
- {% for author in authors %}
167
- {% if author.email %}<a href="mailto:{{ author.email }}">{{ author.name }}</a>
168
- {% else %}<span>{{ author.name }}</span>{% endif %}
169
- {% endfor %}
170
- </div>
171
- {% endif %}
172
- ```
183
+ Usage examples:
173
184
 
174
- **Full example**: set the correct lastmod for [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/sitemap.xml) so that search engines can better handle SEO and thus increase your site's exposure (override path: `docs/overrides/sitemap.xml`)
185
+ - **Example 1**: Set the correct `lastmod` for your site's `sitemap.xml` so that search engines can better handle SEO and thus increase your site's exposure (download [sitemap.xml](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/sitemap.xml) and override this path: `docs/overrides/sitemap.xml`)
186
+ - **Example 2**: Using the template to re-customize the plugin, you have full control over the rendering logic and the plugin is only responsible for providing the data (download [source-file.html](https://github.com/jaywhj/mkdocs-document-dates/blob/main/templates/overrides/partials/source-file.html) and override this path: `docs/overrides/partials/source-file.html`)
175
187
 
176
188
  ## Other Tips
177
189
 
@@ -201,6 +213,8 @@ A dispensable, insignificant little plug-in, friends who have time can take a lo
201
213
  - Solution: I considered using a shell script, but since I'd have to call back to python eventually, it's easier to use a python script. We can detect the user's python environment when the hook is installed, and then dynamically set the hook's shebang line to set the correct python interpreter
202
214
  4. How can I ensure that a single cache file does not conflict when collaborating with multi-person?
203
215
  - Workaround: use JSONL (JSON Lines) instead of JSON, and with the merge strategy 'merge=union'
216
+ 5. How to reduce build time when there are a lot of documents ( >1000 )? Getting git information about a document is usually a file I/O operation, and if there are a lot of files, the efficiency of the operation will plummet. 1,000 documents can be expected to take more than 30 seconds, which is intolerable to the user
217
+ - Solution: Reduce the number of I/Os + Use caching + Replace less efficient system functions
204
218
  - **Improve**:
205
219
  - Since it's a newly developed plugin, it will be designed in the direction of **excellent products**, and the pursuit of the ultimate **ease of use, simplicity and personalization**
206
220
  - **Ease of use**: don't let users do things manually if you can, e.g., auto-install Git Hooks, auto-cache, auto-commit, provide customized templates, etc
@@ -26,9 +26,9 @@ try:
26
26
  with open("README.md", "r", encoding="utf-8") as fh:
27
27
  long_description = fh.read()
28
28
  except FileNotFoundError:
29
- long_description = "A new generation MkDocs plugin for displaying exact meta-info of documents, such as creation time, last update time, authors, email, etc."
29
+ long_description = "A new generation MkDocs plugin for displaying exact meta-info, such as creation time, last update time, authors, email, etc"
30
30
 
31
- VERSION = '3.2.1'
31
+ VERSION = '3.3'
32
32
 
33
33
  setup(
34
34
  name="mkdocs-document-dates",
@@ -36,7 +36,7 @@ setup(
36
36
  author="Aaron Wang",
37
37
  author_email="aaronwqt@gmail.com",
38
38
  license="MIT",
39
- description="A new generation MkDocs plugin for displaying exact meta-info of documents, such as creation time, last update time, authors, email, etc.",
39
+ description="A new generation MkDocs plugin for displaying exact meta-info, such as creation time, last update time, authors, email, etc",
40
40
  long_description=long_description,
41
41
  long_description_content_type="text/markdown",
42
42
  url="https://github.com/jaywhj/mkdocs-document-dates",