add datePublished fallback
This commit is contained in:
parent
a86f3a9967
commit
3f465e8693
@ -181,6 +181,7 @@ export const onCreateNode: GatsbyNode["onCreateNode"] = async function ({
|
|||||||
|
|
||||||
if (node.internal.type === "File" && node.sourceInstanceName === "gallery") {
|
if (node.internal.type === "File" && node.sourceInstanceName === "gallery") {
|
||||||
const { stdout: datePublished, stderr } = await exec(`git log --diff-filter=A --follow --format=%aI -1 -- ${node.absolutePath}`)
|
const { stdout: datePublished, stderr } = await exec(`git log --diff-filter=A --follow --format=%aI -1 -- ${node.absolutePath}`)
|
||||||
|
|
||||||
if (stderr.length) {
|
if (stderr.length) {
|
||||||
console.error('something went wrong checking publish date: ', stderr);
|
console.error('something went wrong checking publish date: ', stderr);
|
||||||
}
|
}
|
||||||
@ -213,7 +214,8 @@ export const onCreateNode: GatsbyNode["onCreateNode"] = async function ({
|
|||||||
vibrantData,
|
vibrantData,
|
||||||
node.absolutePath as string,
|
node.absolutePath as string,
|
||||||
dominant,
|
dominant,
|
||||||
datePublished
|
// if datePublished is empty, image has not been committed to git yet and is thus brand new
|
||||||
|
datePublished.length ? datePublished : (new Date()).toISOString(),
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user