vuepress-theme-plume/theme/src/node/config/resolveProvideData.ts
2024-07-08 02:44:01 +08:00

24 lines
733 B
TypeScript

import type { App } from 'vuepress'
import { entries, fromEntries, getRootLangPath, isPlainObject } from '@vuepress/helper'
import type { PlumeThemePluginOptions } from '../../shared/index.js'
import { PRESET_LOCALES } from '../locales/index.js'
export function resolveProvideData(
app: App,
plugins: PlumeThemePluginOptions,
): Record<string, any> {
const root = getRootLangPath(app)
return {
// 注入水印配置
__PLUME_WM_FP__: isPlainObject(plugins.watermark)
? plugins.watermark.fullPage !== false
: true,
// 注入多语言配置
__PLUME_PRESET_LOCALE__: fromEntries(
entries(PRESET_LOCALES)
.map(([locale, value]) => [locale === root ? '/' : locale, value]),
),
}
}