Skip to content

Conversation

@meteorlxy
Copy link
Member

Close #338

This PR allows users to customize the content of <title> tag in this way:

// clientAppEnhance.ts
import { defineClientAppEnhance, resolvePageHeadTitle } from '@vuepress/client'

export default defineClientAppEnhance(() => {
  resolvePageHeadTitle.value = (page, site) => `${page.title} | ${site.title}`
})

@meteorlxy
Copy link
Member Author

cc @shigma @Mister-Hope @jiazengp

@shigma
Copy link
Member

shigma commented Aug 18, 2021

To me this feature is more like a configuration. It will be quite annoying if one has to write lots of different composition functions for every similar configurations.

I suggest that we only provide a simple client API that exposes all configurations.

// clientAppEnhance.ts
import { defineClientAppEnhance, useClientAppConfig } from '@vuepress/client'

export default defineClientAppEnhance(() => {
  const config = useClientAppConfig() // returns reactive object
  config.resolvePageHeadTitle = (page, site) => `${page.title} | ${site.title}`
})

or we can even provide a syntactic sugar for the code above:

// clientAppEnhance.ts
import { defineClientAppEnhance } from '@vuepress/client'

export default defineClientAppEnhance({
  resolvePageHeadTitle: (page, site) => `${page.title} | ${site.title}`,
})

In that case we can easily extend our client app configuration in the future.

@meteorlxy
Copy link
Member Author

@shigma Sounds good to me.

What other config can be put into it (or in the future) ?

@Mister-Hope
Copy link
Member

My opinion:

I am not coming up any idea what config need to added on the client side, but I think maybe we could extend more config in user config or core.

Some of them already appears in issue or dicussion, and are reasonable.

E.g.:

  • Desides whether accessing other pages data sync or async. Small docs or blog sites could benefit from visiting a sync pages array. And large sites can increase speed when asynchronously load each page data.

  • add darkmode comparability and its status to core. These will make the srr render result default to dark possible, and help hold the same config and behaviour across plugins and themes.

@drewcook
Copy link

I'd like to add that there may be complexity when using extended page data. Please see my issue here - #487

How will this PR address, if at all, using extended page data into defineClientAppEnhance?

@meteorlxy meteorlxy closed this Jan 22, 2022
@Mister-Hope Mister-Hope deleted the meteorxyliu/page-head-title branch April 17, 2022 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature request] Allow us to Remove site name from page title

5 participants