@ -3,6 +3,7 @@ import path from 'path'
import c from 'picocolors'
import LRUCache from 'lru-cache'
import { resolveTitleFromToken } from '@mdit-vue/shared'
import { SiteConfig } from './config'
import { PageData , HeadConfig , EXTERNAL_URL_RE , CleanUrlsMode } from './shared'
import { slash } from './utils/slash'
import { getGitTimestamp } from './utils/getGitTimestamp'
@ -37,7 +38,8 @@ export async function createMarkdownToVueRenderFn(
isBuild = false ,
base = '/' ,
includeLastUpdatedData = false ,
cleanUrls : CleanUrlsMode = 'disabled'
cleanUrls : CleanUrlsMode = 'disabled' ,
siteConfig : SiteConfig | null = null
) {
const md = await createMarkdownRenderer ( srcDir , options , base )
pages = pages . map ( ( p ) = > slash ( p . replace ( /\.md$/ , '' ) ) )
@ -131,7 +133,7 @@ export async function createMarkdownToVueRenderFn(
}
}
cons t pageData : PageData = {
le t pageData : PageData = {
title : inferTitle ( md , frontmatter , title ) ,
titleTemplate : frontmatter.titleTemplate as any ,
description : inferDescription ( frontmatter ) ,
@ -144,6 +146,16 @@ export async function createMarkdownToVueRenderFn(
pageData . lastUpdated = await getGitTimestamp ( file )
}
if ( siteConfig ? . transformPageData ) {
const dataToMerge = await siteConfig . transformPageData ( pageData )
if ( dataToMerge ) {
pageData = {
. . . pageData ,
. . . dataToMerge
}
}
}
const vueSrc = [
. . . injectPageDataCode (
sfcBlocks ? . scripts . map ( ( item ) = > item . content ) ? ? [ ] ,