svelte-meta-tags 3.1.0 → 3.1.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/README.md CHANGED
@@ -125,50 +125,80 @@ pnpm add -D svelte-meta-tags
125
125
 
126
126
  **Overwriting default values with a child page:**
127
127
 
128
+ [Example](https://github.com/oekazuma/svelte-meta-tags/tree/main/example)
129
+
128
130
  `+layout.svelte`
129
131
 
130
132
  ```svelte
131
133
  <script>
132
- import { MetaTags } from 'svelte-meta-tags'; // Import the MetaTags component.
133
- import { page } from '$app/stores'; // Import the page store to access route-specific data.
134
+ import { MetaTags } from 'svelte-meta-tags';
135
+ import { page } from '$app/stores';
136
+ import extend from 'just-extend'; // Please provide functions that allow deep merging of objects, such as lodash.merge, deepmerge, just-extend.
134
137
 
135
- export let data; // Exported so that child components/pages can provide data.
138
+ export let data;
136
139
 
137
- // Create a reactive statement to compute meta tags.
138
- $: metaTags = {
139
- titleTemplate: '%s | Svelte Meta Tags', // Default title template.
140
- description: 'Default Description for the Website', // Default description.
141
- ...$page.data.metaTagsChild // Override with child page meta tags if they exist.
142
- };
140
+ $: metaTags = extend(true, {}, data.baseMetaTags, $page.data.pageMetaTags);
143
141
  </script>
144
142
 
145
143
  <MetaTags {...metaTags} />
146
144
 
147
- <!-- The rest of your layout content and the slot for child content would go here. -->
145
+ <slot />
148
146
  ```
149
147
 
150
- `+page.ts`
148
+ `+layout.ts`
151
149
 
152
150
  ```ts
153
- import type { MetaTagsProps } from 'svelte-meta-tags'; // Import type for meta tags properties.
154
-
155
- export const load = async ({ url }) => {
156
- // Define meta tags for this specific child page.
157
- const metaTags: MetaTagsProps = Object.freeze({
158
- title: 'page title', // Page-specific title.
159
- description: 'Description for Child Page', // This description will override the default.
151
+ import type { MetaTagsProps } from 'svelte-meta-tags';
152
+
153
+ export const load = ({ url }) => {
154
+ const baseMetaTags = Object.freeze({
155
+ title: 'Default',
156
+ titleTemplate: '%s | Svelte Meta Tags',
157
+ description: 'Svelte Meta Tags is a Svelte component for managing meta tags and SEO in your Svelte applications.',
158
+ canonical: new URL(url.pathname, url.origin).href,
160
159
  openGraph: {
161
- // OpenGraph meta tags specific to this page.
162
160
  type: 'website',
163
161
  url: new URL(url.pathname, url.origin).href,
164
162
  locale: 'en_IE',
165
163
  title: 'Open Graph Title',
166
- description: 'Open Graph Description'
164
+ description: 'Open Graph Description',
165
+ siteName: 'SiteName',
166
+ images: [
167
+ {
168
+ url: 'https://www.example.ie/og-image.jpg',
169
+ alt: 'Og Image Alt',
170
+ width: 800,
171
+ height: 600,
172
+ secureUrl: 'https://www.example.ie/og-image.jpg',
173
+ type: 'image/jpeg'
174
+ }
175
+ ]
176
+ }
177
+ }) satisfies MetaTagsProps;
178
+
179
+ return {
180
+ baseMetaTags
181
+ };
182
+ };
183
+ ```
184
+
185
+ `+page.ts`
186
+
187
+ ```ts
188
+ import type { MetaTagsProps } from 'svelte-meta-tags';
189
+
190
+ export const load = () => {
191
+ const pageMetaTags = Object.freeze({
192
+ title: 'TOP',
193
+ description: 'Description TOP',
194
+ openGraph: {
195
+ title: 'Open Graph Title TOP',
196
+ description: 'Open Graph Description TOP'
167
197
  }
168
- });
198
+ }) satisfies MetaTagsProps;
169
199
 
170
200
  return {
171
- metaTagsChild: metaTags // Return meta tags so they can be consumed by layout.svelte.
201
+ pageMetaTags
172
202
  };
173
203
  };
174
204
  ```
@@ -14,5 +14,5 @@ type JsonLdProps_ = typeof __propDef.props;
14
14
  export { JsonLdProps_ as JsonLdProps };
15
15
  export type JsonLdEvents = typeof __propDef.events;
16
16
  export type JsonLdSlots = typeof __propDef.slots;
17
- export default class JsonLd extends SvelteComponentTyped<JsonLdProps, JsonLdEvents, JsonLdSlots> {
17
+ export default class JsonLd extends SvelteComponentTyped<JsonLdProps_, JsonLdEvents, JsonLdSlots> {
18
18
  }
@@ -35,7 +35,9 @@ $:
35
35
  </script>
36
36
 
37
37
  <svelte:head>
38
- <title>{updatedTitle}</title>
38
+ {#if updatedTitle}
39
+ <title>{updatedTitle}</title>
40
+ {/if}
39
41
 
40
42
  {#if robots !== false}
41
43
  <meta name="robots" content="{robots}{robotsParams}" />
@@ -26,5 +26,5 @@ type MetaTagsProps_ = typeof __propDef.props;
26
26
  export { MetaTagsProps_ as MetaTagsProps };
27
27
  export type MetaTagsEvents = typeof __propDef.events;
28
28
  export type MetaTagsSlots = typeof __propDef.slots;
29
- export default class MetaTags extends SvelteComponentTyped<MetaTagsProps, MetaTagsEvents, MetaTagsSlots> {
29
+ export default class MetaTags extends SvelteComponentTyped<MetaTagsProps_, MetaTagsEvents, MetaTagsSlots> {
30
30
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-meta-tags",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Svelte Meta Tags provides components designed to help you manage SEO for Svelte projects",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -21,15 +21,16 @@
21
21
  "schema-dts": "^1.1.2"
22
22
  },
23
23
  "devDependencies": {
24
- "@sveltejs/adapter-auto": "^2.1.1",
25
- "@sveltejs/kit": "^1.27.4",
26
- "@sveltejs/package": "^2.2.2",
27
- "publint": "^0.2.5",
28
- "svelte": "^4.2.2",
29
- "svelte-check": "^3.5.2",
24
+ "@sveltejs/adapter-auto": "^3.1.1",
25
+ "@sveltejs/kit": "^2.5.2",
26
+ "@sveltejs/package": "^2.2.7",
27
+ "@sveltejs/vite-plugin-svelte": "^3.0.2",
28
+ "publint": "^0.2.7",
29
+ "svelte": "^4.2.12",
30
+ "svelte-check": "^3.6.6",
30
31
  "tslib": "^2.6.2",
31
- "typescript": "^5.2.2",
32
- "vite": "^4.5.0"
32
+ "typescript": "^5.3.3",
33
+ "vite": "^5.1.4"
33
34
  },
34
35
  "peerDependencies": {
35
36
  "svelte": "^3.55.0 || ^4.0.0"