Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ramesh-dada opened this issue Aug 3, 2021 · 4 comments
Closed

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

ramesh-dada opened this issue Aug 3, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@ramesh-dada
Copy link

ramesh-dada commented Aug 3, 2021

I want to remove my site name from every page I don’t want it every where I just want page title

I want to remove the highlighted part in image It will be great if we can do some configuration in config file.

@meteorlxy
Copy link
Member

This problem also exists in VuePress v1.

I agree that we should provide a more flexible way to customize the content of <title> tag.

@meteorlxy meteorlxy added the enhancement New feature or request label Aug 3, 2021
@meteorlxy
Copy link
Member

What about providing a new client API to be called in clientAppEnhance.ts ?

For example:

import {
  defineClientAppEnhance,
  setResolvePageHeadTitle,
} from '@vuepress/client'

export default defineClientAppEnhance(() => {
  // this is the default behavior
  setResolvePageHeadTitle(
    (page, siteLocale) =>
      `${page.title ? `${page.title} | ` : ``}${siteLocale.title}`
  )

  // users can customize this way
  setResolvePageHeadTitle((page) => page.title)
})

@meteorlxy
Copy link
Member

It's not supported now, but you might modify it manually in clientAppSetup like this:

import { defineClientAppSetup, usePageData } from '@vuepress/client'
import { nextTick } from 'vue'
import { useRouter } from 'vue-router'

export default defineClientAppSetup(() => {
  const router = useRouter()
  const page = usePageData()
  const changeTitle = (): void => {
    if (document) {
      nextTick(() => {
        document.title = page.value.title
      })
    }
  }

  changeTitle()
  router.afterEach(() => changeTitle())
})

@ramesh-dada
Copy link
Author

Can you please tell me location of this file after 1 hour I gave up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants