svelte-meta-tags 2.8.0 → 3.0.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.
@@ -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}
@@ -287,7 +254,7 @@
287
254
  {/if}
288
255
  {/if}
289
256
 
290
- {#if additionalMetaTags && additionalMetaTags.length > 0}
257
+ {#if additionalMetaTags && Array.isArray(additionalMetaTags)}
291
258
  {#each additionalMetaTags as tag}
292
259
  <meta {...tag} />
293
260
  {/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,8 +40,9 @@ export interface OpenGraph {
39
40
  type?: string;
40
41
  title?: string;
41
42
  description?: string;
42
- images?: ReadonlyArray<OpenGraphImages>;
43
- videos?: ReadonlyArray<OpenGraphVideos>;
43
+ images?: ReadonlyArray<OpenGraphMedia>;
44
+ videos?: ReadonlyArray<OpenGraphMedia>;
45
+ audio?: ReadonlyArray<OpenGraphMedia>;
44
46
  locale?: string;
45
47
  site_name?: string;
46
48
  profile?: OpenGraphProfile;
@@ -48,20 +50,16 @@ export interface OpenGraph {
48
50
  article?: OpenGraphArticle;
49
51
  video?: OpenGraphVideo;
50
52
  }
51
- interface OpenGraphImages {
53
+
54
+ interface OpenGraphMedia {
52
55
  url: string;
53
- alt?: string;
54
56
  width?: number;
55
57
  height?: number;
56
- }
57
- interface OpenGraphVideos {
58
- url: string;
59
58
  alt?: string;
60
- width?: number;
61
- height?: number;
62
- secureUrl?: string;
63
59
  type?: string;
60
+ secureUrl?: string;
64
61
  }
62
+
65
63
  interface OpenGraphProfile {
66
64
  firstName?: string;
67
65
  lastName?: string;
@@ -75,6 +73,7 @@ interface OpenGraphBook {
75
73
  releaseDate?: string;
76
74
  tags?: ReadonlyArray<string>;
77
75
  }
76
+
78
77
  interface OpenGraphArticle {
79
78
  publishedTime?: string;
80
79
  modifiedTime?: string;
@@ -126,17 +125,21 @@ export type MetaTag = HTML5MetaTag | RDFaMetaTag | HTTPEquivMetaTag;
126
125
  export interface LinkTag {
127
126
  rel: string;
128
127
  href: string;
128
+ hrefLang?: string;
129
+ media?: string;
129
130
  sizes?: string;
130
131
  type?: string;
131
132
  color?: string;
133
+ as?: string;
134
+ crossOrigin?: string;
135
+ referrerPolicy?: string;
132
136
  }
133
137
 
134
138
  export interface MetaTagsProps {
135
139
  title?: string;
136
140
  titleTemplate?: string;
137
- noindex?: boolean;
138
- nofollow?: boolean;
139
- robotsProps?: AdditionalRobotsProps;
141
+ robots?: string | boolean;
142
+ additionalRobotsProps?: AdditionalRobotsProps;
140
143
  description?: string;
141
144
  canonical?: string;
142
145
  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.0",
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.1",
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
  }