feat(website): display version in header and load from page-agent package

This commit is contained in:
Simon
2026-01-14 17:42:18 +08:00
parent 7d45bf6598
commit 9a66d5205f
3 changed files with 12 additions and 0 deletions

View File

@@ -84,6 +84,9 @@ export default function Header() {
role="navigation"
aria-label={t('header.nav_docs')}
>
<span className="text-xs font-mono text-gray-400 dark:text-gray-500 tabular-nums">
v{import.meta.env.VERSION}
</span>
<Link
href="/docs/introduction/overview"
className="flex items-center gap-1.5 text-gray-600 dark:text-gray-300 hover:text-blue-600 dark:hover:text-blue-400 transition-colors duration-200"

View File

@@ -1,5 +1,9 @@
/// <reference types="vite/client" />
interface ImportMetaEnv {
readonly VERSION: string
}
declare module '*.module.css' {
const classes: Record<string, string>
export default classes

View File

@@ -1,12 +1,16 @@
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react-swc'
import { config as dotenvConfig } from 'dotenv'
import { readFileSync } from 'node:fs'
import process from 'node:process'
import { dirname, resolve } from 'path'
import { fileURLToPath } from 'url'
import { defineConfig } from 'vite'
const __dirname = dirname(fileURLToPath(import.meta.url))
const pageAgentPkg = JSON.parse(
readFileSync(resolve(__dirname, '../page-agent/package.json'), 'utf-8')
)
// Load .env from repo root
dotenvConfig({ path: resolve(__dirname, '../../.env') })
@@ -32,5 +36,6 @@ export default defineConfig({
'import.meta.env.LLM_MODEL_NAME': JSON.stringify(process.env.LLM_MODEL_NAME),
'import.meta.env.LLM_API_KEY': JSON.stringify(process.env.LLM_API_KEY),
'import.meta.env.LLM_BASE_URL': JSON.stringify(process.env.LLM_BASE_URL),
'import.meta.env.VERSION': JSON.stringify(pageAgentPkg.version),
},
})