-
Notifications
You must be signed in to change notification settings - Fork 273
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
feat: date in frontmatter resolves last modifed date on page #1094
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/carbon-design-system/gatsby-theme-carbon/r15nsssmv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so clean and awesome, killer work. One small idea then one bigger idea
Is there a reason we're calling the component modified date?
&&
I think there's a good opportunity to introduce a little bit of opinion here so that the formatting doesn't get sloppy/out of sync between posts (and sites). If we create a new date object using their string const lastUpdated = new Date(frontmatterDateString)
then we can use toLocaleDateString to give them the appropriate formatting for their browsers locale:
lastUpdated.toLocaleDateString()
Maybe get with Jan to figure out which dateStyle
option would be best.
@vpicone I got with Jan and settled on the date formatting. All should be good there. I was curious on your thoughts on what the component should be called instead of |
@sstrubberg Ahhh that makes sense, I was thinking you meant like a modified version of |
<Row className={styles.row}> | ||
<Column> | ||
<div className={styles.text}> | ||
Page last updated: {lastModified.toLocaleDateString('en-GB', options)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Through the page frontmatter, Gatsby-Theme users can now enter a date that the page was last modified. This date will then be displayed at the bottom left corner of the page. If no date is specified, nothing will be generated at the bottom of the page.
I also cleaned up the publishing docs while I was in there.