mirror of
https://github.com/pengzhanbo/vuepress-theme-plume.git
synced 2026-04-23 10:58:13 +08:00
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import type { App } from 'vuepress'
|
|
import { watch } from 'chokidar'
|
|
import { getThemeConfig } from '../loadConfig/index.js'
|
|
import { prepareArticleTagColors } from './prepareArticleTagColor.js'
|
|
import { preparedBlogData } from './prepareBlogData.js'
|
|
import { prepareEncrypt } from './prepareEncrypt.js'
|
|
import { prepareIcons } from './prepareIcons.js'
|
|
import { prepareSidebar } from './prepareSidebar.js'
|
|
|
|
export async function prepareData(
|
|
app: App,
|
|
): Promise<void> {
|
|
const { localeOptions, encrypt } = getThemeConfig()
|
|
await Promise.all([
|
|
prepareArticleTagColors(app),
|
|
preparedBlogData(app, localeOptions, encrypt),
|
|
prepareSidebar(app, localeOptions),
|
|
prepareEncrypt(app, encrypt),
|
|
prepareIcons(app, localeOptions),
|
|
])
|
|
}
|
|
|
|
export function watchPrepare(
|
|
app: App,
|
|
watchers: any[],
|
|
): void {
|
|
const pagesWatcher = watch('pages/**/*.js', {
|
|
cwd: app.dir.temp(),
|
|
ignoreInitial: true,
|
|
})
|
|
watchers.push(pagesWatcher)
|
|
|
|
pagesWatcher.on('change', () => prepareData(app))
|
|
pagesWatcher.on('add', () => prepareData(app))
|
|
pagesWatcher.on('unlink', () => prepareData(app))
|
|
}
|