Skip to content
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

Merged
merged 7 commits into from
Feb 10, 2021

Conversation

sstrubberg
Copy link
Member

@sstrubberg sstrubberg commented Jan 27, 2021

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.

image


I also cleaned up the publishing docs while I was in there.

@sstrubberg sstrubberg requested review from a team, vpicone and jnm2377 and removed request for a team January 27, 2021 16:47
@vercel
Copy link

vercel bot commented Jan 27, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/carbon-design-system/gatsby-theme-carbon/r15nsssmv
✅ Preview: https://gatsby-theme-carbon-git-fork-sstrubberg-date-manual.carbon-design-system.now.sh

Copy link
Contributor

@vpicone vpicone left a 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.

@sstrubberg
Copy link
Member Author

@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 <ModifiedDate>. When I call the function simply Date it conflicts with the existing Date function that I'm calling process the localeDateToString.

@vpicone
Copy link
Contributor

vpicone commented Feb 8, 2021

@sstrubberg Ahhh that makes sense, I was thinking you meant like a modified version of Date. Maybe LastModifiedDate? Either way I agree Date is bad, don't want to use existing keywords.

<Row className={styles.row}>
<Column>
<div className={styles.text}>
Page last updated: {lastModified.toLocaleDateString('en-GB', options)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Page last updated: {lastModified.toLocaleDateString('en-GB', options)}
Page last updated: {lastModified.toLocaleDateString(undefined, options)}

We don't want to force the English locale. By using undefined (no quotes), it will defer to the browser's setting.
Screen Shot 2021-02-08 at 10 37 52 AM

@sstrubberg sstrubberg merged commit 17947ce into carbon-design-system:main Feb 10, 2021
@sstrubberg sstrubberg deleted the date-manual branch February 10, 2021 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants