Sfoglia il codice sorgente

feat: show git commit reference in documents footer

Hintay 2 anni fa
parent
commit
2831208de3

+ 1 - 1
.github/workflows/documents.yml

@@ -40,7 +40,7 @@ jobs:
                 working-directory: docs
 
             -   name: Build
-                run: yarn docs:build
+                run: COMMIT_REF=$(git rev-parse HEAD) yarn docs:build
                 working-directory: docs
 
             -   name: Archive artifacts

+ 3 - 0
docs/.vitepress/config/common.ts

@@ -0,0 +1,3 @@
+export const projectUrl: string = "https://github.com/0xJacky/nginx-ui"
+export const demoUrl: string = "https://demo.nginxui.com"
+export const editLinkPattern: string = projectUrl + '/edit/master/docs/:path'

+ 2 - 1
docs/.vitepress/config/en.ts

@@ -1,11 +1,12 @@
 import {LocaleSpecificConfig, DefaultTheme} from "vitepress"
+import {demoUrl} from './common'
 
 export const enConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
     themeConfig: {
         nav: [
             {text: 'Home', link: '/'},
             {text: 'Guide', link: '/guide/about'},
-            {text: 'Demo', link: 'https://demo.nginxui.com'}
+            {text: 'Demo', link: demoUrl}
         ],
 
         sidebar: {

+ 13 - 3
docs/.vitepress/config/shared.ts

@@ -1,4 +1,9 @@
 import { defineConfig } from 'vitepress'
+import {projectUrl, editLinkPattern} from './common'
+
+export const commitRef = process.env.COMMIT_REF ?
+    `<a href="${projectUrl}/commit/${process.env.COMMIT_REF}">` + process.env.COMMIT_REF.slice(0, 8) + '</a>':
+    'dev'
 
 function thisYear() {
     return new Date().getFullYear()
@@ -8,6 +13,11 @@ export const sharedConfig = defineConfig({
     title: 'Nginx UI',
     description: 'Yet another Nginx Web UI',
 
+    head: [
+        ['link', { rel: 'icon', type: 'image/svg+xml', href: '/assets/logo.svg' }],
+        ['meta', { name: 'theme-color', content: '#3682D8' }]
+    ],
+
     lastUpdated: true,
 
     themeConfig: {
@@ -18,16 +28,16 @@ export const sharedConfig = defineConfig({
         },
 
         editLink: {
-            pattern: 'https://github.com/0xJacky/nginx-ui/edit/master/docs/:path'
+            pattern: editLinkPattern
         },
 
         footer: {
-            message: 'Released under the AGPL-3.0 License.',
+            message: `Released under the AGPL-3.0 License. (${commitRef})`,
             copyright: 'Copyright © 2021-' + thisYear() + ' Nginx UI Team'
         },
 
         socialLinks: [
-            {icon: 'github', link: 'https://github.com/0xJacky/nginx-ui'}
+            {icon: 'github', link: projectUrl}
         ]
     }
 })

+ 3 - 2
docs/.vitepress/config/zh_CN.ts

@@ -1,16 +1,17 @@
 import {LocaleSpecificConfig, DefaultTheme} from "vitepress"
+import {demoUrl, editLinkPattern} from './common'
 
 export const zhCNConfig: LocaleSpecificConfig<DefaultTheme.Config> = {
     themeConfig: {
         nav: [
             {text: '首页', link: '/zh_CN/'},
             {text: '手册', link: '/zh_CN/guide/about'},
-            {text: '演示', link: 'https://demo.nginxui.com'}
+            {text: '演示', link: demoUrl}
         ],
 
         editLink: {
             text: '编辑此页',
-            pattern: 'https://github.com/0xJacky/nginx-ui/edit/master/docs/:path'
+            pattern: editLinkPattern
         },
 
         sidebar: {

+ 3 - 1
docs/package.json

@@ -10,6 +10,8 @@
         "vitepress": "^1.0.0-alpha.75"
     },
     "devDependencies": {
+        "@types/node": "^20.1.0",
         "less": "^4.1.3"
-    }
+    },
+    "license": "AGPL-3.0"
 }

+ 8 - 0
docs/yarn.lock

@@ -427,6 +427,13 @@ __metadata:
   languageName: node
   linkType: hard
 
+"@types/node@npm:^20.1.0":
+  version: 20.1.0
+  resolution: "@types/node@npm:20.1.0"
+  checksum: c6d9afa9aa78b4b4348c69ece94975be70346b144c278f1395694a10ef919d7db300018101b6f9245e6bdd76674a5327d2d14829092f3d5295e858cff5f22a66
+  languageName: node
+  linkType: hard
+
 "@types/web-bluetooth@npm:^0.0.17":
   version: 0.0.17
   resolution: "@types/web-bluetooth@npm:0.0.17"
@@ -1448,6 +1455,7 @@ __metadata:
   version: 0.0.0-use.local
   resolution: "nginx-ui-docs@workspace:."
   dependencies:
+    "@types/node": ^20.1.0
     less: ^4.1.3
     vitepress: ^1.0.0-alpha.75
   languageName: unknown