update
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -8,6 +8,8 @@ on:
|
||||
|
||||
env:
|
||||
EDGEONE_PROJECT_NAME: cloud-blog
|
||||
GIT_DATE: ${{ github.event.head_commit.timestamp || github.event.pusher.date }}
|
||||
GIT_SHA: ${{ github.event.head_commit.id || github.sha }}
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!-- eslint-disable vue/no-v-text-v-html-on-component -->
|
||||
<template>
|
||||
<footer
|
||||
class="text-center mt-auto w-full flex flex-col gap-2 py-8 px-4 border-t border-white/10 dark:border-white/5">
|
||||
class="text-center mt-auto w-full flex flex-col gap-2 py-4 px-4 border-t border-white/10 dark:border-white/5">
|
||||
<!-- 一言 -->
|
||||
<p v-if="showHitokoto && quote" class="text-text-muted text-sm m-0 italic">
|
||||
「{{ quote }}」<span v-if="from" class="ml-1.5">—— {{ from }}</span>
|
||||
@@ -71,6 +71,12 @@
|
||||
|
||||
<!-- eslint-disable-next-line vue/no-v-html -->
|
||||
<div v-if="contact?.customHtml" v-html="contact.customHtml"></div>
|
||||
|
||||
<!-- Git build info -->
|
||||
<p v-if="build?.short" class="text-text-muted text-xs m-0">
|
||||
构建自提交:<span :title="build.sha">{{ build.short }}</span>
|
||||
<span v-if="build.date">· {{ build.date }}</span>
|
||||
</p>
|
||||
</footer>
|
||||
</template>
|
||||
|
||||
@@ -128,6 +134,10 @@ const isExternal = (url) => {
|
||||
return typeof url === "string" && /^https?:\/\//.test(url);
|
||||
};
|
||||
|
||||
// runtime build info injected from nuxt.config at build time
|
||||
const runtimeConfig = useRuntimeConfig();
|
||||
const build = runtimeConfig.public?.build || null;
|
||||
|
||||
onMounted(() => {
|
||||
if (showHitokoto) fetchHitokoto();
|
||||
});
|
||||
|
||||
@@ -92,7 +92,7 @@ const siteConfig: SiteConfig = {
|
||||
},
|
||||
|
||||
ad: {
|
||||
enable: true,
|
||||
enable: false,
|
||||
ads: [
|
||||
{
|
||||
body: '<p><span class="inline-flex items-center gap-2">本网站由 <img src="/ads/upyun.png" class="h-7 w-auto" alt="Upyun" /> 提供云存储服务</span></p>',
|
||||
|
||||
@@ -1,5 +1,41 @@
|
||||
import siteConfig from "./app/config";
|
||||
import tailwindcss from "@tailwindcss/vite";
|
||||
import { execSync } from "child_process";
|
||||
|
||||
// Compute git build info at build time. If git isn't available (e.g. in
|
||||
// certain CI environments), fields will be empty strings.
|
||||
const runGit = (cmd: string) => {
|
||||
try {
|
||||
return execSync(cmd, { encoding: "utf8" }).trim();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
const gitSha = runGit("git rev-parse HEAD");
|
||||
const gitShort = runGit("git rev-parse --short HEAD");
|
||||
const gitMessage = runGit("git log -1 --pretty=%B");
|
||||
const gitDate = runGit("git show -s --format=%ci HEAD");
|
||||
|
||||
// Prefer build info from environment variables (set by GitHub Actions
|
||||
// or custom CI). Supported vars (in priority order):
|
||||
// - BUILD_SHA, GITHUB_SHA
|
||||
// - BUILD_SHORT, (derived from SHA if missing)
|
||||
// - BUILD_MESSAGE
|
||||
// - BUILD_DATE
|
||||
// Falls back to git-derived values when env vars are not present.
|
||||
const envSha = process.env.BUILD_SHA || process.env.GITHUB_SHA || "";
|
||||
const envShort = process.env.BUILD_SHORT || (envSha ? envSha.slice(0, 7) : "") || gitShort || "";
|
||||
const envMessage = process.env.BUILD_MESSAGE || "";
|
||||
const envDate = process.env.BUILD_DATE || "";
|
||||
|
||||
const gitBuild = {
|
||||
sha: envSha || gitSha,
|
||||
short: envShort || gitShort,
|
||||
message: envMessage || gitMessage,
|
||||
date: envDate || gitDate,
|
||||
};
|
||||
|
||||
export default defineNuxtConfig({
|
||||
compatibilityDate: "2025-12-20",
|
||||
@@ -59,8 +95,8 @@ export default defineNuxtConfig({
|
||||
{ rel: "stylesheet", href: "/fonts/521/main/result.css" },
|
||||
],
|
||||
},
|
||||
pageTransition: { name: "page", mode: "out-in" },
|
||||
layoutTransition: { name: "layout", mode: "out-in" },
|
||||
pageTransition: { name: "page", mode: "in-out" },
|
||||
layoutTransition: { name: "layout", mode: "in-out" },
|
||||
},
|
||||
|
||||
robots: { groups: [{ userAgent: ["GPTBot", "ChatGPT-User"], disallow: ["/"] }] },
|
||||
@@ -94,11 +130,9 @@ export default defineNuxtConfig({
|
||||
},
|
||||
|
||||
runtimeConfig: {
|
||||
public: {},
|
||||
// Private server-only settings
|
||||
databaseUrl: process.env.DATABASE_URL || "",
|
||||
jwtSecret: process.env.JWT_SECRET || "",
|
||||
// legacy supabase service role no longer used
|
||||
public: {
|
||||
build: gitBuild,
|
||||
},
|
||||
},
|
||||
|
||||
postcss: {
|
||||
|
||||
Reference in New Issue
Block a user