forked from carbon-design-system/gatsby-theme-carbon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: date in frontmatter resolves last modifed date on page (carbon-…
…design-system#1094) * feat: date in frontmatter resolves last modifed date on page * fix: removed zombie * fix: updated the example * fix: added toLocalDateString logic * fix: updated language in the docs * fix: new component name
- Loading branch information
1 parent
05641ae
commit 17947ce
Showing
8 changed files
with
53 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
packages/gatsby-theme-carbon/src/components/LastModifiedDate/LastModifiedDate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { Row, Column } from '../Grid'; | ||
import styles from './last-modified-date.module.scss'; | ||
|
||
const LastModifiedDate = ({ date }) => { | ||
const options = { | ||
day: '2-digit', | ||
year: 'numeric', | ||
month: 'long', | ||
}; | ||
|
||
const lastModified = new Date(date); | ||
|
||
return date ? ( | ||
<Row className={styles.row}> | ||
<Column> | ||
<div className={styles.text}> | ||
Page last updated: {lastModified.toLocaleDateString('en-GB', options)} | ||
{/* // https://www-03preprod.ibm.com/support/knowledgecenter/ibm_style/dates-and-times.html */} | ||
</div> | ||
</Column> | ||
</Row> | ||
) : null; | ||
}; | ||
export default LastModifiedDate; |
3 changes: 3 additions & 0 deletions
3
packages/gatsby-theme-carbon/src/components/LastModifiedDate/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import LastModifiedDate from './LastModifiedDate'; | ||
|
||
export default LastModifiedDate; |
8 changes: 8 additions & 0 deletions
8
packages/gatsby-theme-carbon/src/components/LastModifiedDate/last-modified-date.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.text { | ||
@include carbon--type-style('body-short-01'); | ||
} | ||
|
||
.row { | ||
position: relative; | ||
top: 5rem; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters