From f537390443b44fbbf9689fdf48cec2469c62cf38 Mon Sep 17 00:00:00 2001 From: Phil Hawksworth Date: Thu, 16 Jan 2025 15:04:05 +0000 Subject: [PATCH 1/4] begin convention for separating expensive tasks --- _config.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/_config.ts b/_config.ts index 23ef3a419..c5ff8bec3 100644 --- a/_config.ts +++ b/_config.ts @@ -184,6 +184,19 @@ site.scopedUpdates( (path) => path.startsWith("/api/deno/"), ); +// Do more expensive operations if we're building the full site +if (Deno.env.get("BUILD_TYPE") == "FULL") { + console.log("Including resource-heavy operations in the build"); + + // Use Lume's built in date function to get the last modified date of the file + // This will replace the default date exposed to the page layouts + site.data("date", "Git Last Modified"); + + // Generate Open Graph images + // TODO: Add custom OG iomage generation + // site.use(ogImages()); +} + const SKIP_CHECK_URLS = (Deno.env.get("SKIP_CHECK_URLS") || "false") .toLowerCase(); From 59683142caae940f2df7cf6ecba70d5dcaf434c2 Mon Sep 17 00:00:00 2001 From: Phil Hawksworth Date: Thu, 16 Jan 2025 15:04:29 +0000 Subject: [PATCH 2/4] add full build type --- deno.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deno.json b/deno.json index 99d6eeaf7..ebdc6752e 100644 --- a/deno.json +++ b/deno.json @@ -15,10 +15,11 @@ }, "tasks": { "serve": "deno run -A lume.ts -s", + "serve:full": "BUILD_TYPE=FULL deno run -A lume.ts -s", "serve:no_logs": "LUME_LOGS=WARN SKIP_CHECK_URLS=true deno run -A lume.ts -s", "start": "deno task serve", "dev": "deno task serve", - "build": "deno run -A lume.ts", + "build": "BUILD_TYPE=FULL deno run -A lume.ts", "debug": "deno task build && deno task prod", "prod": "cd _site && deno run --allow-read --allow-env --allow-net server.ts", "reference": "cd reference_gen && deno task types && deno task doc", From 2f9c831acfad469a9079182ecb0ffafe5bafd888 Mon Sep 17 00:00:00 2001 From: Phil Hawksworth Date: Thu, 16 Jan 2025 15:04:41 +0000 Subject: [PATCH 3/4] show modified date --- _includes/doc.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/_includes/doc.tsx b/_includes/doc.tsx index 736456c28..221f99e01 100644 --- a/_includes/doc.tsx +++ b/_includes/doc.tsx @@ -19,6 +19,14 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) { throw new Error("Missing sidebar for " + props.url); } + function displayDate(date: string) { + return new Date(date).toLocaleDateString("en-US", { + year: "numeric", + month: "short", + day: "numeric", + }); + } + function walk( sidebarItems: SidebarItem[], ): [SidebarItem[], number] | undefined { @@ -153,6 +161,11 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) { }} > + +
+ Last updated: {displayDate(props.date.toISOString())} +
+ {props.available_since && (
Available since {props.available_since} From 0607a1d19642e20d05b6c12a7c9464fe969dbdad Mon Sep 17 00:00:00 2001 From: Phil Hawksworth Date: Thu, 23 Jan 2025 13:10:42 +0000 Subject: [PATCH 4/4] revised modified date format --- _includes/doc.tsx | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/_includes/doc.tsx b/_includes/doc.tsx index 221f99e01..54bded777 100644 --- a/_includes/doc.tsx +++ b/_includes/doc.tsx @@ -19,12 +19,8 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) { throw new Error("Missing sidebar for " + props.url); } - function displayDate(date: string) { - return new Date(date).toLocaleDateString("en-US", { - year: "numeric", - month: "short", - day: "numeric", - }); + function displayDate(date: Date): string { + return date.toISOString().slice(0, 10); } function walk( @@ -163,7 +159,7 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) {
- Last updated: {displayDate(props.date.toISOString())} + Last updated: {displayDate(props.date)}
{props.available_since && (