diff --git a/plugins/blog/plugin-blog/src/node/getPagesMap.ts b/plugins/blog/plugin-blog/src/node/getPagesMap.ts index b0ddde599c..a4de9a487c 100644 --- a/plugins/blog/plugin-blog/src/node/getPagesMap.ts +++ b/plugins/blog/plugin-blog/src/node/getPagesMap.ts @@ -3,12 +3,17 @@ import type { App, Page } from 'vuepress/core' export type PagesMap = Record export const getPageMap = ( - { pages }: App, + app: App, filter: (page: Page) => boolean, ): PagesMap => { - const pagesMap: PagesMap = {} + const pagesMap: PagesMap = { + '/': [], + ...Object.fromEntries( + Object.keys(app.siteData.locales).map((localePath) => [localePath, []]), + ), + } - pages + app.pages .filter( (page) => filter(page) && @@ -16,7 +21,7 @@ export const getPageMap = ( page.path.substring(page.pathLocale.length - 1) !== '/404.html', ) .forEach((page) => { - ;(pagesMap[page.pathLocale] ??= []).push(page) + pagesMap[page.pathLocale].push(page) }) return pagesMap