-
-
Notifications
You must be signed in to change notification settings - Fork 12
feat: automatically generate post ids #33
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
Conversation
I think doing this has some potential edge cases. If we compute the module name from something that the user might change during the course of writing their post, their will then be two modules wthat write to the same location, and one is stale and might win out. one way to go about this is to save all the post modules in some kind of state or a cache, and before running the post extension again, purge those modules (think you would use Where do we hold that state? I'll leave that part to you 😎 |
Looking at most other SSGs, they kind of adopt a "rebuild the world" approach, where all pages are purged and rebuilt every time a generate is handled. While that does have a generation time cost, which can become prohibitive on larger sites, it also saves you having to deal with stored state and such like that. Since we'd, presumably, like to avoid the whole rebuild-the-universe, and adding a wholly separate cache via something like DETS seems a bit overkill, perhaps we namespace all posts (including those with custom ids) to a parent module, and then use As an aside, I'm not seeing any
Perhaps the edge case only occurs when using the real-time |
Yes, this was the case I was thinking of, I should have clarified. |
I think the path forward for this is to start an agent or some process to hold the page and post modules, and then when when we create the modules on the next request, we purge and delete them using the functions i stated above, clear that cache, and then move forward. and this is only for development, meaning And when you do |
I think I might have solved it, without needing any agent or other state keeper. Check out what I just pushed up. Autogenerated posts are namespaced into The caveats are: The generated HTML pages aren't pruned. If you have a permalink that uses the title, i.e. I only purge/delete posts with autogenerated IDs. If you specify A way around the not-purging of manually specified ids is to namespace all posts, and do the comparison there. |
Generates the post IDs from the title, if they are not specified by the frontmatter.
Generated IDs are the title, stripped of all non-alphanums, camelized, and prefixed with
Post.