svelte-meta-tags 2.3.4 → 2.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ ## [2.5.1](https://github.com/oekazuma/svelte-meta-tags/compare/v2.5.0...v2.5.1) (2022-03-22)
2
+
3
+ ### Bug Fixes
4
+
5
+ - fix title to be reactive([a19d30b](https://github.com/oekazuma/svelte-meta-tags/commit/a19d30bad9938d78360aea126012bfd7061fff3f))
6
+
7
+ # [2.5.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.4.0...v2.5.0) (2022-03-19)
8
+
9
+ ### Features
10
+
11
+ - add titleTemplate property ([3a252e5](https://github.com/oekazuma/svelte-meta-tags/commit/3a252e5783d04456e32539d8bd3ca7646809fd0d))
12
+
13
+ # [2.4.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.4...v2.4.0) (2022-03-12)
14
+
15
+ ### Features
16
+
17
+ - add a property that allows selection of whether to output JSON-LD in the head or in the body ([91c9c38](https://github.com/oekazuma/svelte-meta-tags/commit/91c9c3861d5cc9168a6b3d90c2cf734f5c03f890))
18
+
19
+ ## [2.3.4](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.3...v2.3.4) (2022-03-03)
20
+
21
+ ### Bug Fixes
22
+
23
+ - add pnpm build to release command ([1c01f61](https://github.com/oekazuma/svelte-meta-tags/commit/1c01f619c5cd1dee51c58f4067fd315907fb4753))
24
+
1
25
  ## [2.3.3](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.2...v2.3.3) (2022-03-03)
2
26
 
3
27
  ### Bug Fixes
package/JsonLd.svelte CHANGED
@@ -1,11 +1,18 @@
1
1
  <script>
2
+ export let output = 'head';
2
3
  export let schema = undefined;
3
4
  </script>
4
5
 
5
6
  <svelte:head>
6
- {#if schema}
7
+ {#if schema && output === 'head'}
7
8
  {@html `<script type="application/ld+json">${
8
9
  JSON.stringify({ '@context': 'https://schema.org', ...schema }) + '<'
9
10
  }/script>`}
10
11
  {/if}
11
12
  </svelte:head>
13
+
14
+ {#if schema && output === 'body'}
15
+ {@html `<script type="application/ld+json">${
16
+ JSON.stringify({ '@context': 'https://schema.org', ...schema }) + '<'
17
+ }/script>`}
18
+ {/if}
package/MetaTags.svelte CHANGED
@@ -1,5 +1,6 @@
1
1
  <script>
2
2
  export let title = '';
3
+ export let titleTemplate = '';
3
4
  export let noindex = false;
4
5
  export let nofollow = false;
5
6
  export let robotsProps = undefined;
@@ -13,6 +14,8 @@
13
14
  export let additionalMetaTags = undefined;
14
15
  export let additionalLinkTags = undefined;
15
16
 
17
+ $: updatedTitle = titleTemplate ? titleTemplate.replace(/%s/g, title) : title;
18
+
16
19
  let robotsParams = '';
17
20
  if (robotsProps) {
18
21
  const {
@@ -39,7 +42,7 @@
39
42
  </script>
40
43
 
41
44
  <svelte:head>
42
- <title>{title}</title>
45
+ <title>{updatedTitle}</title>
43
46
 
44
47
  <meta
45
48
  name="robots"
@@ -211,8 +214,8 @@
211
214
  {/if}
212
215
  {/if}
213
216
 
214
- {#if openGraph.title || title}
215
- <meta property="og:title" content={openGraph.title || title} />
217
+ {#if openGraph.title || updatedTitle}
218
+ <meta property="og:title" content={openGraph.title || updatedTitle} />
216
219
  {/if}
217
220
 
218
221
  {#if openGraph.description || description}
package/README.md CHANGED
@@ -19,7 +19,8 @@ This library is inspired by [next-seo](https://github.com/garmeeh/next-seo)
19
19
 
20
20
  - [Installing](#-installing)
21
21
  - [Usage](#-usage)
22
- - [Properties](#properties)
22
+ - [MetaTags Properties](#metatags-properties)
23
+ - [Title Template](#title-template)
23
24
  - [Twitter](#twitter)
24
25
  - [Facebook](#facebook)
25
26
  - [robotsProps](#robotsprops)
@@ -35,6 +36,7 @@ This library is inspired by [next-seo](https://github.com/garmeeh/next-seo)
35
36
  - [Profile](#profile)
36
37
  - [JSON-LD](#json-ld)
37
38
  - [Using schema-dts](#using-schema-dts)
39
+ - [JSON-LD Properties](#json-ld-properties)
38
40
  - [JSON-LD Examples](#json-ld-examples)
39
41
  - [Article](#article)
40
42
  - [Breadcrumb](#breadcrumb)
@@ -84,6 +86,7 @@ pnpm add -D svelte-meta-tags
84
86
 
85
87
  <MetaTags
86
88
  title="Using More of Config"
89
+ titleTemplate="%s | Svelte Meta Tags"
87
90
  description="This example uses more of the available config options."
88
91
  canonical="https://www.canonical.ie/"
89
92
  openGraph={{
@@ -123,11 +126,12 @@ pnpm add -D svelte-meta-tags
123
126
  />
124
127
  ```
125
128
 
126
- ### Properties
129
+ ### MetaTags Properties
127
130
 
128
131
  | Property | Type | Description |
129
132
  | ---------------------------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
130
133
  | `title` | string | Sets the page meta title. |
134
+ | `titleTemplate` | string | Allows you to set default title template that will be added to your title [More Info](#title-template) |
131
135
  | `noindex` | boolean (default false) | Sets whether page should be indexed or not |
132
136
  | `nofollow` | boolean (default false) | Sets whether page should be followed or not |
133
137
  | `additionRobotsProps` | Object | Set the more meta information for the `X-Robots-Tag` [More Info](#robotsprops) |
@@ -169,6 +173,22 @@ pnpm add -D svelte-meta-tags
169
173
  | `openGraph.article.section` | string | A high-level section name. E.g. Technology |
170
174
  | `openGraph.article.tags` | string[] | Tag words associated with this article. |
171
175
 
176
+ #### Title Template
177
+
178
+ Replaces `%s` with your title string
179
+
180
+ ```
181
+ title = 'This is my title'
182
+ titleTemplate = 'Svelte Meta Tags | %s'
183
+ // outputs: Svelte Meta Tags | This is my title
184
+ ```
185
+
186
+ ```
187
+ title = 'This is my title'
188
+ titleTemplate = '%s | Svelte Meta Tags'
189
+ // outputs: This is my title | Svelte Meta Tags
190
+ ```
191
+
172
192
  #### Twitter
173
193
 
174
194
  ```js
@@ -564,6 +584,13 @@ It is also possible to use multiple `<JsonLd />` components in a single page.
564
584
 
565
585
  This plugin uses [schema-dts](https://github.com/google/schema-dts), so it also provides types other than the usage examples below.
566
586
 
587
+ ### JSON-LD Properties
588
+
589
+ | Property | Type | Description |
590
+ | -------- | --------------------- | ---------------------------------------------------------------------------------------------------- |
591
+ | `output` | string (default head) | Sets whether json-ld is output to `<head>` or `<body>`. Possible values are either `head` or `body`. |
592
+ | `schema` | Object | Data in `ld+json` format. [See Examples](#json-ld-examples) |
593
+
567
594
  ### JSON-LD Examples
568
595
 
569
596
  #### Article
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-meta-tags",
3
- "version": "2.3.4",
3
+ "version": "2.5.1",
4
4
  "description": "Svelte Meta Tags is a plugin that makes managing your SEO easier in Svelte projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,36 +21,36 @@
21
21
  "schema-dts": "1.1.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@commitlint/cli": "16.2.1",
24
+ "@commitlint/cli": "16.2.3",
25
25
  "@commitlint/config-conventional": "16.2.1",
26
26
  "@semantic-release/changelog": "6.0.1",
27
27
  "@semantic-release/git": "10.0.1",
28
- "@sveltejs/adapter-auto": "1.0.0-next.30",
29
- "@sveltejs/kit": "1.0.0-next.291",
30
- "@typescript-eslint/eslint-plugin": "5.13.0",
31
- "@typescript-eslint/parser": "5.13.0",
32
- "cypress": "9.5.1",
33
- "eslint": "8.10.0",
28
+ "@sveltejs/adapter-auto": "1.0.0-next.33",
29
+ "@sveltejs/kit": "1.0.0-next.301",
30
+ "@typescript-eslint/eslint-plugin": "5.16.0",
31
+ "@typescript-eslint/parser": "5.16.0",
32
+ "cypress": "9.5.2",
33
+ "eslint": "8.11.0",
34
34
  "eslint-config-prettier": "8.5.0",
35
35
  "eslint-plugin-cypress": "2.12.1",
36
36
  "eslint-plugin-svelte3": "3.4.1",
37
37
  "husky": "7.0.4",
38
- "lint-staged": "12.3.4",
39
- "prettier": "2.5.1",
38
+ "lint-staged": "12.3.7",
39
+ "prettier": "2.6.0",
40
40
  "prettier-plugin-svelte": "2.6.0",
41
41
  "semantic-release": "19.0.2",
42
42
  "svelte": "3.46.4",
43
- "svelte-check": "2.4.5",
43
+ "svelte-check": "2.4.6",
44
44
  "svelte-preprocess": "4.10.4",
45
- "svelte2tsx": "0.5.5",
45
+ "svelte2tsx": "0.5.6",
46
46
  "tslib": "2.3.1",
47
- "typescript": "~4.5.5"
47
+ "typescript": "4.6.2"
48
48
  },
49
49
  "peerDependencies": {
50
50
  "svelte": "^3.39.0"
51
51
  },
52
52
  "lint-staged": {
53
- "*.{js,ts,svelte,md,html,css,json}": "pnpm format",
53
+ "*.{js,ts,cjs,svelte,md,html,css,json,yml,yaml}": "pnpm format",
54
54
  "*.{js,ts,svelte}": [
55
55
  "pnpm lint",
56
56
  "pnpm check"
@@ -93,4 +93,4 @@
93
93
  ".": "./index.js"
94
94
  },
95
95
  "svelte": "./index.js"
96
- }
96
+ }
package/types.d.ts CHANGED
@@ -138,6 +138,7 @@ export interface LinkTag {
138
138
 
139
139
  export interface MetaTagsProps {
140
140
  title?: string;
141
+ titleTemplate?: string;
141
142
  noindex?: boolean;
142
143
  nofollow?: boolean;
143
144
  robotsProps?: AdditionalRobotsProps;
@@ -153,5 +154,6 @@ export interface MetaTagsProps {
153
154
  }
154
155
 
155
156
  export interface JsonLdProps {
157
+ output?: 'head' | 'body';
156
158
  schema?: Thing | WithContext<Thing>;
157
159
  }