-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from GSA/mmeyer/last-update
Mmeyer/last update
- Loading branch information
Showing
15 changed files
with
83 additions
and
17 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"fullClone": true | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
--- | ||
const {last_modified} = Astro.props; | ||
import dayjs from "dayjs"; | ||
import utc from "dayjs/plugin/utc"; | ||
dayjs.extend(utc); | ||
const updateDate = dayjs(last_modified) | ||
.utc() | ||
.format("MMMM DD, YYYY"); | ||
--- | ||
<div class="last-reviewed grid-container " id="page-last-reviewed"> | ||
Last updated: {updateDate} | ||
</div> | ||
|
||
<style> | ||
.last-reviewed { | ||
font-size: .75rem; | ||
text-align: right; | ||
margin-bottom: .5em; | ||
} | ||
</style> |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* This looks at the last git commit of the markdown files to determine the | ||
* modification date. | ||
* | ||
* Alternatively users may override this date by adding a last_modified key to front-matter | ||
* with the date as a string. | ||
* | ||
* When running on cloud.gov pages, it is important to tell cloud.gov to clone | ||
* the full repo — the default is a shallow clone. | ||
* | ||
* This is specified in the root-level federalist.json file | ||
* See: https://cloud.gov/pages/documentation/federalist-json/ | ||
*/ | ||
import { execSync } from "child_process"; | ||
|
||
export function remarkModifiedTime() { | ||
return function (tree, file) { | ||
// allow content creators to override date in front-matter | ||
const manual_last_modified_date = file.data.astro.frontmatter.last_modified | ||
if (manual_last_modified_date) { | ||
file.data.astro.frontmatter.last_modified = manual_last_modified_date | ||
} | ||
else { | ||
const filepath = file.history[0]; | ||
const result = execSync(`git log -1 --pretty="format:%cI" "${filepath}"`); | ||
file.data.astro.frontmatter.last_modified = result.toString(); | ||
} | ||
}; | ||
} |