From 65c5fdeae1a34d73ac213cdf9baaaf31643dea83 Mon Sep 17 00:00:00 2001 From: grassblock Date: Wed, 20 Aug 2025 17:29:09 +0800 Subject: [PATCH 1/3] chore: fix outdate reminder grammar --- src/components/OutDatedCallOut.astro | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/OutDatedCallOut.astro b/src/components/OutDatedCallOut.astro index ff09685..833525d 100644 --- a/src/components/OutDatedCallOut.astro +++ b/src/components/OutDatedCallOut.astro @@ -7,8 +7,8 @@ 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. - +{ ( lastUpdatedAt && daysDelta >= 30 ) && + + This article was updated {daysDelta} days ago. The content may be outdated. + } \ No newline at end of file From b3655b99b328df29002ff26f645c9515533c0061 Mon Sep 17 00:00:00 2001 From: grassblock Date: Wed, 20 Aug 2025 17:36:02 +0800 Subject: [PATCH 2/3] feat: allow to change days before marking an article as outdated --- src/components/OutDatedCallOut.astro | 13 +++++++++++-- src/config.ts | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/OutDatedCallOut.astro b/src/components/OutDatedCallOut.astro index 833525d..6fff5aa 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 = '' } = 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) --- -{ ( lastUpdatedAt && daysDelta >= 30 ) && +{ ( lastUpdatedAt && daysDelta >= daysBeforeOutdated ) && This article was updated {daysDelta} days ago. The content may be outdated. +} +{ (!lastUpdatedAt && 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 From a06cea57837401536ef6e90ff7b10e90eeb61a2f Mon Sep 17 00:00:00 2001 From: grassblock Date: Wed, 20 Aug 2025 18:06:09 +0800 Subject: [PATCH 3/3] feat: more noscript compatibility for outdated callout --- src/components/OutDatedCallOut.astro | 8 ++++---- src/pages/blog/[...slug].astro | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/OutDatedCallOut.astro b/src/components/OutDatedCallOut.astro index 6fff5aa..32a6743 100644 --- a/src/components/OutDatedCallOut.astro +++ b/src/components/OutDatedCallOut.astro @@ -1,22 +1,22 @@ --- import Callout from "./shortcodes/Callout.astro" -import { siteConfig} from "../config"; +import { siteConfig } from "../config"; const daysBeforeOutdated = siteConfig.outdatedCallout.daysBeforeOutdated || 90; -const { lastUpdatedAt = '' } = Astro.props +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) --- -{ ( lastUpdatedAt && daysDelta >= daysBeforeOutdated ) && +{ ( !noscript && daysDelta >= daysBeforeOutdated ) && This article was updated {daysDelta} days ago. The content may be outdated. } -{ (!lastUpdatedAt && daysDelta >= daysBeforeOutdated) && +{ ( noscript && daysDelta >= daysBeforeOutdated ) && This article was updated a long time ago. The content may be outdated. 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 ? : )}