fix(theme): internal deps

This commit is contained in:
pengzhanbo 2022-10-16 03:38:30 +08:00
parent 46f6277dfb
commit 728a6868e6
8 changed files with 16 additions and 16 deletions

View File

@ -4,7 +4,7 @@ export interface BaiduTongjiOptions {
key?: string
}
export const baiduTongjiPlugin = ({ key }: BaiduTongjiOptions): Plugin => {
export const baiduTongjiPlugin = ({ key = '' }: BaiduTongjiOptions): Plugin => {
return {
name: '@vuepress-plume/vuepress-plugin-baidu-tongji',
extendsPage: (page) => {

View File

@ -1,4 +1,4 @@
import { postIndex as postIndexRaw } from '@internal/postIndex.js'
import { postIndex as postIndexRaw } from '@internal/postIndex'
import { ref } from 'vue'
import type { Ref } from 'vue'
import type { PostIndex } from '../../shared/index.js'

View File

@ -1,4 +1,4 @@
import { sidebarIndex as sidebarIndexRaw } from '@internal/sidebarIndex.js'
import { sidebarIndex as sidebarIndexRaw } from '@internal/sidebarIndex'
import { usePageFrontmatter } from '@vuepress/client'
import { computed, ref } from 'vue'
import type { ComputedRef, Ref } from 'vue'

View File

@ -8,13 +8,13 @@ declare const __VUEPRESS_DEV__: boolean
declare const __VUEPRESS_SSR__: boolean
declare const __VUE_HMR_RUNTIME__: Record<string, unknown>
declare module '@internal/postIndex.js' {
declare module '@internal/postIndex' {
import type { PostIndex } from '../shared'
const postIndex: PostIndex
export { postIndex }
}
declare module '@internal/sidebarIndex.js' {
declare module '@internal/sidebarIndex' {
import type { SidebarOptions } from '../shared'
const sidebarIndex: Record<string, SidebarOptions>
export { sidebarIndex }

View File

@ -3,12 +3,12 @@ import type { PlumeThemeLocaleOptions } from '../../shared/index.js'
import { preparedPostIndex, watchPostIndex } from './postIndex.js'
import { preparedSidebarIndex, watchSidebarIndex } from './sidebarIndex.js'
export const onPrepared = (
export const onPrepared = async (
app: App,
localeOption: PlumeThemeLocaleOptions
): void => {
preparedPostIndex(app, localeOption)
preparedSidebarIndex(app, localeOption)
): Promise<void> => {
await preparedPostIndex(app, localeOption)
await preparedSidebarIndex(app, localeOption)
}
export const preparedWatch = (

View File

@ -24,10 +24,10 @@ if (import.meta.hot) {
}
`
export const preparedPostIndex = (
export const preparedPostIndex = async (
app: App,
localeOption: PlumeThemeLocaleOptions
): void => {
): Promise<void> => {
const postIndex: PostIndex = (app.pages as Page<PlumeThemePageData>[])
.filter((page) => {
return (
@ -68,7 +68,7 @@ export const postIndex = ${JSON.stringify(postIndex, null, 2)}
content += HMR_CODE
}
app.writeTemp('internal/postIndex.js', content)
await app.writeTemp('internal/postIndex.js', content)
}
export const watchPostIndex = (

View File

@ -32,10 +32,10 @@ interface NotePage {
link: string
}
export const preparedSidebarIndex = (
export const preparedSidebarIndex = async (
app: App,
{ notes }: PlumeThemeLocaleOptions
): void => {
): Promise<void> => {
const pages = app.pages as Page<PlumeThemePageData>[]
if (notes === false) return
const {
@ -71,7 +71,7 @@ export const sidebarIndex = ${JSON.stringify(sidebarMap, null, 2)}
content += HMR_CODE
}
app.writeTemp('internal/sidebarIndex.js', content)
await app.writeTemp('internal/sidebarIndex.js', content)
}
function noteSidebar(

View File

@ -30,7 +30,7 @@ export const themePlume = ({
formatFrontmatter()
await createPage(app, localeOption)
},
onPrepared: (app) => onPrepared(app, localeOption),
onPrepared: async (app) => await onPrepared(app, localeOption),
extendsPage: (page: Page<Partial<PlumeThemePageData>>) =>
extendsPage(page, localeOption),
onWatched: (app, watchers) => {