svelte-meta-tags 2.7.2 → 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,16 +1,16 @@
1
- <script>
2
- export let output = 'head';
3
- export let schema = {};
4
-
5
- $: isValid = schema && typeof schema === 'object';
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>'}`;
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>"}`;
14
14
  </script>
15
15
 
16
16
  <svelte:head>
@@ -1,4 +1,18 @@
1
- import { SvelteComponentTyped } from 'svelte';
2
- import { JsonLdProps } from './types';
3
-
4
- export default class JsonLd extends SvelteComponentTyped<JsonLdProps> {}
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { JsonLdProps } from './types';
3
+ declare const __propDef: {
4
+ props: {
5
+ output?: JsonLdProps['output'];
6
+ schema?: JsonLdProps['schema'];
7
+ };
8
+ events: {
9
+ [evt: string]: CustomEvent<any>;
10
+ };
11
+ slots: {};
12
+ };
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,50 +1,44 @@
1
- <script>
2
- export let title = '';
3
- export let titleTemplate = '';
4
- export let noindex = false;
5
- export let nofollow = false;
6
- export let robotsProps = undefined;
7
- export let description = undefined;
8
- export let mobileAlternate = undefined;
9
- export let languageAlternates = undefined;
10
- export let twitter = undefined;
11
- export let facebook = undefined;
12
- export let openGraph = undefined;
13
- export let canonical = undefined;
14
- export let additionalMetaTags = undefined;
15
- export let additionalLinkTags = undefined;
16
-
17
- $: updatedTitle = titleTemplate ? titleTemplate.replace(/%s/g, title) : title;
18
-
19
- let robotsParams = '';
20
- if (robotsProps) {
21
- const {
22
- nosnippet,
23
- maxSnippet,
24
- maxImagePreview,
25
- maxVideoPreview,
26
- noarchive,
27
- noimageindex,
28
- notranslate,
29
- unavailableAfter
30
- } = robotsProps;
31
-
32
- robotsParams = `${nosnippet ? ',nosnippet' : ''}${maxSnippet ? `,max-snippet:${maxSnippet}` : ''}${
33
- maxImagePreview ? `,max-image-preview:${maxImagePreview}` : ''
34
- }${noarchive ? ',noarchive' : ''}${unavailableAfter ? `,unavailable_after:${unavailableAfter}` : ''}${
35
- noimageindex ? ',noimageindex' : ''
36
- }${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");
37
33
  }
38
34
  </script>
39
35
 
40
36
  <svelte:head>
41
37
  <title>{updatedTitle}</title>
42
38
 
43
- <meta name="robots" content={`${noindex ? 'noindex' : 'index'},${nofollow ? 'nofollow' : 'follow'}${robotsParams}`} />
44
- <meta
45
- name="googlebot"
46
- content={`${noindex ? 'noindex' : 'index'},${nofollow ? 'nofollow' : 'follow'}${robotsParams}`}
47
- />
39
+ {#if robots !== false}
40
+ <meta name="robots" content="{robots}{robotsParams}" />
41
+ {/if}
48
42
 
49
43
  {#if description}
50
44
  <meta name="description" content={description} />
@@ -164,7 +158,7 @@
164
158
  {/each}
165
159
  {/if}
166
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)}
167
- {#if openGraph.video.actors && openGraph.video.actors.length}
161
+ {#if openGraph.video?.actors && openGraph.video.actors.length}
168
162
  {#each openGraph.video.actors as actor}
169
163
  {#if actor.profile}
170
164
  <meta property="video:actor" content={actor.profile} />
@@ -175,33 +169,33 @@
175
169
  {/each}
176
170
  {/if}
177
171
 
178
- {#if openGraph.video.directors && openGraph.video.directors.length}
172
+ {#if openGraph.video?.directors && openGraph.video.directors.length}
179
173
  {#each openGraph.video.directors as director}
180
174
  <meta property="video:director" content={director} />
181
175
  {/each}
182
176
  {/if}
183
177
 
184
- {#if openGraph.video.writers && openGraph.video.writers.length}
178
+ {#if openGraph.video?.writers && openGraph.video.writers.length}
185
179
  {#each openGraph.video.writers as writer}
186
180
  <meta property="video:writer" content={writer} />
187
181
  {/each}
188
182
  {/if}
189
183
 
190
- {#if openGraph.video.duration}
184
+ {#if openGraph.video?.duration}
191
185
  <meta property="video:duration" content={openGraph.video.duration.toString()} />
192
186
  {/if}
193
187
 
194
- {#if openGraph.video.releaseDate}
188
+ {#if openGraph.video?.releaseDate}
195
189
  <meta property="video:release_date" content={openGraph.video.releaseDate} />
196
190
  {/if}
197
191
 
198
- {#if openGraph.video.tags && openGraph.video.tags.length}
192
+ {#if openGraph.video?.tags && openGraph.video.tags.length}
199
193
  {#each openGraph.video.tags as tag}
200
194
  <meta property="video:tag" content={tag} />
201
195
  {/each}
202
196
  {/if}
203
197
 
204
- {#if openGraph.video.series}
198
+ {#if openGraph.video?.series}
205
199
  <meta property="video:series" content={openGraph.video.series} />
206
200
  {/if}
207
201
  {/if}
@@ -260,7 +254,7 @@
260
254
  {/if}
261
255
  {/if}
262
256
 
263
- {#if additionalMetaTags && additionalMetaTags.length > 0}
257
+ {#if additionalMetaTags && Array.isArray(additionalMetaTags)}
264
258
  {#each additionalMetaTags as tag}
265
259
  <meta {...tag} />
266
260
  {/each}
@@ -1,4 +1,29 @@
1
- import { SvelteComponentTyped } from 'svelte';
2
- import { MetaTagsProps } from './types';
3
-
4
- export default class MetaTags extends SvelteComponentTyped<MetaTagsProps> {}
1
+ import { SvelteComponentTyped } from "svelte";
2
+ import type { MetaTagsProps } from './types';
3
+ declare const __propDef: {
4
+ props: {
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'];
18
+ };
19
+ events: {
20
+ [evt: string]: CustomEvent<any>;
21
+ };
22
+ slots: {};
23
+ };
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.7.2",
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,29 +21,18 @@
21
21
  "schema-dts": "^1.1.2"
22
22
  },
23
23
  "devDependencies": {
24
- "@changesets/cli": "^2.26.1",
25
- "@playwright/test": "^1.33.0",
26
- "@sveltejs/adapter-auto": "^2.0.1",
27
- "@sveltejs/kit": "^1.16.2",
28
- "@sveltejs/package": "^2.0.2",
29
- "@typescript-eslint/eslint-plugin": "^5.59.5",
30
- "@typescript-eslint/parser": "^5.59.5",
31
- "eslint": "^8.40.0",
32
- "eslint-config-prettier": "^8.8.0",
33
- "eslint-plugin-svelte": "^2.27.4",
34
- "husky": "^8.0.3",
35
- "lint-staged": "^13.2.2",
36
- "prettier": "^2.8.8",
37
- "prettier-plugin-svelte": "^2.10.0",
38
- "publint": "^0.1.11",
39
- "svelte": "^3.59.1",
40
- "svelte-check": "^3.3.2",
41
- "tslib": "^2.5.0",
42
- "typescript": "^5.0.4",
43
- "vite": "^4.3.5"
24
+ "@sveltejs/adapter-auto": "^2.1.0",
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
- "svelte": "^3.44.0"
35
+ "svelte": "^3.55.0 || ^4.0.0"
47
36
  },
48
37
  "exports": {
49
38
  "./JsonLd.svelte": {
@@ -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
  }