Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Feature request: first-posted-at #90

Open
redstreet opened this issue Oct 5, 2021 · 8 comments
Open

Feature request: first-posted-at #90

redstreet opened this issue Oct 5, 2021 · 8 comments

Comments

@redstreet
Copy link

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
Copy link
Owner

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

@redstreet
Copy link
Author

redstreet commented Oct 5, 2021

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:

  • I've tested this command with my own repos, and it does what I expect it to do.
  • Why last creation date (and not first)? This is relevant only in an uncommon, edge case scenario: we don't want the first creation date, because if a file is created, deleted, and then recreated, for most blog and article entries and such, we are interested in the date at which it was last recreated, which the above command does.

@khemarato
Copy link

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

@redstreet
Copy link
Author

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
Copy link

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
Copy link
Author

redstreet commented Nov 14, 2021

Thank you for this awesome PR, @buddhist-uni

On using page.date:

  • this page shows some downsides, the main one being the permalink to the page could be lost if page.date is a dynamic variable. This doesn't affect me, and I'm posting it merely for your consideration. An alternative idea is to set page.first-posted-at, and include a set-page-date-instead: true if the user optionally wanted it instead.

  • question for you: would it be possible to override what the plugin sets by setting page.date via frontmatter?

  • left a comment on the git command to use (given above)

@khemarato
Copy link

khemarato commented Nov 14, 2021

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
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants