diff options
| author | Leonardo Bishop <me@leonardobishop.com> | 2024-03-13 23:35:13 +0000 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.com> | 2024-03-13 23:35:13 +0000 |
| commit | 9ea8892c906ea8ee9a7644f9f126a1c2377e1c98 (patch) | |
| tree | 77e2c1e03069894a317a6cb054ed645504c624c9 /nuxt.config.ts | |
| parent | a51aefaeaa855f209ec608743a44a824fd2d75ed (diff) | |
Add git sha1 to footer
Diffstat (limited to 'nuxt.config.ts')
| -rw-r--r-- | nuxt.config.ts | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/nuxt.config.ts b/nuxt.config.ts index 819b910..db228a9 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,9 +1,11 @@ -// https://nuxt.com/docs/api/configuration/nuxt-config +import { execSync } from "child_process"; + export default defineNuxtConfig({ components: [ { path: '~/components', pathPrefix: true }, { path: '~/components/base', pathPrefix: false }, { path: '~/components/header', pathPrefix: false }, + { path: '~/components/footer', pathPrefix: false }, ], devtools: { enabled: true }, modules: [ @@ -21,4 +23,22 @@ export default defineNuxtConfig({ "@fortawesome/free-regular-svg-icons", ], }, + hooks: { + "build:before": () => { + const gitCommitHash = execSync('git rev-parse HEAD').toString().trim(); + const gitCommitHashShort = gitCommitHash.slice(0, 8); + const gitBranch = execSync('git rev-parse --abbrev-ref HEAD').toString().trim(); + + process.env.GIT_COMMIT_HASH = gitCommitHash; + process.env.GIT_COMMIT_HASH_SHORT = gitCommitHashShort; + process.env.GIT_BRANCH = gitBranch; + } + }, + runtimeConfig: { + public: { + gitCommitHash: process.env.GIT_COMMIT_HASH, + gitCommitHashShort: process.env.GIT_COMMIT_HASH_SHORT, + gitBranch: process.env.GIT_BRANCH + } + } }) |
