gjtorikian / jekyll-last-modified-at

A Jekyll plugin to show the last_modified_at time of a post.
MIT License
241 stars 38 forks source link

Feature request: first-posted-at #90

Open redstreet opened 2 years ago

redstreet commented 2 years ago

First, thanks for this excellent plugin!

This is a feature request to add a "Originally created on" or page.first-posted-at, as a complement to page.last-modified-at.

I can see the git log -n 1 command that can be easily modified but don't know enough ruby to make all the modifications needed to expose a new function such as page.first-posted-at. I see @gjtorikian is looking for maintainers already. So if anyone is willing to give me some pointers on how to structure the modifications, I can take a go at it.

Thank you!

gjtorikian commented 2 years ago

If you can provide the Git command to get the info you're interested in, I can probably add the feature in.

redstreet commented 2 years ago

That would be terrific, thank you!

The git command is:

git log --diff-filter=A --follow --format=%aD -1 -- <fname>

For reference, from that page:

[The above command] gives the last "creation date" of a file in a repository, and does it regardless of file renames/moves.

Notes:

khemarato commented 2 years ago

How do you feel about it setting page.date instead of creating some new variable?

redstreet commented 2 years ago

Hmm, that would depend on what page.date is currently set to and used for @buddhist-uni. I'm not familiar enough to know this, would you mind telling me?

khemarato commented 2 years ago

In the attached draft, I've set page.date to the "first-posted-at" time, as you suggested.

The advantage of using page.date is that other plugins (such as jekyll-feed and jekyll-seo-tag) use page.date variable to determine when the page was first published.

redstreet commented 2 years ago

Thank you for this awesome PR, @buddhist-uni

On using page.date:

khemarato commented 2 years ago

Thanks for the comments on the PR. I've addressed them there.

To answer your question: I just tested this locally, and the plugin hooks up the field before Jekyll applies frontmatter values. The permalinks for posts, therefore, don't change and any dates you set in the frontmatter will override the value provided by the plugin. 😄

redstreet commented 2 years ago

Terrific, looks great then! Thank you again a bunch for this PR!