-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(plugin): handle no git-timestamp on page meta #12
Conversation
Thank you for the pull request! Actually,
so it shouldn't raise a key error. Can you provide a demo project to reproduce this error? |
unfortunately i can't reproduce first error similar step i can get > poetry new p1
Created package p1 in p1
> cd p1
> poetry add mkdocs-blogging-plugin
Creating virtualenv p1-TJeFODVO-py3.10 in /home/r3r/.cache/pypoetry/virtualenvs
Using version ^1.2.0 for mkdocs-blogging-plugin
Updating dependencies
Resolving dependencies... (29.2s)
Writing lock file
Package operations: 28 installs, 0 updates, 0 removals
• Installing six (1.16.0)
• Installing markupsafe (2.0.1)
• Installing pyparsing (3.0.6)
• Installing python-dateutil (2.8.2)
• Installing pyyaml (6.0)
• Installing smmap (5.0.0)
• Installing zipp (3.7.0)
• Installing click (8.0.3)
• Installing ghp-import (2.0.2)
• Installing gitdb (4.0.9)
• Installing importlib-metadata (4.10.0)
• Installing jinja2 (3.0.3)
• Installing markdown (3.3.6)
• Installing mergedeep (1.3.4)
• Installing packaging (21.3)
• Installing pytz (2021.3)
• Installing pyyaml-env-tag (0.1)
• Installing watchdog (2.1.6)
• Installing attrs (21.4.0)
• Installing babel (2.9.1)
• Installing gitpython (3.1.24)
• Installing mkdocs (1.2.3)
• Installing more-itertools (8.12.0)
• Installing wcwidth (0.2.5)
• Installing py (1.11.0)
• Installing pluggy (0.13.1)
• Installing mkdocs-blogging-plugin (1.2.0)
• Installing pytest (5.4.3)
> poetry run mkdocs new .
> # edit mkdocs.yml
> mkdir docs/blog/2022/01/ mkdocs.yml site_name: My Docs
plugins:
- blogging:
dirs: # The directories to be included
- blog
features:
tags: {} actual package installed on project where this error occur
|
Can you upload a complete directory containing |
> poetry run mkdocs serve
INFO - Building documentation...
INFO - Cleaning site directory
ERROR - Error building page 'index.md': 'git-timestamp'
Traceback (most recent call last):
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/bin/mkdocs", line 8, in <module>
sys.exit(cli())
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/click/core.py", line 1053, in main
rv = self.invoke(ctx)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/click/core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs/__main__.py", line 177, in serve_command
serve.serve(dev_addr=dev_addr, livereload=livereload, **kwargs)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 54, in serve
config = builder()
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs/commands/serve.py", line 49, in builder
build(config, live_server=live_server, dirty=dirty)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs/commands/build.py", line 314, in build
_build_page(file.page, config, doc_files, nav, env, dirty)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs/commands/build.py", line 220, in _build_page
output = config['plugins'].run_event(
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs/plugins.py", line 102, in run_event
result = method(item, **kwargs)
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs_blogging_plugin/plugin.py", line 249, in on_post_page
sorted_entries = {tag: self.sorted_pages(
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs_blogging_plugin/plugin.py", line 249, in <dictcomp>
sorted_entries = {tag: self.sorted_pages(
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs_blogging_plugin/plugin.py", line 279, in sorted_pages
return sorted(pages,
File "/home/r3r/.cache/pypoetry/virtualenvs/p2-P7z4mDpE-py3.10/lib/python3.10/site-packages/mkdocs_blogging_plugin/plugin.py", line 280, in <lambda>
key=lambda page: page.meta["git-timestamp"], |
The issue is: there is a flaw in the original judgement for whether a page is within the blog directory specified in the configuration. This issue is fixed in a0d41ac. I will release a patch soon. |
You can check v1.2.1 for the fixes. As each page involved in the sorting has a valid timestamp, there is no longer a need for other sorting methods. Thank you for the pull request! |
Proposed changes
when i write drafted text and run
mkdocs serve
mkdocs will raise error that page.meta don't have 'git-timestamp'first it happened here
mkdocs-blogging-plugin/mkdocs_blogging_plugin/plugin.py
Line 221 in 47bff7e
(sorry forget the traceback for this one)
after af8b50a there is also error on other place for example
so i write function to replace lambda where page is sorted by git-timestamp
Types of changes
What types of changes does your code introduce?
Put an
x
in the boxes that applyChecklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
unrelated but there is also this warning when running pytest
i will create another pr for this later
this pr is based from this template https://github.com/appium/appium/blob/master/.github/PULL_REQUEST_TEMPLATE.md