Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/vtbag/website. The @vtbag website. ⭐️ Please star to support this work! ⭐️
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869---import { spawnSync } from "child_process";import { basename, dirname } from "path";
let { lang, lastUpdated } = Astro.locals.starlightRoute;const published = (f: string) => spawnSync( "git", [ "log", "--format=%ct", "--follow", "--diff-filter=A", "--max-count=1", basename(f), ], { cwd: dirname(f), encoding: "utf-8", } ).stdout?.trim();
const updated = (f: string) => { const cmd = `git log --follow --format=%ct ${basename(f)} | head -n 1`; const res = spawnSync("bash", ["-c", cmd], { cwd: dirname(f), encoding: "utf-8", }).stdout?.trim(); return res;};const firstPublished = new Date( Number(published(Astro.locals.starlightRoute.entry.filePath) + "000"));// use starlights valuelastUpdated ||= new Date( Number(updated(Astro.locals.starlightRoute.entry.filePath) + "000"));
---
{ lastUpdated && ( <p style="display: flex; justify-content: space-between; font-size: 0.75rem"> <span style="view-transition-name: lastUpdated"> {"Last updated:"}{" "} <time datetime={lastUpdated.toISOString()}> {lastUpdated.toLocaleDateString(lang, { dateStyle: "medium", timeZone: "UTC", })} </time> </span> <span style="view-transition-name: firstPublished"> {"First published:"}{" "} <time datetime={firstPublished.toISOString()}> {firstPublished.toLocaleDateString(lang, { dateStyle: "medium", timeZone: "UTC", })} </time> </span> </p> )}<portal-gate to="end:head"> <meta property="og:updated_time" content={lastUpdated?.toISOString() ?? ""} /> <meta property="article:modified_time" content={lastUpdated?.toISOString() ?? ""} /> <meta property="article:published_time" content={firstPublished.toISOString()} /></portal-gate>