vuepress-theme-plume
Version:
A Blog&Document Theme for VuePress 2.0
1,279 lines (1,239 loc) • 108 kB
JavaScript
// src/node/theme.ts
import { sleep } from "@pengzhanbo/utils";
// src/node/autoFrontmatter/generator.ts
import { isArray, isEmptyObject as isEmptyObject2, promiseParallel, toArray } from "@pengzhanbo/utils";
import chokidar from "chokidar";
import { createFilter } from "create-filter";
import grayMatter from "gray-matter";
import jsonToYaml from "json2yaml";
import { colors as colors3, fs as fs6, hash as hash3, path as path8 } from "vuepress/utils";
// src/node/loadConfig/compiler.ts
import { promises as fsp } from "node:fs";
import path4 from "node:path";
import process2 from "node:process";
import { pathToFileURL } from "node:url";
import { build } from "esbuild";
import { importFileDefault } from "vuepress/utils";
// src/node/utils/constants.ts
var THEME_NAME = "vuepress-theme-plume";
// src/node/utils/createFsCache.ts
import fs from "node:fs/promises";
import path from "node:path";
import { hash } from "vuepress/utils";
var CACHE_BASE = "markdown";
function createFsCache(app, name) {
const filepath = app.dir.cache(`${CACHE_BASE}/${name}.json`);
const cache4 = { hash: "", data: null };
const read = async () => {
if (!cache4.data) {
try {
const content = await fs.readFile(filepath, "utf-8");
if (content) {
const res = JSON.parse(content);
cache4.data = res.data ?? null;
cache4.hash = hash(res.hash || "");
}
} catch {
}
}
return cache4.data;
};
let timer = null;
const write = async (data) => {
const currentHash = hash(data);
if (cache4.hash && currentHash === cache4.hash)
return;
cache4.data = data;
cache4.hash = currentHash;
timer && clearTimeout(timer);
timer = setTimeout(async () => {
await fs.mkdir(path.dirname(filepath), { recursive: true });
await fs.writeFile(filepath, JSON.stringify(cache4), "utf-8");
}, 300);
};
return {
get hash() {
return cache4.hash;
},
get data() {
return cache4.data;
},
read,
write
};
}
// src/node/utils/hash.ts
import { createHash } from "node:crypto";
import { customAlphabet } from "nanoid";
var hash2 = (content) => createHash("md5").update(content).digest("hex");
var nanoid = customAlphabet("0123456789abcdefghijklmnopqrstuvwxyz", 8);
// src/node/utils/interopDefault.ts
async function interopDefault(m) {
const resolved = await m;
return resolved.default || resolved;
}
// src/node/utils/logger.ts
import { Logger } from "@vuepress/helper";
import { colors } from "vuepress/utils";
var logger = new Logger(THEME_NAME);
var Perf = class {
isDebug = false;
collect = {};
init(isDebug = false) {
this.isDebug = isDebug;
}
mark(mark) {
this.collect[mark] = performance.now();
}
log(mark) {
const startTime = this.collect[mark];
if (!this.isDebug || !startTime)
return;
logger.info("[perf spent time] ", `${colors.green(mark)}: ${colors.cyan(`${(performance.now() - startTime).toFixed(2)}ms`)}`);
}
};
var perf = new Perf();
// src/node/utils/package.ts
import process from "node:process";
import { fs as fs2, path as path3 } from "vuepress/utils";
// src/node/utils/path.ts
import { ensureEndingSlash, ensureLeadingSlash, isLinkAbsolute, isLinkWithProtocol } from "@vuepress/helper";
import { getDirname, path as path2 } from "vuepress/utils";
var __dirname = getDirname(import.meta.url);
var resolve = (...args) => path2.resolve(__dirname, "../", ...args);
var templates = (url) => resolve("../templates", url);
var RE_SLASH = /(\\|\/)+/g;
function normalizePath(path10) {
return path10.replace(RE_SLASH, "/");
}
function pathJoin(...args) {
return normalizePath(path2.join(...args));
}
function normalizeLink(base, link = "") {
return isLinkAbsolute(link) || isLinkWithProtocol(link) ? link : ensureLeadingSlash(normalizePath(`${base}/${link}/`));
}
var RE_START_END_SLASH = /^\/|\/$/g;
function getCurrentDirname(basePath, filepath) {
const dirList = normalizePath(basePath || path2.dirname(filepath)).replace(RE_START_END_SLASH, "").split("/");
return dirList.length > 0 ? dirList[dirList.length - 1] : "";
}
function withBase(path10 = "", base = "/") {
path10 = ensureEndingSlash(ensureLeadingSlash(path10));
if (path10.startsWith(base))
return normalizePath(path10);
return normalizePath(`${base}${path10}`);
}
// src/node/utils/package.ts
function readJsonFileAsync(filePath) {
try {
const content = fs2.readFileSync(filePath, "utf-8");
return JSON.parse(content);
} catch {
}
return {};
}
function getPackage() {
return readJsonFileAsync(path3.join(process.cwd(), "package.json"));
}
function getThemePackage() {
return readJsonFileAsync(resolve("../package.json"));
}
// src/node/utils/resolveContent.ts
function resolveContent(app, { name, content, before, after }) {
content = `${before ? `${before}
` : ""}export const ${name} = ${JSON.stringify(content)}${after ? `
${after}` : ""}`;
if (app.env.isDev) {
const func = `update${name[0].toUpperCase()}${name.slice(1)}`;
content += `
if (import.meta.webpackHot) {
import.meta.webpackHot.accept()
if (__VUE_HMR_RUNTIME__.${func}) {
__VUE_HMR_RUNTIME__.${func}(${name})
}
}
if (import.meta.hot) {
import.meta.hot.accept(({ ${name} }) => {
__VUE_HMR_RUNTIME__.${func}(${name})
})
}
`;
}
return content;
}
// src/node/utils/translate.ts
import { isEmptyObject } from "@pengzhanbo/utils";
var lang = "en";
function setTranslateLang(current) {
if (["zh-CN", "zh", "zh-Hans", "zh-Hant"].includes(current)) {
lang = "zh";
} else {
lang = "en";
}
}
function createTranslate(locales) {
return function t5(key, data) {
const resolved = locales[lang][key];
if (!resolved)
return key;
if (data && !isEmptyObject(data)) {
return resolved.replace(/\{\{\s*(\w+)\s*\}\}/g, (_, key2) => data[key2] || _);
}
return resolved;
};
}
// src/node/utils/writeTemp.ts
var contentHash = /* @__PURE__ */ new Map();
async function writeTemp(app, filepath, content) {
const currentHash = hash2(content);
if (!contentHash.has(filepath) || contentHash.get(filepath) !== currentHash) {
contentHash.set(filepath, currentHash);
await app.writeTemp(filepath, content);
}
}
// src/node/loadConfig/compiler.ts
async function compiler(configPath) {
if (!configPath) {
return { config: {}, dependencies: [] };
}
const dirnameVarName = "__vite_injected_original_dirname";
const filenameVarName = "__vite_injected_original_filename";
const importMetaUrlVarName = "__vite_injected_original_import_meta_url";
const result = await build({
absWorkingDir: process2.cwd(),
entryPoints: [configPath],
outfile: "out.js",
write: false,
target: [`node${process2.versions.node}`],
platform: "node",
bundle: true,
format: "esm",
mainFields: ["main"],
sourcemap: "inline",
metafile: true,
define: {
"__dirname": dirnameVarName,
"__filename": filenameVarName,
"import.meta.url": importMetaUrlVarName,
"import.meta.dirname": dirnameVarName,
"import.meta.filename": filenameVarName
},
plugins: [
{
name: "externalize-deps",
setup(build2) {
build2.onResolve({ filter: /.*/ }, ({ path: id }) => {
if (id[0] !== "." && !path4.isAbsolute(id)) {
return { external: true };
}
return null;
});
}
},
{
name: "inject-file-scope-variables",
setup(build2) {
build2.onLoad({ filter: /\.[cm]?[jt]s$/ }, async (args) => {
const contents = await fsp.readFile(args.path, "utf-8");
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(
path4.dirname(args.path)
)};const ${filenameVarName} = ${JSON.stringify(args.path)};const ${importMetaUrlVarName} = ${JSON.stringify(
pathToFileURL(args.path).href
)};`;
return {
loader: args.path.endsWith("ts") ? "ts" : "js",
contents: injectValues + contents
};
});
}
}
]
});
const { text } = result.outputFiles[0];
const tempFilePath = `${configPath}.${hash2(text)}.mjs`;
let config;
try {
await fsp.writeFile(tempFilePath, text);
config = await importFileDefault(tempFilePath);
} finally {
await fsp.rm(tempFilePath);
}
return {
config,
dependencies: Object.keys(result.metafile?.inputs ?? {})
};
}
// src/node/loadConfig/findConfigPath.ts
import fs3, { constants, promises as fsp2 } from "node:fs";
import { resolve as resolve2 } from "node:path";
import process3 from "node:process";
import { colors as colors2 } from "vuepress/utils";
var CONFIG_FILE_NAME = "plume.config";
var extensions = ["ts", "js", "mjs", "cjs", "mts", "cts"];
async function findConfigPath(app, configPath) {
const cwd = process3.cwd();
const source = app.dir.source(".vuepress");
const paths = [];
if (configPath) {
const path10 = resolve2(cwd, configPath);
if (existsSync(path10) && (await fsp2.stat(path10)).isFile()) {
return path10;
}
}
extensions.forEach(
(ext) => paths.push(
resolve2(cwd, `${source}/${CONFIG_FILE_NAME}.${ext}`),
resolve2(cwd, `./${CONFIG_FILE_NAME}.${ext}`),
resolve2(cwd, `./.vuepress/${CONFIG_FILE_NAME}.${ext}`)
)
);
let current;
for (const path10 of paths) {
if (existsSync(path10) && (await fsp2.stat(path10)).isFile()) {
current = path10;
break;
}
}
if (configPath && current) {
logger.warn(`Can not find config file: ${colors2.gray(configPath)}
Use config file: ${colors2.gray(current)}`);
}
return current;
}
function existsSync(fp) {
try {
fs3.accessSync(fp, constants.R_OK);
return true;
} catch {
return false;
}
}
// src/node/loadConfig/loader.ts
import process4 from "node:process";
import { deepMerge } from "@pengzhanbo/utils";
import { watch } from "chokidar";
// src/node/config/initThemeOptions.ts
import { hasOwn, uniq } from "@pengzhanbo/utils";
import { entries, fromEntries, getFullLocaleConfig, isPlainObject } from "@vuepress/helper";
// src/node/locales/de.ts
var deLocale = {
selectLanguageName: "Deutsch",
selectLanguageText: "Sprache ausw\xE4hlen",
appearanceText: "Erscheinungsbild",
lightModeSwitchTitle: "Zu hellem Thema wechseln",
darkModeSwitchTitle: "Zu dunklem Thema wechseln",
outlineLabel: "Inhalt dieser Seite",
returnToTopLabel: "Zur\xFCck nach oben",
editLinkText: "Diese Seite bearbeiten",
contributorsText: "Mitwirkende",
prevPageLabel: "Vorherige Seite",
nextPageLabel: "N\xE4chste Seite",
lastUpdatedText: "Zuletzt aktualisiert am",
changelogText: "\xC4nderungsprotokoll",
changelogOnText: "am",
changelogButtonText: "Alle \xC4nderungen anzeigen",
copyrightText: "Alle Rechte vorbehalten",
copyrightAuthorText: "Urheberrecht liegt bei:",
copyrightCreationOriginalText: "Originalartikel:",
copyrightCreationTranslateText: "\xDCbersetzt aus:",
copyrightCreationReprintText: "Nachdruck von:",
copyrightLicenseText: "Lizenz:",
notFound: {
code: "404",
title: "Seite nicht gefunden",
quote: "Aber wenn du deine Richtung nicht \xE4nderst und weiter suchst, k\xF6nntest du schlie\xDFlich dorthin gelangen, wohin du gehen willst.",
linkText: "Zur Startseite"
},
homeText: "Startseite",
blogText: "Blog",
tagText: "Tag",
archiveText: "Archiv",
categoryText: "Kategorie",
archiveTotalText: "{count} Beitr\xE4ge",
encryptButtonText: "Best\xE4tigen",
encryptPlaceholder: "Bitte Passwort eingeben",
encryptGlobalText: "Diese Website ist nur mit Passwort zug\xE4nglich",
encryptPageText: "Diese Seite ist nur mit Passwort zug\xE4nglich",
footer: {
message: 'Unterst\xFCtzt von <a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a>'
}
};
var dePresetLocale = {
// ------ copyright license ------
"CC0": "CC0 1.0 Universell",
"CC-BY-4.0": "Namensnennung 4.0 International",
"CC-BY-NC-4.0": "Namensnennung-Nicht kommerziell 4.0 International",
"CC-BY-NC-SA-4.0": "Namensnennung-Nicht kommerziell-Weitergabe unter gleichen Bedingungen 4.0 International",
"CC-BY-NC-ND-4.0": "Namensnennung-Nicht kommerziell-Keine Bearbeitung 4.0 International",
"CC-BY-ND-4.0": "Namensnennung-Keine Bearbeitung 4.0 International",
"CC-BY-SA-4.0": "Namensnennung-Weitergabe unter gleichen Bedingungen 4.0 International"
};
// src/node/locales/en.ts
var enLocale = {
selectLanguageName: "English",
selectLanguageText: "Languages",
appearanceText: "Appearance",
lightModeSwitchTitle: "Switch to light theme",
darkModeSwitchTitle: "Switch to dark theme",
editLinkText: "Edit this page",
contributorsText: "Contributors",
lastUpdatedText: "Last Updated",
changelogText: "Changelog",
changelogOnText: "On",
changelogButtonText: "View All Changelog",
copyrightText: "Copyright",
copyrightAuthorText: "Copyright Ownership:",
copyrightCreationOriginalText: "This article link:",
copyrightCreationTranslateText: "This article is translated from:",
copyrightCreationReprintText: "This article is reprint from:",
copyrightLicenseText: "License under:",
encryptButtonText: "Confirm",
encryptPlaceholder: "Enter password",
encryptGlobalText: "Only password can access this site",
encryptPageText: "Only password can access this page",
homeText: "Home",
blogText: "Blog",
tagText: "Tags",
archiveText: "Archives",
categoryText: "Categories",
archiveTotalText: "{count} articles",
footer: {
message: 'Powered by <a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a>'
}
};
var enPresetLocale = {
// ------ copyright license ------
"CC0": "CC0 1.0 Universal",
"CC-BY-4.0": "Attribution 4.0 International",
"CC-BY-NC-4.0": "Attribution-NonCommercial 4.0 International",
"CC-BY-NC-SA-4.0": "Attribution-NonCommercial-ShareAlike 4.0 International",
"CC-BY-NC-ND-4.0": "Attribution-NonCommercial-NoDerivatives 4.0 International",
"CC-BY-ND-4.0": "Attribution-NoDerivatives 4.0 International",
"CC-BY-SA-4.0": "Attribution-ShareAlike 4.0 International"
};
// src/node/locales/fr.ts
var frLocale = {
selectLanguageName: "Fran\xE7ais",
selectLanguageText: "Choisir la langue",
appearanceText: "Apparence",
lightModeSwitchTitle: "Passer au th\xE8me clair",
darkModeSwitchTitle: "Passer au th\xE8me sombre",
outlineLabel: "Contenu de cette page",
returnToTopLabel: "Retour en haut",
editLinkText: "Modifier cette page",
contributorsText: "Contributeurs",
prevPageLabel: "Page pr\xE9c\xE9dente",
nextPageLabel: "Page suivante",
lastUpdatedText: "Derni\xE8re mise \xE0 jour",
changelogText: "Historique des changements",
changelogOnText: "le",
changelogButtonText: "Voir tout l'historique des changements",
copyrightText: "Tous droits r\xE9serv\xE9s",
copyrightAuthorText: "Copyright appartenant \xE0 :",
copyrightCreationOriginalText: "Lien de l'article :",
copyrightCreationTranslateText: "Traduit de :",
copyrightCreationReprintText: "Reproduit de :",
copyrightLicenseText: "Licence :",
notFound: {
code: "404",
title: "Page non trouv\xE9e",
quote: "Mais si tu ne changes pas de direction et que tu continues \xE0 chercher, tu finiras par arriver \xE0 destination.",
linkText: "Retour \xE0 l'accueil"
},
homeText: "Accueil",
blogText: "Blog",
tagText: "\xC9tiquette",
archiveText: "Archives",
categoryText: "Cat\xE9gorie",
archiveTotalText: "{count} articles",
encryptButtonText: "Confirmer",
encryptPlaceholder: "Veuillez entrer le mot de passe",
encryptGlobalText: "Ce site n'est accessible qu'avec un mot de passe",
encryptPageText: "Cette page n'est accessible qu'avec un mot de passe",
footer: {
message: 'Propuls\xE9 par <a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a>'
}
};
var frPresetLocale = {
// ------ copyright license ------
"CC0": "CC0 1.0 Universel",
"CC-BY-4.0": "Attribution 4.0 International",
"CC-BY-NC-4.0": "Attribution-Pas d'Utilisation Commerciale 4.0 International",
"CC-BY-NC-SA-4.0": "Attribution-Pas d'Utilisation Commerciale-Partage dans les M\xEAmes Conditions 4.0 International",
"CC-BY-NC-ND-4.0": "Attribution-Pas d'Utilisation Commerciale-Pas de Modification 4.0 International",
"CC-BY-ND-4.0": "Attribution-Pas de Modification 4.0 International",
"CC-BY-SA-4.0": "Attribution-Partage dans les M\xEAmes Conditions 4.0 International"
};
// src/node/locales/ja.ts
var jaLocale = {
selectLanguageName: "\u65E5\u672C\u8A9E",
selectLanguageText: "\u8A00\u8A9E\u3092\u9078\u629E",
appearanceText: "\u5916\u89B3",
lightModeSwitchTitle: "\u30E9\u30A4\u30C8\u30E2\u30FC\u30C9\u306B\u5207\u308A\u66FF\u3048",
darkModeSwitchTitle: "\u30C0\u30FC\u30AF\u30E2\u30FC\u30C9\u306B\u5207\u308A\u66FF\u3048",
outlineLabel: "\u3053\u306E\u30DA\u30FC\u30B8\u306E\u5185\u5BB9",
returnToTopLabel: "\u30C8\u30C3\u30D7\u306B\u623B\u308B",
editLinkText: "\u3053\u306E\u30DA\u30FC\u30B8\u3092\u7DE8\u96C6",
contributorsText: "\u8CA2\u732E\u8005",
prevPageLabel: "\u524D\u306E\u30DA\u30FC\u30B8",
nextPageLabel: "\u6B21\u306E\u30DA\u30FC\u30B8",
lastUpdatedText: "\u6700\u7D42\u66F4\u65B0\u65E5",
changelogText: "\u5909\u66F4\u5C65\u6B74",
changelogOnText: "\u306B",
changelogButtonText: "\u3059\u3079\u3066\u306E\u5909\u66F4\u5C65\u6B74\u3092\u898B\u308B",
copyrightText: "\u8457\u4F5C\u6A29",
copyrightAuthorText: "\u8457\u4F5C\u6A29\u8005\uFF1A",
copyrightCreationOriginalText: "\u672C\u6587\u30EA\u30F3\u30AF\uFF1A",
copyrightCreationTranslateText: "\u672C\u6587\u306E\u7FFB\u8A33\u5143\uFF1A",
copyrightCreationReprintText: "\u672C\u6587\u306E\u8EE2\u8F09\u5143\uFF1A",
copyrightLicenseText: "\u30E9\u30A4\u30BB\u30F3\u30B9\uFF1A",
notFound: {
code: "404",
title: "\u30DA\u30FC\u30B8\u304C\u898B\u3064\u304B\u308A\u307E\u305B\u3093",
quote: "\u3057\u304B\u3057\u3001\u65B9\u5411\u3092\u5909\u3048\u305A\u306B\u63A2\u3057\u7D9A\u3051\u308C\u3070\u3001\u6700\u7D42\u7684\u306B\u306F\u884C\u304D\u305F\u3044\u5834\u6240\u306B\u305F\u3069\u308A\u7740\u304F\u304B\u3082\u3057\u308C\u307E\u305B\u3093\u3002",
linkText: "\u30DB\u30FC\u30E0\u306B\u623B\u308B"
},
homeText: "\u30DB\u30FC\u30E0",
blogText: "\u30D6\u30ED\u30B0",
tagText: "\u30BF\u30B0",
archiveText: "\u30A2\u30FC\u30AB\u30A4\u30D6",
categoryText: "\u30AB\u30C6\u30B4\u30EA\u30FC",
archiveTotalText: "{count} \u4EF6",
encryptButtonText: "\u78BA\u8A8D",
encryptPlaceholder: "\u30D1\u30B9\u30EF\u30FC\u30C9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",
encryptGlobalText: "\u3053\u306E\u30B5\u30A4\u30C8\u306F\u30D1\u30B9\u30EF\u30FC\u30C9\u3067\u306E\u307F\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u3067\u3059",
encryptPageText: "\u3053\u306E\u30DA\u30FC\u30B8\u306F\u30D1\u30B9\u30EF\u30FC\u30C9\u3067\u306E\u307F\u30A2\u30AF\u30BB\u30B9\u53EF\u80FD\u3067\u3059",
footer: {
message: '<a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a> \u306B\u3088\u3063\u3066\u63D0\u4F9B\u3055\u308C\u3066\u3044\u307E\u3059'
}
};
var jaPresetLocale = {
// ------ copyright license ------
"CC0": "CC0 1.0 \u30D1\u30D6\u30EA\u30C3\u30AF\u30C9\u30E1\u30A4\u30F3",
"CC-BY-4.0": "\u8868\u793A 4.0 \u56FD\u969B",
"CC-BY-NC-4.0": "\u8868\u793A-\u975E\u55B6\u5229 4.0 \u56FD\u969B",
"CC-BY-NC-SA-4.0": "\u8868\u793A-\u975E\u55B6\u5229-\u7D99\u627F 4.0 \u56FD\u969B",
"CC-BY-NC-ND-4.0": "\u8868\u793A-\u975E\u55B6\u5229-\u6539\u5909\u7981\u6B62 4.0 \u56FD\u969B",
"CC-BY-ND-4.0": "\u8868\u793A-\u6539\u5909\u7981\u6B62 4.0 \u56FD\u969B",
"CC-BY-SA-4.0": "\u8868\u793A-\u7D99\u627F 4.0 \u56FD\u969B"
};
// src/node/locales/ru.ts
var ruLocale = {
selectLanguageName: "\u0420\u0443\u0441\u0441\u043A\u0438\u0439",
selectLanguageText: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u044F\u0437\u044B\u043A",
appearanceText: "\u0412\u043D\u0435\u0448\u043D\u0438\u0439 \u0432\u0438\u0434",
lightModeSwitchTitle: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043D\u0430 \u0441\u0432\u0435\u0442\u043B\u0443\u044E \u0442\u0435\u043C\u0443",
darkModeSwitchTitle: "\u041F\u0435\u0440\u0435\u043A\u043B\u044E\u0447\u0438\u0442\u044C \u043D\u0430 \u0442\u0435\u043C\u043D\u0443\u044E \u0442\u0435\u043C\u0443",
outlineLabel: "\u0421\u043E\u0434\u0435\u0440\u0436\u0430\u043D\u0438\u0435 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B",
returnToTopLabel: "\u0412\u0435\u0440\u043D\u0443\u0442\u044C\u0441\u044F \u043D\u0430\u0432\u0435\u0440\u0445",
editLinkText: "\u0420\u0435\u0434\u0430\u043A\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0443",
contributorsText: "\u0410\u0432\u0442\u043E\u0440\u044B",
prevPageLabel: "\u041F\u0440\u0435\u0434\u044B\u0434\u0443\u0449\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430",
nextPageLabel: "\u0421\u043B\u0435\u0434\u0443\u044E\u0449\u0430\u044F \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430",
lastUpdatedText: "\u041F\u043E\u0441\u043B\u0435\u0434\u043D\u0435\u0435 \u043E\u0431\u043D\u043E\u0432\u043B\u0435\u043D\u0438\u0435",
changelogText: "\u0418\u0441\u0442\u043E\u0440\u0438\u044F \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u0439",
changelogOnText: "\u043E\u0442",
changelogButtonText: "\u041F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u0432\u0441\u0435 \u0438\u0437\u043C\u0435\u043D\u0435\u043D\u0438\u044F",
copyrightText: "\u0412\u0441\u0435 \u043F\u0440\u0430\u0432\u0430 \u0437\u0430\u0449\u0438\u0449\u0435\u043D\u044B",
copyrightAuthorText: "\u0410\u0432\u0442\u043E\u0440\u0441\u043A\u0438\u0435 \u043F\u0440\u0430\u0432\u0430 \u043F\u0440\u0438\u043D\u0430\u0434\u043B\u0435\u0436\u0430\u0442:",
copyrightCreationOriginalText: "\u0421\u0441\u044B\u043B\u043A\u0430 \u043D\u0430 \u0441\u0442\u0430\u0442\u044C\u044E:",
copyrightCreationTranslateText: "\u041F\u0435\u0440\u0435\u0432\u043E\u0434 \u0441\u0442\u0430\u0442\u044C\u0438:",
copyrightCreationReprintText: "\u041F\u0435\u0440\u0435\u043F\u0435\u0447\u0430\u0442\u0430\u043D\u043E \u0438\u0437:",
copyrightLicenseText: "\u041B\u0438\u0446\u0435\u043D\u0437\u0438\u044F:",
notFound: {
code: "404",
title: "\u0421\u0442\u0440\u0430\u043D\u0438\u0446\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430",
quote: "\u041D\u043E \u0435\u0441\u043B\u0438 \u0432\u044B \u043D\u0435 \u043C\u0435\u043D\u044F\u0435\u0442\u0435 \u043A\u0443\u0440\u0441 \u0438 \u043F\u0440\u043E\u0434\u043E\u043B\u0436\u0430\u0435\u0442\u0435 \u0438\u0441\u043A\u0430\u0442\u044C, \u0432 \u043A\u043E\u043D\u0435\u0447\u043D\u043E\u043C \u0438\u0442\u043E\u0433\u0435 \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0434\u043E\u0431\u0440\u0430\u0442\u044C\u0441\u044F \u0434\u043E \u043C\u0435\u0441\u0442\u0430 \u043D\u0430\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u044F.",
linkText: "\u0412\u0435\u0440\u043D\u0443\u0442\u044C\u0441\u044F \u043D\u0430 \u0433\u043B\u0430\u0432\u043D\u0443\u044E"
},
homeText: "\u0413\u043B\u0430\u0432\u043D\u0430\u044F",
blogText: "\u0411\u043B\u043E\u0433",
tagText: "\u0422\u0435\u0433\u0438",
archiveText: "\u0410\u0440\u0445\u0438\u0432",
categoryText: "\u041A\u0430\u0442\u0435\u0433\u043E\u0440\u0438\u0438",
archiveTotalText: "{count} \u0441\u0442\u0430\u0442\u0435\u0439",
encryptButtonText: "\u041F\u043E\u0434\u0442\u0432\u0435\u0440\u0434\u0438\u0442\u044C",
encryptPlaceholder: "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u043F\u0430\u0440\u043E\u043B\u044C",
encryptGlobalText: "\u0414\u043E\u0441\u0442\u0443\u043F \u043A \u0441\u0430\u0439\u0442\u0443 \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E \u043F\u0430\u0440\u043E\u043B\u044E",
encryptPageText: "\u0414\u043E\u0441\u0442\u0443\u043F \u043A \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0435 \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u043E \u043F\u0430\u0440\u043E\u043B\u044E",
footer: {
message: '\u0420\u0430\u0431\u043E\u0442\u0430\u0435\u0442 \u043D\u0430 <a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a>'
}
};
var ruPresetLocale = {
// ------ copyright license ------
"CC0": "CC0 1.0 \u0423\u043D\u0438\u0432\u0435\u0440\u0441\u0430\u043B\u044C\u043D\u0430\u044F",
"CC-BY-4.0": "\u0410\u0442\u0440\u0438\u0431\u0443\u0446\u0438\u044F 4.0 \u041C\u0435\u0436\u0434\u0443\u043D\u0430\u0440\u043E\u0434\u043D\u044B\u0439",
"CC-BY-NC-4.0": "\u0410\u0442\u0440\u0438\u0431\u0443\u0446\u0438\u044F-\u041D\u0435\u043A\u043E\u043C\u043C\u0435\u0440\u0447\u0435\u0441\u043A\u043E\u0435 4.0 \u041C\u0435\u0436\u0434\u0443\u043D\u0430\u0440\u043E\u0434\u043D\u044B\u0439",
"CC-BY-NC-SA-4.0": "\u0410\u0442\u0440\u0438\u0431\u0443\u0446\u0438\u044F-\u041D\u0435\u043A\u043E\u043C\u043C\u0435\u0440\u0447\u0435\u0441\u043A\u043E\u0435-\u0421 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435\u043C \u0443\u0441\u043B\u043E\u0432\u0438\u0439 4.0 \u041C\u0435\u0436\u0434\u0443\u043D\u0430\u0440\u043E\u0434\u043D\u044B\u0439",
"CC-BY-NC-ND-4.0": "\u0410\u0442\u0440\u0438\u0431\u0443\u0446\u0438\u044F-\u041D\u0435\u043A\u043E\u043C\u043C\u0435\u0440\u0447\u0435\u0441\u043A\u043E\u0435-\u0411\u0435\u0437 \u043F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u043D\u044B\u0445 4.0 \u041C\u0435\u0436\u0434\u0443\u043D\u0430\u0440\u043E\u0434\u043D\u044B\u0439",
"CC-BY-ND-4.0": "\u0410\u0442\u0440\u0438\u0431\u0443\u0446\u0438\u044F-\u0411\u0435\u0437 \u043F\u0440\u043E\u0438\u0437\u0432\u043E\u0434\u043D\u044B\u0445 4.0 \u041C\u0435\u0436\u0434\u0443\u043D\u0430\u0440\u043E\u0434\u043D\u044B\u0439",
"CC-BY-SA-4.0": "\u0410\u0442\u0440\u0438\u0431\u0443\u0446\u0438\u044F-\u0421 \u0441\u043E\u0445\u0440\u0430\u043D\u0435\u043D\u0438\u0435\u043C \u0443\u0441\u043B\u043E\u0432\u0438\u0439 4.0 \u041C\u0435\u0436\u0434\u0443\u043D\u0430\u0440\u043E\u0434\u043D\u044B\u0439"
};
// src/node/locales/zh-tw.ts
var zhTwLocale = {
selectLanguageName: "\u7E41\u9AD4\u4E2D\u6587",
selectLanguageText: "\u9078\u64C7\u8A9E\u8A00",
appearanceText: "\u5916\u89C0",
lightModeSwitchTitle: "\u5207\u63DB\u70BA\u6DFA\u8272\u4E3B\u984C",
darkModeSwitchTitle: "\u5207\u63DB\u70BA\u6DF1\u8272\u4E3B\u984C",
outlineLabel: "\u6B64\u9801\u5167\u5BB9",
returnToTopLabel: "\u8FD4\u56DE\u9802\u90E8",
editLinkText: "\u7DE8\u8F2F\u6B64\u9801",
contributorsText: "\u8CA2\u737B\u8005",
prevPageLabel: "\u4E0A\u4E00\u9801",
nextPageLabel: "\u4E0B\u4E00\u9801",
lastUpdatedText: "\u6700\u5F8C\u66F4\u65B0\u65BC",
changelogText: "\u8B8A\u66F4\u6B77\u53F2",
changelogOnText: "\u65BC",
changelogButtonText: "\u67E5\u770B\u5168\u90E8\u8B8A\u66F4\u6B77\u53F2",
copyrightText: "\u7248\u6B0A\u6240\u6709",
copyrightAuthorText: "\u7248\u6B0A\u6B78\u5C6C\uFF1A",
copyrightCreationOriginalText: "\u672C\u6587\u9023\u7D50\uFF1A",
copyrightCreationTranslateText: "\u672C\u6587\u7FFB\u8B6F\u81EA\uFF1A",
copyrightCreationReprintText: "\u672C\u6587\u8F49\u8F09\u81EA\uFF1A",
copyrightLicenseText: "\u8A31\u53EF\u8B49\uFF1A",
notFound: {
code: "404",
title: "\u9801\u9762\u672A\u627E\u5230",
quote: "\u4F46\u662F\uFF0C\u5982\u679C\u4F60\u4E0D\u6539\u8B8A\u65B9\u5411\uFF0C\u4E26\u4E14\u4E00\u76F4\u5C0B\u627E\uFF0C\u6700\u7D42\u53EF\u80FD\u6703\u5230\u9054\u4F60\u8981\u53BB\u7684\u5730\u65B9\u3002",
linkText: "\u8FD4\u56DE\u9996\u9801"
},
homeText: "\u9996\u9801",
blogText: "\u535A\u5BA2",
tagText: "\u6A19\u7C64",
archiveText: "\u6B78\u6A94",
categoryText: "\u5206\u985E",
archiveTotalText: "{count} \u7BC7",
encryptButtonText: "\u78BA\u8A8D",
encryptPlaceholder: "\u8ACB\u8F38\u5165\u5BC6\u78BC",
encryptGlobalText: "\u672C\u7AD9\u53EA\u5141\u8A31\u5BC6\u78BC\u8A2A\u554F",
encryptPageText: "\u672C\u9801\u9762\u53EA\u5141\u8A31\u5BC6\u78BC\u8A2A\u554F",
footer: {
message: 'Powered by <a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a>'
}
};
var zhTwPresetLocale = {
// ------ copyright license ------
"CC0": "CC0 1.0 \u901A\u7528",
"CC-BY-4.0": "\u7F72\u540D 4.0 \u570B\u969B",
"CC-BY-NC-4.0": "\u7F72\u540D-\u975E\u5546\u696D\u6027 4.0 \u570B\u969B",
"CC-BY-NC-SA-4.0": "\u7F72\u540D-\u975E\u5546\u696D\u6027-\u76F8\u540C\u65B9\u5F0F\u5171\u4EAB 4.0 \u570B\u969B",
"CC-BY-NC-ND-4.0": "\u7F72\u540D-\u975E\u5546\u696D\u6027-\u7981\u6B62\u6F14\u7E79 4.0 \u570B\u969B",
"CC-BY-ND-4.0": "\u7F72\u540D-\u7981\u6B62\u6F14\u7E79 4.0 \u570B\u969B",
"CC-BY-SA-4.0": "\u7F72\u540D-\u76F8\u540C\u65B9\u5F0F\u5171\u4EAB 4.0 \u570B\u969B"
};
// src/node/locales/zh.ts
var zhLocale = {
selectLanguageName: "\u7B80\u4F53\u4E2D\u6587",
selectLanguageText: "\u9009\u62E9\u8BED\u8A00",
appearanceText: "\u5916\u89C2",
lightModeSwitchTitle: "\u5207\u6362\u4E3A\u6D45\u8272\u4E3B\u9898",
darkModeSwitchTitle: "\u5207\u6362\u4E3A\u6DF1\u8272\u4E3B\u9898",
outlineLabel: "\u6B64\u9875\u5185\u5BB9",
returnToTopLabel: "\u8FD4\u56DE\u9876\u90E8",
editLinkText: "\u7F16\u8F91\u6B64\u9875",
contributorsText: "\u8D21\u732E\u8005",
prevPageLabel: "\u4E0A\u4E00\u9875",
nextPageLabel: "\u4E0B\u4E00\u9875",
lastUpdatedText: "\u6700\u540E\u66F4\u65B0\u4E8E",
changelogText: "\u53D8\u66F4\u5386\u53F2",
changelogOnText: "\u4E8E",
changelogButtonText: "\u67E5\u770B\u5168\u90E8\u53D8\u66F4\u5386\u53F2",
copyrightText: "\u7248\u6743\u6240\u6709",
copyrightAuthorText: "\u7248\u6743\u5F52\u5C5E\uFF1A",
copyrightCreationOriginalText: "\u672C\u6587\u94FE\u63A5\uFF1A",
copyrightCreationTranslateText: "\u672C\u6587\u7FFB\u8BD1\u81EA\uFF1A",
copyrightCreationReprintText: "\u672C\u6587\u8F6C\u8F7D\u81EA\uFF1A",
copyrightLicenseText: "\u8BB8\u53EF\u8BC1\uFF1A",
notFound: {
code: "404",
title: "\u9875\u9762\u672A\u627E\u5230",
quote: "\u4F46\u662F\uFF0C\u5982\u679C\u4F60\u4E0D\u6539\u53D8\u65B9\u5411\uFF0C\u5E76\u4E14\u4E00\u76F4\u5BFB\u627E\uFF0C\u6700\u7EC8\u53EF\u80FD\u4F1A\u5230\u8FBE\u4F60\u8981\u53BB\u7684\u5730\u65B9\u3002",
linkText: "\u8FD4\u56DE\u9996\u9875"
},
homeText: "\u9996\u9875",
blogText: "\u535A\u5BA2",
tagText: "\u6807\u7B7E",
archiveText: "\u5F52\u6863",
categoryText: "\u5206\u7C7B",
archiveTotalText: "{count} \u7BC7",
encryptButtonText: "\u786E\u8BA4",
encryptPlaceholder: "\u8BF7\u8F93\u5165\u5BC6\u7801",
encryptGlobalText: "\u672C\u7AD9\u53EA\u5141\u8BB8\u5BC6\u7801\u8BBF\u95EE",
encryptPageText: "\u672C\u9875\u9762\u53EA\u5141\u8BB8\u5BC6\u7801\u8BBF\u95EE",
footer: {
message: 'Powered by <a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a>'
}
};
var zhPresetLocale = {
// ------ copyright license ------
"CC0": "CC0 1.0 \u901A\u7528",
"CC-BY-4.0": "\u7F72\u540D 4.0 \u56FD\u9645",
"CC-BY-NC-4.0": "\u7F72\u540D-\u975E\u5546\u4E1A\u6027 4.0 \u56FD\u9645",
"CC-BY-NC-SA-4.0": "\u7F72\u540D-\u975E\u5546\u4E1A\u6027-\u76F8\u540C\u65B9\u5F0F\u5171\u4EAB 4.0 \u56FD\u9645",
"CC-BY-NC-ND-4.0": "\u7F72\u540D-\u975E\u5546\u4E1A\u6027-\u7981\u6B62\u6F14\u7ECE 4.0 \u56FD\u9645",
"CC-BY-ND-4.0": "\u7F72\u540D-\u7981\u6B62\u6F14\u7ECE 4.0 \u56FD\u9645",
"CC-BY-SA-4.0": "\u7F72\u540D-\u76F8\u540C\u65B9\u5F0F\u5171\u4EAB 4.0 \u56FD\u9645"
};
// src/node/locales/index.ts
var LOCALE_OPTIONS = [
[["en", "en-US"], enLocale],
[["zh", "zh-CN", "zh-Hans", "zh-Hant"], zhLocale],
[["zh-TW"], zhTwLocale],
[["de", "de-DE"], deLocale],
[["fr", "fr-FR"], frLocale],
[["ru", "ru-RU"], ruLocale],
[["ja", "ja-JP"], jaLocale]
];
var PRESET_LOCALES = [
[["en", "en-US"], enPresetLocale],
[["zh", "zh-CN", "zh-Hans", "zh-Hant"], zhPresetLocale],
[["zh-TW"], zhTwPresetLocale],
[["de", "de-DE"], dePresetLocale],
[["fr", "fr-FR"], frPresetLocale],
[["ru", "ru-RU"], ruPresetLocale],
[["ja", "ja-JP"], jaPresetLocale]
];
// src/node/config/initThemeOptions.ts
var FALLBACK_OPTIONS = {
appearance: true,
blog: {
pagination: 15,
postList: true,
tags: true,
archives: true,
categories: true,
link: "/blog/",
tagsLink: "/blog/tags/",
archivesLink: "/blog/archives/",
categoriesLink: "/blog/categories/"
},
article: "/article/",
notes: { link: "/", dir: "/notes/", notes: [] },
navbarSocialInclude: ["github", "twitter", "discord", "facebook"],
aside: true,
outline: [2, 3],
externalLinkIcon: true,
// page meta
editLink: true,
contributors: true,
changelog: false,
prevPage: true,
nextPage: true,
footer: {
message: 'Power by <a target="_blank" href="https://v2.vuepress.vuejs.org/">VuePress</a> & <a target="_blank" href="https://theme-plume.vuejs.press">vuepress-theme-plume</a>'
}
};
function initThemeOptions(app, { locales, ...options }) {
const resolvedOptions = {
...mergeOptions(FALLBACK_OPTIONS, options),
locales: getFullLocaleConfig({
app,
name: THEME_NAME,
default: LOCALE_OPTIONS,
config: fromEntries(
entries({
"/": {},
...locales
}).map(([locale, opt]) => [
locale,
mergeOptions(options, opt)
])
)
})
};
return resolvedOptions;
}
function mergeOptions(target, source) {
const res = {};
const keys = uniq([...Object.keys(target), ...Object.keys(source)]);
for (const key of keys) {
if (hasOwn(source, key)) {
const value = source[key];
const targetValue = target[key];
if (isPlainObject(targetValue) && isPlainObject(value)) {
res[key] = Object.assign({}, targetValue, value);
} else {
res[key] = value;
}
} else {
res[key] = target[key];
}
}
return res;
}
// src/node/loadConfig/loader.ts
var loader = null;
async function initConfigLoader(app, { configFile, onChange, defaultConfig }) {
perf.mark("load-config");
loader = {
configFile,
dependencies: [],
load: () => compiler(loader.configFile),
loaded: false,
changeEvents: [],
whenLoaded: [],
defaultConfig,
config: initThemeOptions(app, defaultConfig)
};
perf.mark("load-config:find");
loader.configFile = await findConfigPath(app, configFile);
perf.log("load-config:find");
if (onChange) {
loader.changeEvents.push(onChange);
}
perf.mark("load-config:loaded");
const { config, dependencies = [] } = await loader.load();
perf.log("load-config:loaded");
loader.loaded = true;
loader.dependencies = [...dependencies];
updateResolvedConfig(app, config);
loader.whenLoaded.forEach((fn) => fn(loader.config));
loader.whenLoaded = [];
perf.log("load-config");
}
function watchConfigFile(app, watchers, onChange) {
if (!loader || !loader.configFile)
return;
const watcher = watch(loader.configFile, {
ignoreInitial: true,
cwd: process4.cwd()
});
addDependencies(watcher);
onConfigChange(onChange);
watcher.on("change", async () => {
if (loader) {
loader.loaded = false;
const { config, dependencies = [] } = await loader.load();
loader.loaded = true;
addDependencies(watcher, dependencies);
updateResolvedConfig(app, config);
runChangeEvents();
}
});
watcher.on("unlink", async () => {
updateResolvedConfig(app);
runChangeEvents();
});
watchers.push(watcher);
}
async function onConfigChange(onChange) {
if (loader && !loader.changeEvents.includes(onChange)) {
loader.changeEvents.push(onChange);
if (loader.loaded) {
await onChange(loader.config);
}
}
}
function waitForConfigLoaded() {
return new Promise((resolve3) => {
if (loader?.loaded) {
resolve3(loader.config);
} else {
loader?.whenLoaded.push(resolve3);
}
});
}
function getThemeConfig() {
return loader.config;
}
function updateResolvedConfig(app, userConfig = {}) {
if (loader) {
const config = deepMerge({}, loader.defaultConfig, userConfig);
loader.config = initThemeOptions(app, config);
}
}
async function runChangeEvents() {
if (loader) {
await Promise.all(loader.changeEvents.map((fn) => fn(loader.config)));
}
}
function addDependencies(watcher, dependencies) {
if (!loader)
return;
if (dependencies?.length) {
const deps = dependencies.filter((dep) => !loader.dependencies.includes(dep) && dep[0] === ".");
loader.dependencies.push(...deps);
watcher.add(deps);
} else {
watcher.add(loader.dependencies);
}
}
// src/node/autoFrontmatter/readFile.ts
import fg from "fast-glob";
import { fs as fs4, path as path5 } from "vuepress/utils";
async function readMarkdownList(app, { globFilter, checkCache }) {
const source = app.dir.source();
const files = await fg(["**/*.md"], {
cwd: source,
ignore: ["node_modules", ".vuepress"]
});
return await Promise.all(
files.filter((id) => {
if (!globFilter(id))
return false;
return checkCache(path5.join(source, id));
}).map((file) => readMarkdown(source, file))
);
}
async function readMarkdown(sourceDir, relativePath) {
const filepath = path5.join(sourceDir, relativePath);
const stats = await fs4.promises.stat(filepath);
return {
filepath,
relativePath: normalizePath(relativePath),
content: await fs4.promises.readFile(filepath, "utf-8"),
createTime: getFileCreateTime(stats),
stats
};
}
function getFileCreateTime(stats) {
return stats.birthtime.getFullYear() !== 1970 ? stats.birthtime : stats.atime;
}
// src/node/autoFrontmatter/resolveOptions.ts
import { uniq as uniq3 } from "@pengzhanbo/utils";
import { ensureLeadingSlash as ensureLeadingSlash2 } from "@vuepress/helper";
import { resolveLocalePath } from "vuepress/shared";
import { path as path7 } from "vuepress/utils";
// src/node/config/extendsBundlerOptions.ts
import {
addViteConfig,
addViteOptimizeDepsExclude,
addViteOptimizeDepsInclude,
addViteSsrNoExternal,
chainWebpack
} from "@vuepress/helper";
import { isPackageExists } from "local-pkg";
function extendsBundlerOptions(bundlerOptions, app) {
addViteConfig(bundlerOptions, app, {
build: {
chunkSizeWarningLimit: 2048
}
});
addViteOptimizeDepsInclude(
bundlerOptions,
app,
["@vueuse/core", "bcrypt-ts/browser", "@vuepress/helper/client", "@iconify/vue", "@iconify/vue/offline", "@vuepress/plugin-git/client"]
);
addViteOptimizeDepsExclude(bundlerOptions, app, "@theme");
addViteSsrNoExternal(bundlerOptions, app, [
"@vuepress/helper",
"@vuepress/plugin-reading-time",
"@vuepress/plugin-watermark"
]);
if (isPackageExists("swiper")) {
addViteOptimizeDepsInclude(bundlerOptions, app, ["swiper/modules", "swiper/vue"]);
addViteSsrNoExternal(bundlerOptions, app, ["swiper"]);
}
const silenceDeprecations = ["mixed-decls", "legacy-js-api", "import", "global-builtin"];
chainWebpack(bundlerOptions, app, (config) => {
config.module.rule("scss").use("sass-loader").tap((options) => ({
...options,
sassOptions: {
silenceDeprecations,
...options.sassOptions
}
}));
});
addViteConfig(bundlerOptions, app, {
css: {
preprocessorOptions: {
sass: {
silenceDeprecations
},
scss: {
silenceDeprecations
}
}
}
});
}
// src/node/config/resolveNotesOptions.ts
import { uniq as uniq2 } from "@pengzhanbo/utils";
import { entries as entries2, removeLeadingSlash } from "@vuepress/helper";
function resolveNotesLinkList(options) {
const locales = options.locales || {};
const notesLinks = [];
for (const [locale, opt] of entries2(locales)) {
const config = locale === "/" ? opt.notes || options.notes : opt.notes;
if (config && config.notes?.length) {
const prefix = config.link || "";
notesLinks.push(
...config.notes.map(
(note) => withBase(`${prefix}/${note.link || ""}`, locale)
)
);
}
}
return uniq2(notesLinks);
}
function resolveNotesOptions(options) {
const locales = options.locales || {};
const notesOptionsList = [];
for (const [locale, opt] of entries2(locales)) {
const current = locale === "/" ? opt.notes || options.notes : opt.notes;
if (current) {
current.dir = withBase(current.dir, locale);
notesOptionsList.push(current);
}
}
return notesOptionsList;
}
function resolveNotesDirs(options) {
const notesList = resolveNotesOptions(options);
return uniq2(notesList.flatMap(
({ notes, dir }) => notes.map((note) => removeLeadingSlash(normalizePath(`${dir}/${note.dir || ""}/`)))
));
}
// src/node/config/resolveThemeData.ts
import { entries as entries3, isBoolean, isPlainObject as isPlainObject2 } from "@vuepress/helper";
var EXCLUDE_LIST = [
"hostname",
"locales",
"sidebar",
"navbar",
"notes",
"sidebar",
"article",
"changelog",
"contributors",
"bulletin",
"cache",
"autoFrontmatter",
"comment",
"codeHighlighter",
"markdown",
"configFile",
"encrypt",
"plugins",
"search",
"watermark",
"readingTime",
"copyCode"
];
var EXCLUDE_LOCALE_LIST = [...EXCLUDE_LIST, "blog", "appearance"];
function resolveThemeData(app, options) {
const themeData = { locales: {} };
entries3(options).forEach(([key, value]) => {
if (!EXCLUDE_LIST.includes(key))
themeData[key] = value;
});
themeData.contributors = isPlainObject2(options.contributors) ? { mode: options.contributors.mode || "inline" } : isBoolean(options.contributors) ? options.contributors : true;
themeData.changelog = !!options.changelog;
if (isPlainObject2(options.bulletin)) {
const { enablePage: _, ...opt } = options.bulletin;
themeData.bulletin = opt;
} else if (options.bulletin) {
themeData.bulletin = options.bulletin;
}
if (isPlainObject2(options.blog)) {
const { categoriesTransform, include, exclude, ...blog } = options.blog;
themeData.blog = blog;
} else {
themeData.blog = options.blog;
}
entries3(options.locales || {}).forEach(([locale, opt]) => {
themeData.locales[locale] = {};
entries3(opt).forEach(([key, value]) => {
if (!EXCLUDE_LOCALE_LIST.includes(key))
themeData.locales[locale][key] = value;
});
if (isPlainObject2(opt.bulletin)) {
const { enablePage: _, ...rest } = opt.bulletin;
themeData.locales[locale].bulletin = rest;
} else if (opt.bulletin) {
themeData.locales[locale].bulletin = opt.bulletin;
}
});
entries3(options.locales || {}).forEach(([locale, opt]) => {
if (opt.navbar !== false && (!opt.navbar || opt.navbar.length === 0)) {
const navbar = [{
text: opt.homeText || options.homeText || "Home",
link: locale
}];
if (options.blog !== false) {
const blog = options.blog || {};
const blogLink = blog.link || "/blog/";
navbar.push({
text: opt.blogText || options.blogText || "Blog",
link: withBase(blogLink, locale)
});
if (blog.tags !== false) {
navbar.push({
text: opt.tagText || options.tagText || "Tags",
link: withBase(blog.tagsLink || `${blogLink}/tags/`, locale)
});
}
if (blog.archives !== false) {
navbar.push({
text: opt.archiveText || options.archiveText || "Archives",
link: withBase(blog.archivesLink || `${blogLink}/archives/`, locale)
});
}
}
themeData.locales[locale].navbar = navbar;
} else {
themeData.locales[locale].navbar = opt.navbar;
}
});
return themeData;
}
// src/node/config/setupAlias.ts
import { fs as fs5, path as path6 } from "vuepress/utils";
function setupAlias() {
return {
...Object.fromEntries(
fs5.readdirSync(
resolve("client/components"),
{ encoding: "utf-8", recursive: true }
).filter((file) => file.endsWith(".vue")).map((file) => [
path6.join("@theme", file),
resolve("client/components", file)
])
)
};
}
// src/node/config/setupProvideData.ts
import { getFullLocaleConfig as getFullLocaleConfig2, isPlainObject as isPlainObject3 } from "@vuepress/helper";
function setupProvideData(app, plugins) {
const options = getThemeConfig();
const watermark = options.watermark ?? plugins.watermark;
return {
// 注入水印配置
__PLUME_WM_FP__: isPlainObject3(watermark) ? watermark.fullPage !== false : true,
// 注入多语言配置
__PLUME_PRESET_LOCALE__: getFullLocaleConfig2({
app,
name: "vuepress-theme-plume/preset-locales",
default: PRESET_LOCALES
})
};
}
// src/node/config/templateBuildRenderer.ts
import { templateRenderer } from "vuepress/utils";
function templateBuildRenderer(template, context) {
const options = getThemeConfig();
const pkg = getThemePackage();
template = template.replace("{{ themeVersion }}", pkg.version || "").replace(/^\s+|\s+$/gm, "").replace(/\n/g, "");
if (options.appearance ?? true) {
const appearance = typeof options.appearance === "string" ? options.appearance : "auto";
const script = appearance === "force-dark" ? `document.documentElement.dataset.theme = 'dark'` : `;(function () {
const um= localStorage.getItem('vuepress-theme-appearance') || '${appearance}';
const sm = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
const isDark = um === 'dark' || (um !== 'light' && sm);
document.documentElement.dataset.theme = isDark ? 'dark' : 'light';
})();`.replace(/^\s+|\s+$/gm, "").replace(/\n/g, "");
template = template.replace("<!--vuepress-theme-plume-appearance-->", `<script id="check-dark-mode">${script}</script>`);
} else {
template = template.replace("<!--vuepress-theme-plume-appearance-->", "");
}
return templateRenderer(template, context);
}
// src/node/autoFrontmatter/baseFrontmatter.ts
import dayjs from "dayjs";
function createBaseFrontmatter(autoFrontmatter) {
const res = {};
if (autoFrontmatter.createTime !== false) {
res.createTime = (formatTime, { createTime }, data) => {
if (formatTime)
return formatTime;
if (data.friends || data.pageLayout === "friends")
return;
return dayjs(new Date(createTime)).format("YYYY/MM/DD HH:mm:ss");
};
}
return res;
}
// src/node/autoFrontmatter/resolveLinkBySidebar.ts
function resolveLinkBySidebar(sidebar, _prefix) {
const res = {};
if (sidebar === "auto") {
return res;
}
for (const item of sidebar) {
if (typeof item !== "string") {
const { prefix, dir = "", link = "/", items, text = "" } = item;
getSidebarLink(items, link, text, pathJoin(_prefix, prefix || dir), res);
}
}
return res;
}
function getSidebarLink(items, link, text, dir = "", res = {}) {
if (items === "auto")
return;
if (!items) {
res[pathJoin(dir, `${text}.md`)] = link;
return;
}
for (const item of items) {
if (typeof item === "string") {
if (!link)
continue;
if (item) {
res[pathJoin(dir, `${item}.md`)] = link;
} else {
res[pathJoin(dir, "README.md")] = link;
res[pathJoin(dir, "index.md")] = link;
res[pathJoin(dir, "readme.md")] = link;
}
res[dir] = link;
} else {
const { prefix, dir: subDir = "", link: subLink = "/", items: subItems, text: subText = "" } = item;
getSidebarLink(subItems, pathJoin(link, subLink), subText, pathJoin(prefix || dir, subDir), res);
}
}
}
// src/node/autoFrontmatter/resolveOptions.ts
function resolveOptions(options, autoFrontmatter) {
const resolveLocale = (relativeFilepath) => resolveLocalePath(options.locales, ensureLeadingSlash2(relativeFilepath));
const findNotesByLocale = (locale) => {
const notes = options.locales?.[locale]?.notes;
return notes === false ? void 0 : notes;
};
const findNote = (relativeFilepath) => {
const locale = resolveLocale(relativeFilepath);
const filepath = ensureLeadingSlash2(relativeFilepath);
const notes = findNotesByLocale(locale);
if (!notes)
return void 0;
const notesList = notes?.notes || [];
const notesDir = notes?.dir || "";
return notesList.find(
(note) => filepath.startsWith(normalizePath(`${notesDir}/${note.dir}`))
);
};
const baseFrontmatter = createBaseFrontmatter(autoFrontmatter);
const localesNotesDirs = resolveNotesDirs(options);
const configs = [];
if (localesNotesDirs.length) {
configs.push({
include: localesNotesDirs.map((dir) => pathJoin(dir, "/{readme,README,index}.md")),
frontmatter: {
title(title, { relativePath }) {
if (title)
return title;
if (autoFrontmatter.title === false)
return;
return findNote(relativePath)?.text || getCurrentDirname("", relativePath);
},
...baseFrontmatter,
permalink(permalink, { relativePath }, data) {
if (permalink)
return permalink;
if (autoFrontmatter.permalink === false || data.friends || data.pageLayout === "friends")
return;
const locale = resolveLocale(relativePath);
const prefix = findNotesByLocale(locale)?.link || "";
const note = findNote(relativePath);
return pathJoin(
prefix.startsWith(locale) ? "/" : locale,
prefix,
note?.link || getCurrentDirname(note?.dir, relativePath),
"/"
);
}
}
});
configs.push({
include: localesN