From 4a2640e0b42e86ae6d815dfc7273ad696b57edff Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sat, 5 Apr 2025 10:40:27 +0200 Subject: [PATCH] Pull the latest tag from git, on build, and display it top-right on the About page. --- src/routes/about/+page.svelte | 10 ++++++++-- vite.config.ts | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index 9e4ee80..00a14c8 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -1,10 +1,16 @@
- About +
+ About + Version: {gitTagVersion} +

Alexandria is a reader and writer for curated publications (in Asciidoc), and will eventually also support long-form articles (Markdown) and wiki pages (Asciidoc). It is produced by the GitCitadel project team.

Please submit support issues on the project repo page and follow us on GitHub and Geyserfund.

@@ -53,4 +59,4 @@

Documentation

-
\ No newline at end of file + diff --git a/vite.config.ts b/vite.config.ts index b9ba52c..7a6e207 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,9 +1,26 @@ import { sveltekit } from "@sveltejs/kit/vite"; import { defineConfig } from "vite"; +import { execSync } from "child_process"; + +// Function to get the latest git tag +function getLatestGitTag() { + try { + // Get the latest git tag + const tag = execSync('git describe --tags --abbrev=0').toString().trim(); + return tag; + } catch (error) { + console.error("Failed to get git tag:", error); + return "unknown"; + } +} export default defineConfig({ plugins: [sveltekit()], test: { include: ['./tests/unit/**/*.unit-test.js'] + }, + define: { + // Expose the git tag as a global variable + 'import.meta.env.GIT_TAG': JSON.stringify(getLatestGitTag()) } });