Compare commits
No commits in common. "a06cea57837401536ef6e90ff7b10e90eeb61a2f" and "95e5a1618a55557ebf9bbaaa086d2351f78dbc71" have entirely different histories.
a06cea5783
...
95e5a1618a
3 changed files with 7 additions and 16 deletions
|
@ -1,23 +1,14 @@
|
||||||
---
|
---
|
||||||
import Callout from "./shortcodes/Callout.astro"
|
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 lastUpdated = new Date(lastUpdatedAt).getTime()
|
||||||
const dateNow = new Date().getTime()
|
const dateNow = new Date().getTime()
|
||||||
const dateDelta = dateNow - lastUpdated
|
const dateDelta = dateNow - lastUpdated
|
||||||
const Day = 1000 * 60 * 60 * 24
|
const Day = 1000 * 60 * 60 * 24
|
||||||
const daysDelta = Math.round(dateDelta / Day)
|
const daysDelta = Math.round(dateDelta / Day)
|
||||||
---
|
---
|
||||||
{ ( !noscript && daysDelta >= daysBeforeOutdated ) &&
|
{ daysDelta >= 30 &&
|
||||||
<Callout type="warning" icon="📅">
|
<Callout type="warning" icon="📅">
|
||||||
This article was updated {daysDelta} days ago. The content may be outdated.
|
This article was updated on {daysDelta} days ago. The content may be outdated.
|
||||||
</Callout>
|
</Callout>
|
||||||
}
|
|
||||||
{ ( noscript && daysDelta >= daysBeforeOutdated ) &&
|
|
||||||
<Callout type="warning" icon="📅">
|
|
||||||
This article was updated a long time ago. The content may be outdated.
|
|
||||||
</Callout>
|
|
||||||
}
|
}
|
|
@ -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,
|
// 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
|
// initialized by the server islands
|
||||||
outdatedCallout: {
|
outdatedCallout: {
|
||||||
enabled: true, // enable the outdated callout
|
enabled: true,
|
||||||
daysBeforeOutdated: 90, // the number of days before the content is considered outdated, defaults to 90 days
|
daysBeforeOutdated: 90, // the number of days before the content is considered outdated, defaults to 90 days
|
||||||
},
|
},
|
||||||
// encryption
|
// encryption
|
||||||
|
|
|
@ -74,7 +74,7 @@ const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `
|
||||||
{ (cover && cover !== firstImageURL && cover !== `/blog/${slug}/featured.png`) && <Image class="cover" width=720 height=480 src={cover} alt={`cover of ${entry.data.title}`} /> }
|
{ (cover && cover !== firstImageURL && cover !== `/blog/${slug}/featured.png`) && <Image class="cover" width=720 height=480 src={cover} alt={`cover of ${entry.data.title}`} /> }
|
||||||
{headings.length !== 0 && <TableOfContents headings={headings} />}
|
{headings.length !== 0 && <TableOfContents headings={headings} />}
|
||||||
{entry.data.summary && <p class="summary">{entry.data.summary}</p> }
|
{entry.data.summary && <p class="summary">{entry.data.summary}</p> }
|
||||||
{ siteConfig.outdatedCallout.enabled && (siteConfig.noClientJavaScript ? <OutDatedCallOut noscript=true lastUpdatedAt={lastUpdated} /> : <OutDatedCallOut server:defer lastUpdatedAt={lastUpdated} ><OutDatedCallOut noscript lastUpdatedAt={lastUpdated} slot="fallback" ></OutDatedCallOut></OutDatedCallOut>)}
|
<OutDatedCallOut server:defer lastUpdatedAt={lastUpdated} />
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<Content />
|
<Content />
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue