svelte-meta-tags 2.8.0 → 3.0.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.
@@ -1,22 +1,16 @@
1
- <script>
2
- /** @type {import("./types").JsonLdProps['output']} */
3
- export let output = 'head';
4
-
5
- /** @type {import("./types").JsonLdProps['schema']} */
6
- export let schema = undefined;
7
-
8
- $: isValid = schema && typeof schema === 'object';
9
-
10
- /**
11
- * @param {import("./types").JsonLdProps['schema']} schema
12
- */
13
- function createSchema(schema) {
14
- const addContext = (context) => ({ '@context': 'https://schema.org', ...context });
15
-
16
- return Array.isArray(schema) ? schema.map((context) => addContext(context)) : addContext(schema);
17
- }
18
-
19
- $: json = `${'<scri' + 'pt type="application/ld+json">'}${JSON.stringify(createSchema(schema))}${'</scri' + 'pt>'}`;
1
+ <script>export let output = "head";
2
+ export let schema = void 0;
3
+ $:
4
+ isValid = schema && typeof schema === "object";
5
+ const createSchema = (schema2) => {
6
+ const addContext = (context) => ({
7
+ "@context": "https://schema.org",
8
+ ...context
9
+ });
10
+ return Array.isArray(schema2) ? schema2.map((context) => addContext(context)) : addContext(schema2);
11
+ };
12
+ $:
13
+ json = `${'<script type="application/ld+json">'}${JSON.stringify(createSchema(schema))}${"<\/script>"}`;
20
14
  </script>
21
15
 
22
16
  <svelte:head>
@@ -1,25 +1,18 @@
1
- /** @typedef {typeof __propDef.props} JsonLdProps */
2
- /** @typedef {typeof __propDef.events} JsonLdEvents */
3
- /** @typedef {typeof __propDef.slots} JsonLdSlots */
4
- export default class JsonLd extends SvelteComponentTyped<{
5
- output?: "head" | "body";
6
- schema?: import("schema-dts").Thing | import("schema-dts").WithContext<import("schema-dts").Thing> | import("schema-dts").Thing[] | import("schema-dts").WithContext<import("schema-dts").Thing>[];
7
- }, {
8
- [evt: string]: CustomEvent<any>;
9
- }, {}> {
10
- }
11
- export type JsonLdProps = typeof __propDef.props;
12
- export type JsonLdEvents = typeof __propDef.events;
13
- export type JsonLdSlots = typeof __propDef.slots;
14
1
  import { SvelteComponentTyped } from "svelte";
2
+ import type { JsonLdProps } from './types';
15
3
  declare const __propDef: {
16
4
  props: {
17
- output?: import("./types").JsonLdProps['output'];
18
- schema?: import("./types").JsonLdProps['schema'];
5
+ output?: JsonLdProps['output'];
6
+ schema?: JsonLdProps['schema'];
19
7
  };
20
8
  events: {
21
9
  [evt: string]: CustomEvent<any>;
22
10
  };
23
11
  slots: {};
24
12
  };
25
- export {};
13
+ type JsonLdProps_ = typeof __propDef.props;
14
+ export { JsonLdProps_ as JsonLdProps };
15
+ export type JsonLdEvents = typeof __propDef.events;
16
+ export type JsonLdSlots = typeof __propDef.slots;
17
+ export default class JsonLd extends SvelteComponentTyped<JsonLdProps, JsonLdEvents, JsonLdSlots> {
18
+ }
@@ -1,77 +1,44 @@
1
- <script>
2
- /** @type {import("./types").MetaTagsProps['title']} */
3
- export let title = '';
4
-
5
- /** @type {import("./types").MetaTagsProps['titleTemplate']} */
6
- export let titleTemplate = '';
7
-
8
- /** @type {import("./types").MetaTagsProps['noindex']} */
9
- export let noindex = false;
10
-
11
- /** @type {import("./types").MetaTagsProps['nofollow']} */
12
- export let nofollow = false;
13
-
14
- /** @type {import("./types").MetaTagsProps['robotsProps']} */
15
- export let robotsProps = undefined;
16
-
17
- /** @type {import("./types").MetaTagsProps['description']} */
18
- export let description = undefined;
19
-
20
- /** @type {import("./types").MetaTagsProps['mobileAlternate']} */
21
- export let mobileAlternate = undefined;
22
-
23
- /** @type {import("./types").MetaTagsProps['languageAlternates']} */
24
- export let languageAlternates = undefined;
25
-
26
- /** @type {import("./types").MetaTagsProps['twitter']} */
27
- export let twitter = undefined;
28
-
29
- /** @type {import("./types").MetaTagsProps['facebook']} */
30
- export let facebook = undefined;
31
-
32
- /** @type {import("./types").MetaTagsProps['openGraph']} */
33
- export let openGraph = undefined;
34
-
35
- /** @type {import("./types").MetaTagsProps['canonical']} */
36
- export let canonical = undefined;
37
-
38
- /** @type {import("./types").MetaTagsProps['additionalMetaTags']} */
39
- export let additionalMetaTags = undefined;
40
-
41
- /** @type {import("./types").MetaTagsProps['additionalLinkTags']} */
42
- export let additionalLinkTags = undefined;
43
-
44
- $: updatedTitle = titleTemplate ? titleTemplate.replace(/%s/g, title) : title;
45
-
46
- let robotsParams = '';
47
- if (robotsProps) {
48
- const {
49
- nosnippet,
50
- maxSnippet,
51
- maxImagePreview,
52
- maxVideoPreview,
53
- noarchive,
54
- noimageindex,
55
- notranslate,
56
- unavailableAfter
57
- } = robotsProps;
58
-
59
- robotsParams = `${nosnippet ? ',nosnippet' : ''}${maxSnippet ? `,max-snippet:${maxSnippet}` : ''}${
60
- maxImagePreview ? `,max-image-preview:${maxImagePreview}` : ''
61
- }${noarchive ? ',noarchive' : ''}${unavailableAfter ? `,unavailable_after:${unavailableAfter}` : ''}${
62
- noimageindex ? ',noimageindex' : ''
63
- }${maxVideoPreview ? `,max-video-preview:${maxVideoPreview}` : ''}${notranslate ? ',notranslate' : ''}`;
1
+ <script>export let title = "";
2
+ export let titleTemplate = "";
3
+ export let robots = "index,follow";
4
+ export let additionalRobotsProps = void 0;
5
+ export let description = void 0;
6
+ export let mobileAlternate = void 0;
7
+ export let languageAlternates = void 0;
8
+ export let twitter = void 0;
9
+ export let facebook = void 0;
10
+ export let openGraph = void 0;
11
+ export let canonical = void 0;
12
+ export let additionalMetaTags = void 0;
13
+ export let additionalLinkTags = void 0;
14
+ $:
15
+ updatedTitle = titleTemplate ? title ? titleTemplate.replace(/%s/g, title) : title : title;
16
+ let robotsParams = "";
17
+ if (additionalRobotsProps) {
18
+ const {
19
+ nosnippet,
20
+ maxSnippet,
21
+ maxImagePreview,
22
+ maxVideoPreview,
23
+ noarchive,
24
+ noimageindex,
25
+ notranslate,
26
+ unavailableAfter
27
+ } = additionalRobotsProps;
28
+ robotsParams = `${nosnippet ? ",nosnippet" : ""}${maxSnippet ? `,max-snippet:${maxSnippet}` : ""}${maxImagePreview ? `,max-image-preview:${maxImagePreview}` : ""}${noarchive ? ",noarchive" : ""}${unavailableAfter ? `,unavailable_after:${unavailableAfter}` : ""}${noimageindex ? ",noimageindex" : ""}${maxVideoPreview ? `,max-video-preview:${maxVideoPreview}` : ""}${notranslate ? ",notranslate" : ""}`;
29
+ }
30
+ $:
31
+ if (!robots && additionalRobotsProps) {
32
+ console.warn("additionalRobotsProps cannot be used when robots is set to false");
64
33
  }
65
34
  </script>
66
35
 
67
36
  <svelte:head>
68
37
  <title>{updatedTitle}</title>
69
38
 
70
- <meta name="robots" content={`${noindex ? 'noindex' : 'index'},${nofollow ? 'nofollow' : 'follow'}${robotsParams}`} />
71
- <meta
72
- name="googlebot"
73
- content={`${noindex ? 'noindex' : 'index'},${nofollow ? 'nofollow' : 'follow'}${robotsParams}`}
74
- />
39
+ {#if robots !== false}
40
+ <meta name="robots" content="{robots}{robotsParams}" />
41
+ {/if}
75
42
 
76
43
  {#if description}
77
44
  <meta name="description" content={description} />
@@ -191,7 +158,7 @@
191
158
  {/each}
192
159
  {/if}
193
160
  {:else if openGraph.type.toLowerCase() === 'video.movie' || openGraph.type.toLowerCase() === 'video.episode' || openGraph.type.toLowerCase() === 'video.tv_show' || (openGraph.type.toLowerCase() === 'video.other' && openGraph.video)}
194
- {#if openGraph.video.actors && openGraph.video.actors.length}
161
+ {#if openGraph.video?.actors && openGraph.video.actors.length}
195
162
  {#each openGraph.video.actors as actor}
196
163
  {#if actor.profile}
197
164
  <meta property="video:actor" content={actor.profile} />
@@ -202,33 +169,33 @@
202
169
  {/each}
203
170
  {/if}
204
171
 
205
- {#if openGraph.video.directors && openGraph.video.directors.length}
172
+ {#if openGraph.video?.directors && openGraph.video.directors.length}
206
173
  {#each openGraph.video.directors as director}
207
174
  <meta property="video:director" content={director} />
208
175
  {/each}
209
176
  {/if}
210
177
 
211
- {#if openGraph.video.writers && openGraph.video.writers.length}
178
+ {#if openGraph.video?.writers && openGraph.video.writers.length}
212
179
  {#each openGraph.video.writers as writer}
213
180
  <meta property="video:writer" content={writer} />
214
181
  {/each}
215
182
  {/if}
216
183
 
217
- {#if openGraph.video.duration}
184
+ {#if openGraph.video?.duration}
218
185
  <meta property="video:duration" content={openGraph.video.duration.toString()} />
219
186
  {/if}
220
187
 
221
- {#if openGraph.video.releaseDate}
188
+ {#if openGraph.video?.releaseDate}
222
189
  <meta property="video:release_date" content={openGraph.video.releaseDate} />
223
190
  {/if}
224
191
 
225
- {#if openGraph.video.tags && openGraph.video.tags.length}
192
+ {#if openGraph.video?.tags && openGraph.video.tags.length}
226
193
  {#each openGraph.video.tags as tag}
227
194
  <meta property="video:tag" content={tag} />
228
195
  {/each}
229
196
  {/if}
230
197
 
231
- {#if openGraph.video.series}
198
+ {#if openGraph.video?.series}
232
199
  <meta property="video:series" content={openGraph.video.series} />
233
200
  {/if}
234
201
  {/if}
@@ -254,15 +221,18 @@
254
221
  {#if image.height}
255
222
  <meta property="og:image:height" content={image.height.toString()} />
256
223
  {/if}
224
+ {#if image.secureUrl}
225
+ <meta property="og:image:secure_url" content={image.secureUrl.toString()} />
226
+ {/if}
227
+ {#if image.type}
228
+ <meta property="og:image:type" content={image.type.toString()} />
229
+ {/if}
257
230
  {/each}
258
231
  {/if}
259
232
 
260
233
  {#if openGraph.videos && openGraph.videos.length}
261
234
  {#each openGraph.videos as video}
262
235
  <meta property="og:video" content={video.url} />
263
- {#if video.alt}
264
- <meta property="og:video:alt" content={video.alt} />
265
- {/if}
266
236
  {#if video.width}
267
237
  <meta property="og:video:width" content={video.width.toString()} />
268
238
  {/if}
@@ -278,16 +248,28 @@
278
248
  {/each}
279
249
  {/if}
280
250
 
251
+ {#if openGraph.audio && openGraph.audio.length}
252
+ {#each openGraph.audio as audio}
253
+ <meta property="og:audio" content={audio.url} />
254
+ {#if audio.secureUrl}
255
+ <meta property="og:audio:secure_url" content={audio.secureUrl.toString()} />
256
+ {/if}
257
+ {#if audio.type}
258
+ <meta property="og:audio:type" content={audio.type.toString()} />
259
+ {/if}
260
+ {/each}
261
+ {/if}
262
+
281
263
  {#if openGraph.locale}
282
264
  <meta property="og:locale" content={openGraph.locale} />
283
265
  {/if}
284
266
 
285
- {#if openGraph.site_name}
286
- <meta property="og:site_name" content={openGraph.site_name} />
267
+ {#if openGraph.siteName}
268
+ <meta property="og:site_name" content={openGraph.siteName} />
287
269
  {/if}
288
270
  {/if}
289
271
 
290
- {#if additionalMetaTags && additionalMetaTags.length > 0}
272
+ {#if additionalMetaTags && Array.isArray(additionalMetaTags)}
291
273
  {#each additionalMetaTags as tag}
292
274
  <meta {...tag} />
293
275
  {/each}
@@ -1,49 +1,29 @@
1
- /** @typedef {typeof __propDef.props} MetaTagsProps */
2
- /** @typedef {typeof __propDef.events} MetaTagsEvents */
3
- /** @typedef {typeof __propDef.slots} MetaTagsSlots */
4
- export default class MetaTags extends SvelteComponentTyped<{
5
- title?: string;
6
- titleTemplate?: string;
7
- noindex?: boolean;
8
- nofollow?: boolean;
9
- robotsProps?: import("./types").AdditionalRobotsProps;
10
- description?: string;
11
- mobileAlternate?: import("./types").MobileAlternate;
12
- languageAlternates?: readonly import("./types").LanguageAlternate[];
13
- twitter?: import("./types").Twitter;
14
- facebook?: import("./types").Facebook;
15
- openGraph?: import("./types").OpenGraph;
16
- canonical?: string;
17
- additionalMetaTags?: readonly import("./types").MetaTag[];
18
- additionalLinkTags?: readonly import("./types").LinkTag[];
19
- }, {
20
- [evt: string]: CustomEvent<any>;
21
- }, {}> {
22
- }
23
- export type MetaTagsProps = typeof __propDef.props;
24
- export type MetaTagsEvents = typeof __propDef.events;
25
- export type MetaTagsSlots = typeof __propDef.slots;
26
1
  import { SvelteComponentTyped } from "svelte";
2
+ import type { MetaTagsProps } from './types';
27
3
  declare const __propDef: {
28
4
  props: {
29
- title?: import("./types").MetaTagsProps['title'];
30
- titleTemplate?: import("./types").MetaTagsProps['titleTemplate'];
31
- noindex?: import("./types").MetaTagsProps['noindex'];
32
- nofollow?: import("./types").MetaTagsProps['nofollow'];
33
- robotsProps?: import("./types").MetaTagsProps['robotsProps'];
34
- description?: import("./types").MetaTagsProps['description'];
35
- mobileAlternate?: import("./types").MetaTagsProps['mobileAlternate'];
36
- languageAlternates?: import("./types").MetaTagsProps['languageAlternates'];
37
- twitter?: import("./types").MetaTagsProps['twitter'];
38
- facebook?: import("./types").MetaTagsProps['facebook'];
39
- openGraph?: import("./types").MetaTagsProps['openGraph'];
40
- canonical?: import("./types").MetaTagsProps['canonical'];
41
- additionalMetaTags?: import("./types").MetaTagsProps['additionalMetaTags'];
42
- additionalLinkTags?: import("./types").MetaTagsProps['additionalLinkTags'];
5
+ title?: MetaTagsProps['title'];
6
+ titleTemplate?: MetaTagsProps['titleTemplate'];
7
+ robots?: MetaTagsProps['robots'];
8
+ additionalRobotsProps?: MetaTagsProps['additionalRobotsProps'];
9
+ description?: MetaTagsProps['description'];
10
+ mobileAlternate?: MetaTagsProps['mobileAlternate'];
11
+ languageAlternates?: MetaTagsProps['languageAlternates'];
12
+ twitter?: MetaTagsProps['twitter'];
13
+ facebook?: MetaTagsProps['facebook'];
14
+ openGraph?: MetaTagsProps['openGraph'];
15
+ canonical?: MetaTagsProps['canonical'];
16
+ additionalMetaTags?: MetaTagsProps['additionalRobotsProps'];
17
+ additionalLinkTags?: MetaTagsProps['additionalLinkTags'];
43
18
  };
44
19
  events: {
45
20
  [evt: string]: CustomEvent<any>;
46
21
  };
47
22
  slots: {};
48
23
  };
49
- export {};
24
+ type MetaTagsProps_ = typeof __propDef.props;
25
+ export { MetaTagsProps_ as MetaTagsProps };
26
+ export type MetaTagsEvents = typeof __propDef.events;
27
+ export type MetaTagsSlots = typeof __propDef.slots;
28
+ export default class MetaTags extends SvelteComponentTyped<MetaTagsProps, MetaTagsEvents, MetaTagsSlots> {
29
+ }
package/dist/types.d.ts CHANGED
@@ -20,6 +20,7 @@ export interface AdditionalRobotsProps {
20
20
  noimageindex?: boolean;
21
21
  notranslate?: boolean;
22
22
  }
23
+
23
24
  export interface Twitter {
24
25
  cardType?: 'summary' | 'summary_large_image' | 'app' | 'player';
25
26
  site?: string;
@@ -39,29 +40,40 @@ export interface OpenGraph {
39
40
  type?: string;
40
41
  title?: string;
41
42
  description?: string;
42
- images?: ReadonlyArray<OpenGraphImages>;
43
+ images?: ReadonlyArray<OpenGraphImage>;
43
44
  videos?: ReadonlyArray<OpenGraphVideos>;
45
+ audio?: ReadonlyArray<OpenGraphAudio>;
44
46
  locale?: string;
45
- site_name?: string;
47
+ siteName?: string;
46
48
  profile?: OpenGraphProfile;
47
49
  book?: OpenGraphBook;
48
50
  article?: OpenGraphArticle;
49
51
  video?: OpenGraphVideo;
50
52
  }
51
- interface OpenGraphImages {
53
+
54
+ interface OpenGraphImage {
52
55
  url: string;
53
- alt?: string;
56
+ secureUrl?: string;
57
+ type?: string;
54
58
  width?: number;
55
59
  height?: number;
60
+ alt?: string;
56
61
  }
62
+
57
63
  interface OpenGraphVideos {
58
64
  url: string;
59
- alt?: string;
65
+ secureUrl?: string;
66
+ type?: string;
60
67
  width?: number;
61
68
  height?: number;
69
+ }
70
+
71
+ interface OpenGraphAudio {
72
+ url: string;
62
73
  secureUrl?: string;
63
74
  type?: string;
64
75
  }
76
+
65
77
  interface OpenGraphProfile {
66
78
  firstName?: string;
67
79
  lastName?: string;
@@ -75,6 +87,7 @@ interface OpenGraphBook {
75
87
  releaseDate?: string;
76
88
  tags?: ReadonlyArray<string>;
77
89
  }
90
+
78
91
  interface OpenGraphArticle {
79
92
  publishedTime?: string;
80
93
  modifiedTime?: string;
@@ -126,17 +139,21 @@ export type MetaTag = HTML5MetaTag | RDFaMetaTag | HTTPEquivMetaTag;
126
139
  export interface LinkTag {
127
140
  rel: string;
128
141
  href: string;
142
+ hrefLang?: string;
143
+ media?: string;
129
144
  sizes?: string;
130
145
  type?: string;
131
146
  color?: string;
147
+ as?: string;
148
+ crossOrigin?: string;
149
+ referrerPolicy?: string;
132
150
  }
133
151
 
134
152
  export interface MetaTagsProps {
135
153
  title?: string;
136
154
  titleTemplate?: string;
137
- noindex?: boolean;
138
- nofollow?: boolean;
139
- robotsProps?: AdditionalRobotsProps;
155
+ robots?: string | boolean;
156
+ additionalRobotsProps?: AdditionalRobotsProps;
140
157
  description?: string;
141
158
  canonical?: string;
142
159
  mobileAlternate?: MobileAlternate;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "svelte-meta-tags",
3
- "version": "2.8.0",
4
- "description": "Svelte Meta Tags is a plugin that makes managing your SEO easier in Svelte projects.",
3
+ "version": "3.0.1",
4
+ "description": "Svelte Meta Tags provides components designed to help you manage SEO for Svelte projects",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
7
  "keywords": [
@@ -21,26 +21,15 @@
21
21
  "schema-dts": "^1.1.2"
22
22
  },
23
23
  "devDependencies": {
24
- "@changesets/cli": "^2.26.1",
25
- "@playwright/test": "^1.34.3",
26
24
  "@sveltejs/adapter-auto": "^2.1.0",
27
- "@sveltejs/kit": "^1.20.0",
28
- "@sveltejs/package": "^2.0.2",
29
- "@typescript-eslint/eslint-plugin": "^5.59.8",
30
- "@typescript-eslint/parser": "^5.59.8",
31
- "eslint": "^8.41.0",
32
- "eslint-config-prettier": "^8.8.0",
33
- "eslint-plugin-svelte": "^2.29.0",
34
- "husky": "^8.0.3",
35
- "lint-staged": "^13.2.2",
36
- "prettier": "^2.8.8",
37
- "prettier-plugin-svelte": "^2.10.1",
38
- "publint": "^0.1.12",
39
- "svelte": "^3.59.1",
40
- "svelte-check": "^3.4.3",
41
- "tslib": "^2.5.2",
42
- "typescript": "^5.0.4",
43
- "vite": "^4.3.9"
25
+ "@sveltejs/kit": "^1.22.6",
26
+ "@sveltejs/package": "^2.2.1",
27
+ "publint": "^0.2.2",
28
+ "svelte": "^4.2.0",
29
+ "svelte-check": "^3.5.0",
30
+ "tslib": "^2.6.2",
31
+ "typescript": "^5.1.6",
32
+ "vite": "^4.4.9"
44
33
  },
45
34
  "peerDependencies": {
46
35
  "svelte": "^3.55.0 || ^4.0.0"
@@ -70,10 +59,6 @@
70
59
  "preview": "vite preview",
71
60
  "package": "svelte-kit sync && svelte-package && publint",
72
61
  "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
73
- "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
74
- "lint": "prettier --plugin-search-dir . --check . && eslint .",
75
- "format": "prettier --plugin-search-dir . --write .",
76
- "test": "playwright test",
77
- "release": "changeset publish"
62
+ "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch"
78
63
  }
79
64
  }