badboy / mdbook-last-changed

https://badboy.github.io/mdbook-last-changed/
Mozilla Public License 2.0
13 stars 6 forks source link

Missing `Last changed: ` in README.md's #10

Open bartvanderwal opened 4 weeks ago

bartvanderwal commented 4 weeks ago

Great repo! This helped me achieve what I wanted too for a large part, without needing to build it myself.

I have three feature requests though of which the first one might be considered a bug report. And the main one.

  1. It works on most pages, but I am missing a Last change in README.md files, which mdbook automatically converts to index.html on building. See for instance in the mdbook codebase here. I suppose as a work-around I could rename all these files to index.md, but then they aren't shown in GitHub anymore by default. Could mdbook-lastchange retrieve the last change date in git of a README.md'a and use/insert that on the matching index.html?

TL; DR / Other suggestions

I might look at these other two suggestions myself. Perhaps should make another separate issue(s) for them.

Edit 9-11-2024: Suggestion 2 below was moved to issue #11 , and suggestion 3 was denied, might be a possible fork.

  1. The text Last changed: 2021-11-05 is fine as a default, but could it also be made configurable, so I can localize it for Dutch? For instance a second setting last-changed-text besides git-repository-url. Ideally also with a variable position of the date. So you could also change it to a more verbose "This page was last changed on 2024-22-12" to make explicit that the data is per page, and not per website. "Diese Seite wurde zuletzt am 2024-22-12 geändert"

  2. It would be great - and I think also pretty logical - if this plugin could also generate a sitemap.xml file of all the pages and use the determined dates as value for the lastmod property. The existing mdbook-generate-sitemap creates a sitemap, but is missing the lastmod valuea, but also seems to be a bit abandoned, or never really to have left the ground, as Google webmaster tools finds immediate errors. And the repo has this issue reported for it, but also an open pull request with a fix for it thas is open and unmerged for 10 months.

Here is an small example of a sitemap.xml

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
  <url>
    <loc>https://minordevops.nl</loc>
    <priority>1.0</priority>
    <lastmod>2021-11-05</lastmod>
  </url>
  <url>
    <loc>https://minordevops.nl/testing.html</loc>
    <priority>1.0</priority>
    <lastmod>2024-10-27</lastmod>
  </url>
<urlset>
badboy commented 3 weeks ago

The first issue should be easy to handle: when the filename is index.html (or index.md? whatever mdbook gives us...) look for README.md too (now what to do about all the different casings of that ...). A check somewhere here might be the way to do it: https://github.com/badboy/mdbook-last-changed/blob/4f5518a1bd8d06bf3ab79d9318ea7da5133cbf68/src/lib.rs#L94

Your last-changed-text request seems appropriate, but please split it out into a separate issue. The sitemap request: Nah, that's out of scope for this simple preprocessor. I don't want to maintain that. So if you need that feel free to fork and add the functionality yourself.