diff --git a/src/components/OutDatedCallOut.astro b/src/components/OutDatedCallOut.astro index ff09685..32a6743 100644 --- a/src/components/OutDatedCallOut.astro +++ b/src/components/OutDatedCallOut.astro @@ -1,14 +1,23 @@ --- import Callout from "./shortcodes/Callout.astro" -const { lastUpdatedAt } = Astro.props + +import { siteConfig } from "../config"; +const daysBeforeOutdated = siteConfig.outdatedCallout.daysBeforeOutdated || 90; + +const { lastUpdatedAt = '', noscript = false } = Astro.props const lastUpdated = new Date(lastUpdatedAt).getTime() const dateNow = new Date().getTime() const dateDelta = dateNow - lastUpdated const Day = 1000 * 60 * 60 * 24 const daysDelta = Math.round(dateDelta / Day) --- -{ daysDelta >= 30 && - - This article was updated on {daysDelta} days ago. The content may be outdated. - +{ ( !noscript && daysDelta >= daysBeforeOutdated ) && + + This article was updated {daysDelta} days ago. The content may be outdated. + +} +{ ( noscript && daysDelta >= daysBeforeOutdated ) && + + This article was updated a long time ago. The content may be outdated. + } \ No newline at end of file diff --git a/src/config.ts b/src/config.ts index d0fb3de..d419c72 100644 --- a/src/config.ts +++ b/src/config.ts @@ -41,7 +41,7 @@ export const siteConfig = { // enable the callout to notify users that the content maybe outdated, this will add a callout to the top of the article page, // initialized by the server islands outdatedCallout: { - enabled: true, + enabled: true, // enable the outdated callout daysBeforeOutdated: 90, // the number of days before the content is considered outdated, defaults to 90 days }, // encryption diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 5b9b4e0..4daf3e6 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -74,7 +74,7 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || ` { (cover && cover !== firstImageURL && cover !== `/blog/${slug}/featured.png`) && {`cover } {headings.length !== 0 && } {entry.data.summary &&

{entry.data.summary}

} - + { siteConfig.outdatedCallout.enabled && (siteConfig.noClientJavaScript ? : )}