svelte-meta-tags 2.6.5 → 2.7.0

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/README.md CHANGED
@@ -574,7 +574,7 @@ JSON-LD allows for more customized and richer display, such as in search results
574
574
 
575
575
  To discover all the different content types that JSON-LD offers, go to: https://developers.google.com/search/docs/guides/search-gallery
576
576
 
577
- It is also possible to use multiple `<JsonLd />` components in a single page.
577
+ Tips: If you want to handle multiple JSON-LDs on one page, pass an array to the `schema`.
578
578
 
579
579
  ### Using `schema-dts`
580
580
 
@@ -784,6 +784,68 @@ This plugin uses [schema-dts](https://github.com/google/schema-dts), so it provi
784
784
  />
785
785
  ```
786
786
 
787
+ ### JSON-LD Multiple Examples
788
+
789
+ ```svelte
790
+ <script>
791
+ import { JsonLd } from 'svelte-meta-tags';
792
+ </script>
793
+
794
+ <JsonLd
795
+ schema={[
796
+ {
797
+ '@type': 'BreadcrumbList',
798
+ itemListElement: [
799
+ {
800
+ '@type': 'ListItem',
801
+ position: 1,
802
+ name: 'Books',
803
+ item: 'https://example.com/books'
804
+ },
805
+ {
806
+ '@type': 'ListItem',
807
+ position: 2,
808
+ name: 'Science Fiction',
809
+ item: 'https://example.com/books/sciencefiction'
810
+ },
811
+ {
812
+ '@type': 'ListItem',
813
+ position: 3,
814
+ name: 'Award Winners'
815
+ }
816
+ ]
817
+ },
818
+ {
819
+ '@type': 'NewsArticle',
820
+ mainEntityOfPage: {
821
+ '@type': 'WebPage',
822
+ '@id': 'https://google.com/article'
823
+ },
824
+ headline: 'Article headline',
825
+ image: [
826
+ 'https://example.com/photos/1x1/photo.jpg',
827
+ 'https://example.com/photos/4x3/photo.jpg',
828
+ 'https://example.com/photos/16x9/photo.jpg'
829
+ ],
830
+ datePublished: '2015-02-05T08:00:00+08:00',
831
+ dateModified: '2015-02-05T09:20:00+08:00',
832
+ author: {
833
+ '@type': 'Person',
834
+ name: 'John Doe'
835
+ },
836
+ publisher: {
837
+ '@type': 'Organization',
838
+ name: 'Google',
839
+ logo: {
840
+ '@type': 'ImageObject',
841
+ url: 'https://google.com/logo.jpg'
842
+ }
843
+ }
844
+ }
845
+ ]}
846
+ />
847
+ ```
848
+
787
849
  ## Types
788
850
 
789
851
  The following types can be imported from `svelte-meta-tags`
@@ -814,7 +876,7 @@ interface MetaTagsProps {
814
876
  ```ts
815
877
  interface JsonLdProps {
816
878
  output?: 'head' | 'body';
817
- schema?: Thing | WithContext<Thing>;
879
+ schema?: Thing | WithContext<Thing> | Thing[] | WithContext<Thing>[];
818
880
  }
819
881
  ```
820
882
 
@@ -3,10 +3,14 @@
3
3
  export let schema = {};
4
4
 
5
5
  $: isValid = schema && typeof schema === 'object';
6
- $: json = `${'<scri' + 'pt type="application/ld+json">'}${JSON.stringify({
7
- '@context': 'https://schema.org',
8
- ...schema
9
- })}${'</scri' + 'pt>'}`;
6
+
7
+ function createSchema(schema) {
8
+ const addContext = (context) => ({ '@context': 'https://schema.org', ...context });
9
+
10
+ return Array.isArray(schema) ? schema.map((context) => addContext(context)) : addContext(schema);
11
+ }
12
+
13
+ $: json = `${'<scri' + 'pt type="application/ld+json">'}${JSON.stringify(createSchema(schema))}${'</scri' + 'pt>'}`;
10
14
  </script>
11
15
 
12
16
  <svelte:head>
@@ -150,5 +150,5 @@ export interface MetaTagsProps {
150
150
 
151
151
  export interface JsonLdProps {
152
152
  output?: 'head' | 'body';
153
- schema?: Thing | WithContext<Thing>;
153
+ schema?: Thing | WithContext<Thing> | Thing[] | WithContext<Thing>[];
154
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-meta-tags",
3
- "version": "2.6.5",
3
+ "version": "2.7.0",
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",
@@ -17,37 +17,78 @@
17
17
  "type": "git",
18
18
  "url": "https://github.com/oekazuma/svelte-meta-tags"
19
19
  },
20
+ "scripts": {
21
+ "dev": "vite dev",
22
+ "build": "vite build",
23
+ "preview": "vite preview",
24
+ "package": "svelte-kit sync && svelte-package && publint",
25
+ "prepare": "husky install",
26
+ "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
27
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
28
+ "lint": "prettier --plugin-search-dir . --check . --cache && eslint .",
29
+ "format": "prettier --plugin-search-dir . --write . --cache",
30
+ "test": "playwright test"
31
+ },
20
32
  "dependencies": {
21
- "schema-dts": "^1.1.0"
33
+ "schema-dts": "^1.1.2"
22
34
  },
23
35
  "devDependencies": {
24
- "@playwright/test": "^1.29.2",
25
- "@sveltejs/adapter-auto": "^1.0.2",
26
- "@sveltejs/kit": "^1.1.4",
27
- "@sveltejs/package": "^1.0.2",
28
- "@typescript-eslint/eslint-plugin": "^5.48.2",
29
- "@typescript-eslint/parser": "^5.48.2",
30
- "eslint": "^8.32.0",
31
- "eslint-config-prettier": "^8.6.0",
36
+ "@playwright/test": "^1.31.2",
37
+ "@sveltejs/adapter-auto": "^2.0.0",
38
+ "@sveltejs/kit": "^1.11.0",
39
+ "@sveltejs/package": "^2.0.2",
40
+ "@typescript-eslint/eslint-plugin": "^5.54.1",
41
+ "@typescript-eslint/parser": "^5.54.1",
42
+ "eslint": "^8.35.0",
43
+ "eslint-config-prettier": "^8.7.0",
32
44
  "eslint-plugin-svelte3": "^4.0.0",
33
45
  "husky": "^8.0.3",
34
- "lint-staged": "^13.1.0",
35
- "prettier": "^2.8.3",
46
+ "lint-staged": "^13.1.2",
47
+ "prettier": "^2.8.4",
36
48
  "prettier-plugin-svelte": "^2.9.0",
37
- "svelte": "^3.55.1",
38
- "svelte-check": "^3.0.2",
39
- "tslib": "^2.4.1",
40
- "typescript": "^4.9.4",
41
- "vite": "^4.0.4"
49
+ "publint": "^0.1.10",
50
+ "svelte": "^3.56.0",
51
+ "svelte-check": "^3.1.0",
52
+ "tslib": "^2.5.0",
53
+ "typescript": "^4.9.5",
54
+ "vite": "^4.1.4"
42
55
  },
43
56
  "peerDependencies": {
44
57
  "svelte": "^3.44.0"
45
58
  },
46
59
  "exports": {
47
60
  "./package.json": "./package.json",
48
- "./JsonLd.svelte": "./JsonLd.svelte",
49
- "./MetaTags.svelte": "./MetaTags.svelte",
50
- ".": "./index.js"
61
+ "./JsonLd.svelte": {
62
+ "types": "./dist/JsonLd.svelte.d.ts",
63
+ "svelte": "./dist/JsonLd.svelte",
64
+ "default": "./dist/JsonLd.svelte"
65
+ },
66
+ "./MetaTags.svelte": {
67
+ "types": "./dist/MetaTags.svelte.d.ts",
68
+ "svelte": "./dist/MetaTags.svelte",
69
+ "default": "./dist/MetaTags.svelte"
70
+ },
71
+ ".": {
72
+ "types": "./dist/index.d.ts",
73
+ "svelte": "./dist/index.js",
74
+ "default": "./dist/index.js"
75
+ }
51
76
  },
52
- "svelte": "./index.js"
53
- }
77
+ "files": [
78
+ "dist"
79
+ ],
80
+ "svelte": "./dist/index.js",
81
+ "typesVersions": {
82
+ ">4.0": {
83
+ "JsonLd.svelte": [
84
+ "./dist/JsonLd.svelte.d.ts"
85
+ ],
86
+ "MetaTags.svelte": [
87
+ "./dist/MetaTags.svelte.d.ts"
88
+ ],
89
+ "index": [
90
+ "./dist/index.d.ts"
91
+ ]
92
+ }
93
+ }
94
+ }
package/CHANGELOG.md DELETED
@@ -1,181 +0,0 @@
1
- ## [2.6.4](https://github.com/oekazuma/svelte-meta-tags/compare/v2.6.3...v2.6.4) (2022-11-16)
2
-
3
- - add Svelte to peerDependencies([2d99894](https://github.com/oekazuma/svelte-meta-tags/commit/2d9989454e5ed51d9f4d0d9e9300ba933d0c0ffa))
4
-
5
- ## [2.6.3](https://github.com/oekazuma/svelte-meta-tags/compare/v2.6.2...v2.6.3) (2022-08-31)
6
-
7
- - add schema-dts to dependencies([9824e38](https://github.com/oekazuma/svelte-meta-tags/commit/9824e388728e37009aa06f56642ec4a2b9520921))
8
-
9
- ## [2.6.2](https://github.com/oekazuma/svelte-meta-tags/compare/v2.6.1...v2.6.2) (2022-08-11)
10
-
11
- - trim production dependencies([2008183](https://github.com/oekazuma/svelte-meta-tags/commit/2008183b0a712cc6288e188cabdb14c85f93b0ee))
12
-
13
- ## [2.6.1](https://github.com/oekazuma/svelte-meta-tags/compare/v2.6.0...v2.6.1) (2022-05-27)
14
-
15
- - clean up JSON-LD ([16d107c](https://github.com/oekazuma/svelte-meta-tags/commit/16d107c09546ffd6b2f8312a6851d46bd0da6ae1))
16
-
17
- # [2.6.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.5.5...v2.6.0) (2022-05-16)
18
-
19
- ### Features
20
-
21
- - allow all public type definitions to be retrieved ([3e04e2f](https://github.com/oekazuma/svelte-meta-tags/commit/3e04e2fd8ff8446709a7d015b5819971cb42765d))
22
-
23
- ## [2.5.5](https://github.com/oekazuma/svelte-meta-tags/compare/v2.5.4...v2.5.5) (2022-05-06)
24
-
25
- ### Bug Fixes
26
-
27
- - revert JSON.stringify options back to previous ([5160cec](https://github.com/oekazuma/svelte-meta-tags/commit/5160cec32f50a29a8e59aa87f851557444ad26a3))
28
-
29
- ## [2.5.4](https://github.com/oekazuma/svelte-meta-tags/compare/v2.5.3...v2.5.4) (2022-05-06)
30
-
31
- ### Bug Fixes
32
-
33
- - obfuscate by concatenating script tag ([fa9d409](https://github.com/oekazuma/svelte-meta-tags/commit/fa9d40960afc8b06d4aadc6a958fc05b6b15a96c))
34
-
35
- ## [2.5.3](https://github.com/oekazuma/svelte-meta-tags/compare/v2.5.2...v2.5.3) (2022-05-06)
36
-
37
- - escaping content in script tags ([25bf038](https://github.com/oekazuma/svelte-meta-tags/commit/25bf038a485697249ecc9633166599b0652f3550))
38
-
39
- ## [2.5.2](https://github.com/oekazuma/svelte-meta-tags/compare/v2.5.1...v2.5.2) (2022-05-06)
40
-
41
- - version bump for package
42
-
43
- ## [2.5.1](https://github.com/oekazuma/svelte-meta-tags/compare/v2.5.0...v2.5.1) (2022-03-22)
44
-
45
- ### Bug Fixes
46
-
47
- - fix title to be reactive([a19d30b](https://github.com/oekazuma/svelte-meta-tags/commit/a19d30bad9938d78360aea126012bfd7061fff3f))
48
-
49
- # [2.5.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.4.0...v2.5.0) (2022-03-19)
50
-
51
- ### Features
52
-
53
- - add titleTemplate property ([3a252e5](https://github.com/oekazuma/svelte-meta-tags/commit/3a252e5783d04456e32539d8bd3ca7646809fd0d))
54
-
55
- # [2.4.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.4...v2.4.0) (2022-03-12)
56
-
57
- ### Features
58
-
59
- - 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))
60
-
61
- ## [2.3.4](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.3...v2.3.4) (2022-03-03)
62
-
63
- ### Bug Fixes
64
-
65
- - add pnpm build to release command ([1c01f61](https://github.com/oekazuma/svelte-meta-tags/commit/1c01f619c5cd1dee51c58f4067fd315907fb4753))
66
-
67
- ## [2.3.3](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.2...v2.3.3) (2022-03-03)
68
-
69
- ### Bug Fixes
70
-
71
- - fix tsconfig.json ([bd54216](https://github.com/oekazuma/svelte-meta-tags/commit/bd542167bc0f377157d7337b9eb2e9b58d63a625))
72
-
73
- ## [2.3.2](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.1...v2.3.2) (2022-02-28)
74
-
75
- ### Bug Fixes
76
-
77
- - **deps:** update dependency schema-dts to v1.1.0 ([d57c99d](https://github.com/oekazuma/svelte-meta-tags/commit/d57c99d89b5071e1e2045892ee2814a7105251ce))
78
-
79
- ## [2.3.1](https://github.com/oekazuma/svelte-meta-tags/compare/v2.3.0...v2.3.1) (2022-02-25)
80
-
81
- ### Bug Fixes
82
-
83
- - fix lint error in `@typescript-eslint/no-empty-interface` ([6f41cc4](https://github.com/oekazuma/svelte-meta-tags/commit/6f41cc4e0d0022b1be6c778d4520bdd7b0188127))
84
-
85
- # [2.3.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.2.3...v2.3.0) (2022-01-28)
86
-
87
- ### Features
88
-
89
- - add twitter title description image imageAlt ([e3270f5](https://github.com/oekazuma/svelte-meta-tags/commit/e3270f54fda56483a192d34dfc9d589c7949fc5b))
90
-
91
- ## [2.2.3](https://github.com/oekazuma/svelte-meta-tags/compare/v2.2.2...v2.2.3) (2022-01-14)
92
-
93
- ### Bug Fixes
94
-
95
- - fix path to type definitions ([7c49639](https://github.com/oekazuma/svelte-meta-tags/commit/7c49639c1f08fe6ee6ea3e036c9982b1c1979c77))
96
-
97
- ## [2.2.2](https://github.com/oekazuma/svelte-meta-tags/compare/v2.2.1...v2.2.2) (2021-12-26)
98
-
99
- ### Bug Fixes
100
-
101
- - revert changes so that npm and yarn can also be used for installation ([f536977](https://github.com/oekazuma/svelte-meta-tags/commit/f536977550948f675f4207b80dc5aca96cc535a0))
102
-
103
- ## [2.2.1](https://github.com/oekazuma/svelte-meta-tags/compare/v2.2.0...v2.2.1) (2021-12-21)
104
-
105
- ### Bug Fixes
106
-
107
- - make the schema property of jsonLdProps not mandatory ([15f00f9](https://github.com/oekazuma/svelte-meta-tags/commit/15f00f9940fdcb8ac9a8c8f6ed51782bd5789ebd))
108
-
109
- # [2.2.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.1.0...v2.2.0) (2021-12-17)
110
-
111
- ### Features
112
-
113
- - improved Twitter's CardType type definition ([13b11fd](https://github.com/oekazuma/svelte-meta-tags/commit/13b11fd2e9f6625e1cd0802e825f312f37988666))
114
-
115
- # [2.1.0](https://github.com/oekazuma/svelte-meta-tags/compare/v2.0.0...v2.1.0) (2021-11-04)
116
-
117
- ### Features
118
-
119
- - allow title to be dynamically changed ([b9acefb](https://github.com/oekazuma/svelte-meta-tags/commit/b9acefbea7c64b5434837ffecc17423dcf0ce2d3))
120
-
121
- # [2.0.0](https://github.com/oekazuma/svelte-meta-tags/compare/v1.2.2...v2.0.0) (2021-09-18)
122
-
123
- ### chore
124
-
125
- - change name the MetaTags export ([d40b535](https://github.com/oekazuma/svelte-meta-tags/commit/d40b535249be8b629ba1034358865aa08993927c))
126
- - remove jsonLd property from MetaTags component ([a05ae2b](https://github.com/oekazuma/svelte-meta-tags/commit/a05ae2b72a8605253a50249e8f76ee76cbe1411d))
127
-
128
- ### BREAKING CHANGES
129
-
130
- - Change the way import is written.
131
- - Remove jsonLd parameter from MetaTags component.
132
- Please use the JsonLd component from now on.
133
-
134
- ## [1.2.2](https://github.com/oekazuma/svelte-meta-tags/compare/v1.2.1...v1.2.2) (2021-09-07)
135
-
136
- ### Bug Fixes
137
-
138
- - fix types in package.json ([7be485a](https://github.com/oekazuma/svelte-meta-tags/commit/7be485a880203ce2038ea91768031fbbf66d32b5))
139
-
140
- ## [1.2.1](https://github.com/oekazuma/svelte-meta-tags/compare/v1.2.0...v1.2.1) (2021-09-07)
141
-
142
- ### Bug Fixes
143
-
144
- - restore the emitTypes setting of package ([20d8a85](https://github.com/oekazuma/svelte-meta-tags/commit/20d8a85ab0f76a1a7c270cdf3a1062eb83c1aa59))
145
-
146
- # [1.2.0](https://github.com/oekazuma/svelte-meta-tags/compare/v1.1.1...v1.2.0) (2021-09-07)
147
-
148
- ### Features
149
-
150
- - import types to make them easier to use ([cdceda7](https://github.com/oekazuma/svelte-meta-tags/commit/cdceda73204d668f80cb2773b73e252e53d0d6a1))
151
-
152
- ## [1.1.1](https://github.com/oekazuma/svelte-meta-tags/compare/v1.1.0...v1.1.1) (2021-09-02)
153
-
154
- ### Bug Fixes
155
-
156
- - update package.json ([cd0574c](https://github.com/oekazuma/svelte-meta-tags/commit/cd0574cf04050d3f8a031556ff20628aa390c671))
157
-
158
- # [1.1.0](https://github.com/oekazuma/svelte-meta-tags/compare/v1.0.5...v1.1.0) (2021-08-30)
159
-
160
- ### Features
161
-
162
- - separate JSON-LD from MetaTags component ([43698ab](https://github.com/oekazuma/svelte-meta-tags/commit/43698ab9b98781f3b9ff246640c1e29ab772ba75))
163
-
164
- ## [1.0.5](https://github.com/oekazuma/svelte-meta-tags/compare/v1.0.4...v1.0.5) (2021-08-30)
165
-
166
- ### Bug Fixes
167
-
168
- - **deps:** update dependency schema-dts to v1 ([a13737a](https://github.com/oekazuma/svelte-meta-tags/commit/a13737a621d0a199b18dea55324b06ff9478fce1))
169
-
170
- ## [1.0.4](https://github.com/oekazuma/svelte-meta-tags/compare/v1.0.3...v1.0.4) (2021-08-27)
171
-
172
- ### Bug Fixes
173
-
174
- - pkgRoot settings to semantic-releas ([c52e674](https://github.com/oekazuma/svelte-meta-tags/commit/c52e674e9240cc61eb4cbe062f483f96dbf02b1a))
175
-
176
- ## [1.0.3](https://github.com/oekazuma/svelte-meta-tags/compare/v1.0.2...v1.0.3) (2021-08-27)
177
-
178
- ### Bug Fixes
179
-
180
- - change branch to branches ([0c4c0e3](https://github.com/oekazuma/svelte-meta-tags/commit/0c4c0e346ee63648bc771033b828a19324739d68))
181
- - change commitlint type-enum ([0b84c33](https://github.com/oekazuma/svelte-meta-tags/commit/0b84c33e32b1e59c8a7deb3e45d6cece28069eaa))
File without changes
File without changes
File without changes
File without changes