-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
BlogPlugin: handling of generated blog posts #7583
base: master
Are you sure you want to change the base?
Conversation
Thanks! Great work! I'm currently tight on time, but I'll try to get back to this |
afe00a2
to
fe49397
Compare
a minimum code generating blog post. Should fail without my changes and work with them POST_CONTENT="""---
date:
created: {date}
tags:
- generated
title: Generated Blog Post
categories:
- test
---
This post is generated
"""
class BlogPostGeneratingPlugin(BasePlugin):
def on_files(self, files: Files, /, *, config: MkDocsConfig) -> Files | None:
file = File.generated(config=config, src_uri="blog/posts/generated.md", content=POST_CONTENT.format(date=datetime.now()))
files.append(file)
return files Same as ready to launch folder with post generating hook And to illustrate the issue PR solves here is the exception mkdocs throws without my changes
|
@squidfunk is there a chance for this PR to be accepted? I have a hack to workaround the issue in my project and either need to invest time to cover it with tests and improve code if it is permanent or just wait till it is fixed in mkdocs-material and remove... |
Thanks again for your time investment and efforts here. We currently have a feature freeze due to the foundational work that's happening right now. Since this PR improves deeper customizations and integrations rather than common use cases, we're not considering it for merge in the light of our current efforts. I'm sorry for any inconveniences caused. We'll come back to it after the next announcement. |
No worries. It is important to keep focus. |
As it has been discussed in #7545 I've modified
blog
plugin code to handle generated posts.Now if file
Post
instance is being created from generated content, it reads content withfile.string_content
property (Implementation from master branch used to crash in this case since tried to load non existing file from file system).Error messages are also changed to reference path and plugin that has generated the file.
For case where file is loaded form filesystem the behavior and messages are kept as is to ensure backward compatibility.