Merge branch 'main' into feature/leanCloud
This commit is contained in:
commit
1af31ef0d2
@ -19,7 +19,7 @@ const loadEnvConfig = (): Record<string, string | undefined> => {
|
||||
|
||||
export interface NetlifyServe {
|
||||
host: string
|
||||
cancel: () => void
|
||||
close: () => void
|
||||
}
|
||||
export const netlifyServe = async ({
|
||||
directory,
|
||||
@ -49,6 +49,6 @@ export const netlifyServe = async ({
|
||||
|
||||
return {
|
||||
host: 'http://localhost:' + port,
|
||||
cancel,
|
||||
close: () => cancel(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,8 +75,8 @@ export const netlifyFunctionsPlugin = (
|
||||
): Plugin => {
|
||||
return (app: App) => {
|
||||
const opts = initOptions(app, options)
|
||||
cache.options = opts
|
||||
let server: NetlifyServe
|
||||
cache.options = opts
|
||||
return {
|
||||
name: '@vuepress-plume/vuepress-plugin-netlify-functions',
|
||||
|
||||
@ -85,12 +85,14 @@ export const netlifyFunctionsPlugin = (
|
||||
if (!app.env.isBuild) {
|
||||
// 初始化用户侧的 functions
|
||||
await initialFunctions(app, opts)
|
||||
if (!server) {
|
||||
server = await netlifyServe(opts)
|
||||
}
|
||||
server = await netlifyServe(opts)
|
||||
}
|
||||
},
|
||||
|
||||
onWatched: (app, watchers) => {
|
||||
watchers.push(server)
|
||||
},
|
||||
|
||||
extendsBundlerOptions: (bundlerOption, app: App) => {
|
||||
extendsBundlerOptions(bundlerOption, app, opts, server.host)
|
||||
},
|
||||
|
||||
@ -16,12 +16,16 @@ import { useThemeLocaleData } from '../composables'
|
||||
const route = useRoute()
|
||||
const frontmatter = usePageFrontmatter()
|
||||
const themeLocale = useThemeLocaleData()
|
||||
const isHome = computed(() => {
|
||||
return route.path === '/' && frontmatter.value.home
|
||||
})
|
||||
|
||||
const pageType = computed(() => {
|
||||
return (frontmatter.value.pageType as string) || ''
|
||||
const matter = frontmatter.value
|
||||
let type = ''
|
||||
if (matter.home) {
|
||||
type = 'home'
|
||||
} else {
|
||||
type = (frontmatter.value.pageType as string) || ''
|
||||
}
|
||||
return type
|
||||
})
|
||||
|
||||
const footer = computed(() => {
|
||||
@ -32,6 +36,7 @@ const pageMap = {
|
||||
category: Category,
|
||||
archive: Archive,
|
||||
tag: Tag,
|
||||
home: Home,
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@ -48,8 +53,7 @@ const pageMap = {
|
||||
</slot>
|
||||
<AsideNavbar />
|
||||
<slot name="page">
|
||||
<Home v-if="isHome" />
|
||||
<Component :is="pageMap[pageType]" v-else-if="pageType" />
|
||||
<Component :is="pageMap[pageType]" v-if="pageType" />
|
||||
<Page v-else>
|
||||
<template #top>
|
||||
<slot name="page-top" />
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user