-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Customizing the <title> meta data pattern #296
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
Comments
You can't... and shouldn't. Use configurations like YAML front matter. |
I don't get it? Please let me rephrase my request: YAML front matter does not give me the freedom to define a pattern for the siteTitle/pageTitle constellation used in the |
I don't get it either. What exactly are you trying to do other than giving the page a title? You want to dynamically generate the title to use in JavaScript? Why? What is it that specifically requires JavaScript? Maybe give an example? When making feature requests, realize that others don't have the context of what exactly you are trying to do because... well, I'm not you. |
First of all sorry for the misunderstanding. I wanted to customize the way E.g. the order and the separator character. Is there a way to customize that? From what I saw, this behavior is hardcoded in the Hope this is understandable. Thanks. |
@MartinMuzatko lol, I understand what you mean at the first stage, but you took a wrong way to describe it. No wonder Evan confused about that. Lines 52 to 64 in 5023d19
Look at current One may want the In my opinion, this is theme specific. If you choose to use default theme, you have to use @yyx990803 So I propose to define |
Thank you @meteorlxy :) |
What about a The default function could be something like: const formatTitle = (siteTitle, pageTitle) => {
return siteTitle
? pageTitle
? `${siteTitle} | ${pageTitle}`
: siteTitle
: pageTitle || 'VuePress'
} In ...
$title () {
const page = this.$page
const pageTitle = page.frontmatter.home ? null : (
page.frontmatter.title || // explicit title
page.title // inferred title
)
return this.$site.formatTitle(this.$siteTitle, pageTitle)
},
... |
In fact, you can overwrite Emmm will the |
@meteorlxy I'm not exactly sure what you mean by including From my perspective, because configuring the Regarding the case @MartinMuzatko mentioned, it seems like if we just include |
You can override the // .vuepress/enhanceApp.js
export default ({ Vue }) => {
Vue.mixin({
computed: {
$title () {
return 'VUE'
}
}
})
} cc @yyx990803 |
So yes, I am writing a custom theme... Where do I put extra logic around generating title meta attribute? I want to build it from more than just site title and page title. |
I've been working on this recently. One option is to add it in the entry Layout of the theme, something on this line:
...
export default {
components: { Header, Footer },
computed: {
$title() {
if (this.$frontmatter.home) {
return this.$siteTitle;
} else {
return `${this.$page.title} | ${this.$frontmatter.custom_value}`;
}
}
}
}; |
Hello!
I'm trying to override the behavior of some dataMixin variables, like the
$title
.When setting
this.$title
inHome.vue
screated
method, I get the following error:Is there a way to override this mechanism?
I'd prefer title - siteTitle
The text was updated successfully, but these errors were encountered: