From 3a252e5783d04456e32539d8bd3ca7646809fd0d Mon Sep 17 00:00:00 2001 From: "oe.kazuma" Date: Sun, 20 Mar 2022 06:41:58 +0900 Subject: [PATCH] feat: add titleTemplate property --- README.md | 17 +++++++++++++++++ src/lib/MetaTags.svelte | 5 +++++ src/lib/types.d.ts | 1 + src/routes/index.svelte | 3 ++- 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7feac94..e731204 100644 --- a/README.md +++ b/README.md @@ -129,6 +129,7 @@ pnpm add -D svelte-meta-tags | Property | Type | Description | | ---------------------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `title` | string | Sets the page meta title. | +| `titleTemplate` | string | Allows you to set default title template that will be added to your title [More Info](#title-template) | | `noindex` | boolean (default false) | Sets whether page should be indexed or not | | `nofollow` | boolean (default false) | Sets whether page should be followed or not | | `additionRobotsProps` | Object | Set the more meta information for the `X-Robots-Tag` [More Info](#robotsprops) | @@ -170,6 +171,22 @@ pnpm add -D svelte-meta-tags | `openGraph.article.section` | string | A high-level section name. E.g. Technology | | `openGraph.article.tags` | string[] | Tag words associated with this article. | +#### Title Template + +Replaces `%s` with your title string + +```js +title = 'This is my title'; +titleTemplate = 'Svelte Meta Tags | %s'; +// outputs: Svelte Meta Tags | This is my title +``` + +```js +title = 'This is my title'; +titleTemplate = '%s | Svelte Meta Tags'; +// outputs: This is my title | Svelte Meta Tags +``` + #### Twitter ```js diff --git a/src/lib/MetaTags.svelte b/src/lib/MetaTags.svelte index 03f1b52..acd65ce 100644 --- a/src/lib/MetaTags.svelte +++ b/src/lib/MetaTags.svelte @@ -1,5 +1,6 @@