svelte-sitemap icon indicating copy to clipboard operation
svelte-sitemap copied to clipboard

[New Feature Request] Automatically set lastmod in sitemap

Open Glench opened this issue 2 years ago • 2 comments

It'd be great if this library could automatically fill in the <lastmod> time in the generated sitemap based on either the datetime the source route file was modified (probably won't work if you clone a fresh git repo since all files will have the same datetime?) or maybe the datetime the file was last modified in git or something.

Glench avatar Jan 27 '22 21:01 Glench

This is a little bit tricky, because the sitemap is generated on postbuild hook, so it is always based on newly generated static files. There would have to be some mapping to the original files...

And there are also dynamically generated routes [slug].svelte, from which date information cannot be taken.

Another thing is that the route itself often consists of a child component. So there would have to be complex traversal to other files as well.

In summary, I would say that this solution will never be completely reliable and is not worth the effort 🤨 Let's keep it simple 😄

Or do you have a better idea? I'd love to hear it.

bartholomej avatar Jan 28 '22 11:01 bartholomej

Yeah, that all makes sense. And yeah, too complicated. Thanks for considering it.

What about my other idea of introspecting git information? Git already has a diffing mechanism for static files so you could perhaps get the last time each build/**.html file was modified in git and put that in the sitemap? Maybe a --use-git-lastmod option?

It would be a little unfortunate that this feature would only work with projects that are stored in Git, but for me it would be better than manually updating the <lastmod> fields every time.

Glench avatar Jan 28 '22 14:01 Glench