Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/@vuepress/client/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const createVueApp: CreateVueAppFunction = async () => {
)
const pageFrontmatter = computed(() => resolvePageFrontmatter(pageData.value))
const pageHeadTitle = computed(() =>
resolvePageHeadTitle(pageData.value, siteLocaleData.value)
resolvePageHeadTitle.value(pageData.value, siteLocaleData.value)
)
const pageHead = computed(() =>
resolvePageHead(
Expand Down
15 changes: 9 additions & 6 deletions packages/@vuepress/client/src/injections/pageHeadTitle.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { inject } from 'vue'
import { inject, ref } from 'vue'
import type { ComputedRef, InjectionKey } from 'vue'
import type { PageData } from './pageData'
import type { SiteLocaleData } from './siteLocaleData'
Expand All @@ -19,9 +19,12 @@ export const usePageHeadTitle = (): PageHeadTitleRef => {
}

/**
* Title to displayed in `<head>` tag
* A function used for resolving the content of `head > title` tag
*
* This function is stored in a `ref`, so that users could change the
* function to customize the content of title tag.
*/
export const resolvePageHeadTitle = (
page: PageData,
siteLocale: SiteLocaleData
): PageHeadTitle => `${page.title ? `${page.title} | ` : ``}${siteLocale.title}`
export const resolvePageHeadTitle = ref(
(page: PageData, siteLocale: SiteLocaleData) =>
`${page.title ? `${page.title} | ` : ``}${siteLocale.title}`
)