From f8ddeaf6eda2f158d88312a885eef32f19651f20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Mon, 11 Sep 2017 12:13:48 +0200 Subject: [PATCH] Update titleTemplate --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 771c1ca..7d7d49f 100644 --- a/README.md +++ b/README.md @@ -342,7 +342,7 @@ Maps to the inner-text value of the `` element. <title>Foo Bar ``` -#### `titleTemplate` (String) +#### `titleTemplate` (String | Function) The value of `title` will be injected into the `%s` placeholder in `titleTemplate` before being rendered. The original title will be available on `metaInfo.titleChunk`. @@ -359,6 +359,15 @@ The value of `title` will be injected into the `%s` placeholder in `titleTemplat Foo Bar - Baz ``` +The property can also be a function (from [v1.2.0](https://github.com/declandewet/vue-meta/releases/tag/v1.2.0)): + +```js +titleTemplate: (titleChunk) => { + // If undefined or blank then we don't need the hyphen + return titleChunk ? `${titleChunk} - Site Title` : 'Site Title'; +} +``` + #### `htmlAttrs` (Object) Each **key:value** maps to the equivalent **attribute:value** of the `` element.