Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display last updated date #1337

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions _config.ts
Original file line number Diff line number Diff line change
@@ -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();

9 changes: 9 additions & 0 deletions _includes/doc.tsx
Original file line number Diff line number Diff line change
@@ -19,6 +19,10 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) {
throw new Error("Missing sidebar for " + props.url);
}

function displayDate(date: Date): string {
return date.toISOString().slice(0, 10);
}

function walk(
sidebarItems: SidebarItem[],
): [SidebarItem[], number] | undefined {
@@ -153,6 +157,11 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) {
}}
>
</h1>

<div class="text-sm mt-0 mb-8 text-foreground-secondary">
Last updated: {displayDate(props.date)}
</div>

{props.available_since && (
<div class="bg-gray-200 rounded-md text-sm py-3 px-4 mb-4 font-semibold">
Available since {props.available_since}
3 changes: 2 additions & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -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",