@ainsleydev/sveltekit-helper 0.3.2 → 0.4.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/dist/components/payload/PayloadFooter.svelte +34 -0
- package/dist/components/payload/PayloadFooter.svelte.d.ts +17 -0
- package/dist/components/payload/PayloadFooter.svelte.d.ts.map +1 -0
- package/dist/components/payload/PayloadSEO.svelte +195 -0
- package/dist/components/payload/PayloadSEO.svelte.d.ts +19 -0
- package/dist/components/payload/PayloadSEO.svelte.d.ts.map +1 -0
- package/dist/components/payload/index.d.ts +4 -1
- package/dist/components/payload/index.d.ts.map +1 -1
- package/dist/components/payload/index.js +3 -0
- package/dist/components/payload/resolve.d.ts +9 -0
- package/dist/components/payload/resolve.d.ts.map +1 -0
- package/dist/components/payload/resolve.js +12 -0
- package/dist/components/payload/types.d.ts +72 -0
- package/dist/components/payload/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/utils/seo/index.d.ts +2 -0
- package/dist/utils/seo/index.d.ts.map +1 -0
- package/dist/utils/seo/index.js +1 -0
- package/dist/utils/seo/ld-json.d.ts +9 -0
- package/dist/utils/seo/ld-json.d.ts.map +1 -0
- package/dist/utils/seo/ld-json.js +10 -0
- package/dist/utils/seo/ld-json.test.js +31 -0
- package/package.json +5 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { PayloadFooterProps } from './types.js';
|
|
3
|
+
|
|
4
|
+
const { settings, pageCodeInjection }: PayloadFooterProps = $props();
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Code injection meta.
|
|
8
|
+
*/
|
|
9
|
+
const siteCodeInjection = $derived(settings?.codeInjection?.footer);
|
|
10
|
+
const pageFooterInjection = $derived(pageCodeInjection?.footer);
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<!--
|
|
14
|
+
@component
|
|
15
|
+
|
|
16
|
+
PayloadFooter renders footer code injection scripts from both
|
|
17
|
+
site-level settings and page-level overrides.
|
|
18
|
+
|
|
19
|
+
@example
|
|
20
|
+
```svelte
|
|
21
|
+
<PayloadFooter
|
|
22
|
+
settings={globalSettings}
|
|
23
|
+
pageCodeInjection={page.codeInjection}
|
|
24
|
+
/>
|
|
25
|
+
```
|
|
26
|
+
-->
|
|
27
|
+
<!-- Code Injection - Settings -->
|
|
28
|
+
{#if siteCodeInjection}
|
|
29
|
+
{@html siteCodeInjection}
|
|
30
|
+
{/if}
|
|
31
|
+
<!-- Code Injection - Page -->
|
|
32
|
+
{#if pageFooterInjection}
|
|
33
|
+
{@html pageFooterInjection}
|
|
34
|
+
{/if}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PayloadFooterProps } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* PayloadFooter renders footer code injection scripts from both
|
|
4
|
+
* site-level settings and page-level overrides.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```svelte
|
|
8
|
+
* <PayloadFooter
|
|
9
|
+
* settings={globalSettings}
|
|
10
|
+
* pageCodeInjection={page.codeInjection}
|
|
11
|
+
* />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
declare const PayloadFooter: import("svelte").Component<PayloadFooterProps, {}, "">;
|
|
15
|
+
type PayloadFooter = ReturnType<typeof PayloadFooter>;
|
|
16
|
+
export default PayloadFooter;
|
|
17
|
+
//# sourceMappingURL=PayloadFooter.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayloadFooter.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/payload/PayloadFooter.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AA0BrD;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,aAAa,wDAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { serializeSchema } from '../../utils/seo/ld-json.js';
|
|
3
|
+
import { resolveItems } from './resolve.js';
|
|
4
|
+
|
|
5
|
+
import type { PayloadSEOProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
const { siteName, pageMeta, settings }: PayloadSEOProps = $props();
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Meta properties that should appear on both the
|
|
11
|
+
* page and global level.
|
|
12
|
+
*/
|
|
13
|
+
const meta = $derived.by(() => {
|
|
14
|
+
return {
|
|
15
|
+
title: pageMeta?.title ?? settings.meta?.title ?? settings.siteName ?? siteName,
|
|
16
|
+
description: pageMeta?.description ?? settings.meta?.description ?? settings.tagLine ?? '',
|
|
17
|
+
media: pageMeta?.image
|
|
18
|
+
? resolveItems(pageMeta.image)
|
|
19
|
+
: settings.meta?.image
|
|
20
|
+
? resolveItems(settings.meta.image)
|
|
21
|
+
: null,
|
|
22
|
+
canonical: pageMeta?.canonicalURL ?? settings.meta?.canonicalURL ?? null,
|
|
23
|
+
private: pageMeta?.private ?? settings.meta?.private ?? false,
|
|
24
|
+
structuredData: {
|
|
25
|
+
settings: settings.meta?.structuredData ?? null,
|
|
26
|
+
page: pageMeta?.structuredData ?? null,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Other meta props that could change on page refresh.
|
|
33
|
+
*/
|
|
34
|
+
const site = $derived(settings.siteName?.trim() ?? siteName);
|
|
35
|
+
const locale = $derived(settings?.locale ?? 'en');
|
|
36
|
+
const social = $derived(settings?.social ?? {});
|
|
37
|
+
const codeInjectionSettings = $derived(settings?.codeInjection);
|
|
38
|
+
const socialLinks = $derived(Object.values(social).filter(Boolean) as string[]);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Generate structured data for the website.
|
|
42
|
+
*/
|
|
43
|
+
const websiteSchema = $derived.by(() => ({
|
|
44
|
+
'@context': 'https://schema.org',
|
|
45
|
+
'@type': 'WebSite',
|
|
46
|
+
name: siteName,
|
|
47
|
+
url: meta.canonical,
|
|
48
|
+
}));
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Generate structured data for the organisation.
|
|
52
|
+
*/
|
|
53
|
+
const organizationSchema = $derived.by(() => {
|
|
54
|
+
if (socialLinks.length === 0) return null;
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
'@context': 'https://schema.org',
|
|
58
|
+
'@type': 'Organization',
|
|
59
|
+
name: siteName,
|
|
60
|
+
...(meta.canonical ? { url: meta.canonical } : {}),
|
|
61
|
+
...(meta?.media?.url ? { logo: meta.media.url } : {}),
|
|
62
|
+
...(settings.tagLine || settings.meta?.description
|
|
63
|
+
? { description: settings.tagLine ?? settings.meta?.description }
|
|
64
|
+
: {}),
|
|
65
|
+
sameAs: socialLinks.filter((url) => url.startsWith('http')),
|
|
66
|
+
...(settings.contact?.email || settings.contact?.telephone
|
|
67
|
+
? {
|
|
68
|
+
contactPoint: [
|
|
69
|
+
{
|
|
70
|
+
'@type': 'ContactPoint',
|
|
71
|
+
...(settings.contact?.telephone
|
|
72
|
+
? { telephone: settings.contact.telephone }
|
|
73
|
+
: {}),
|
|
74
|
+
...(settings.contact?.email ? { email: settings.contact.email } : {}),
|
|
75
|
+
contactType: 'customer support',
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
}
|
|
79
|
+
: {}),
|
|
80
|
+
...(settings.address
|
|
81
|
+
? {
|
|
82
|
+
address: {
|
|
83
|
+
'@type': 'PostalAddress',
|
|
84
|
+
...(settings.address.line1
|
|
85
|
+
? { streetAddress: settings.address.line1 }
|
|
86
|
+
: {}),
|
|
87
|
+
...(settings.address.city
|
|
88
|
+
? { addressLocality: settings.address.city }
|
|
89
|
+
: {}),
|
|
90
|
+
...(settings.address.county
|
|
91
|
+
? { addressRegion: settings.address.county }
|
|
92
|
+
: {}),
|
|
93
|
+
...(settings.address.postcode
|
|
94
|
+
? { postalCode: settings.address.postcode }
|
|
95
|
+
: {}),
|
|
96
|
+
...(settings.address.country
|
|
97
|
+
? { addressCountry: settings.address.country }
|
|
98
|
+
: {}),
|
|
99
|
+
},
|
|
100
|
+
}
|
|
101
|
+
: {}),
|
|
102
|
+
};
|
|
103
|
+
});
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<!--
|
|
107
|
+
@component
|
|
108
|
+
|
|
109
|
+
PayloadSEO renders all head meta tags for a page, including Open Graph,
|
|
110
|
+
Twitter Card, canonical URL, structured data, and code injection from
|
|
111
|
+
Payload CMS settings.
|
|
112
|
+
|
|
113
|
+
@example
|
|
114
|
+
```svelte
|
|
115
|
+
<PayloadSEO
|
|
116
|
+
siteName="My Site"
|
|
117
|
+
settings={globalSettings}
|
|
118
|
+
pageMeta={page.meta}
|
|
119
|
+
/>
|
|
120
|
+
```
|
|
121
|
+
-->
|
|
122
|
+
<svelte:head>
|
|
123
|
+
<!-- Meta -->
|
|
124
|
+
<title>{meta.title} | {siteName}</title>
|
|
125
|
+
<meta name="description" content={meta.description} />
|
|
126
|
+
<!-- Canonical -->
|
|
127
|
+
{#if meta.canonical}
|
|
128
|
+
<link rel="canonical" href={meta.canonical} />
|
|
129
|
+
{/if}
|
|
130
|
+
<!-- No Index -->
|
|
131
|
+
{#if meta.private}
|
|
132
|
+
<meta name="robots" content="noindex" />
|
|
133
|
+
{/if}
|
|
134
|
+
<!-- Open Graph -->
|
|
135
|
+
<meta property="og:type" content="website" />
|
|
136
|
+
<meta property="og:title" content={meta.title} />
|
|
137
|
+
<meta property="og:description" content={meta.description} />
|
|
138
|
+
<meta property="og:site_name" content={site} />
|
|
139
|
+
<meta property="og:locale" content={locale} />
|
|
140
|
+
{#if meta.canonical}
|
|
141
|
+
<meta property="og:url" content={meta.canonical} />
|
|
142
|
+
{/if}
|
|
143
|
+
{#if meta.media}
|
|
144
|
+
{#if meta.media.url}
|
|
145
|
+
<meta property="og:image" content={meta.media.url} />
|
|
146
|
+
{/if}
|
|
147
|
+
{#if meta.media.alt}
|
|
148
|
+
<meta property="og:image:alt" content={meta.media.alt} />
|
|
149
|
+
{/if}
|
|
150
|
+
{#if meta.media.width}
|
|
151
|
+
<meta property="og:image:width" content={meta.media.width.toString()} />
|
|
152
|
+
{/if}
|
|
153
|
+
{#if meta.media.height}
|
|
154
|
+
<meta property="og:image:height" content={meta.media.height.toString()} />
|
|
155
|
+
{/if}
|
|
156
|
+
{#if meta.media.mimeType}
|
|
157
|
+
<meta property="og:image:type" content={meta.media.mimeType} />
|
|
158
|
+
{/if}
|
|
159
|
+
{/if}
|
|
160
|
+
<!-- Twitter Card -->
|
|
161
|
+
<meta name="twitter:card" content={meta?.media?.url ? 'summary_large_image' : 'summary'} />
|
|
162
|
+
<meta name="twitter:title" content={meta.title} />
|
|
163
|
+
<meta name="twitter:description" content={meta.description} />
|
|
164
|
+
{#if meta.media}
|
|
165
|
+
{#if meta.media.url}
|
|
166
|
+
<meta name="twitter:image" content={meta.media.url} />
|
|
167
|
+
{/if}
|
|
168
|
+
{#if meta.media.alt}
|
|
169
|
+
<meta name="twitter:image:alt" content={meta.media.alt} />
|
|
170
|
+
{/if}
|
|
171
|
+
{/if}
|
|
172
|
+
{#if social.x}
|
|
173
|
+
<meta name="twitter:site" content={social.x.startsWith('@') ? social.x : `@${social.x}`} />
|
|
174
|
+
{/if}
|
|
175
|
+
<!-- Structured Data - Settings -->
|
|
176
|
+
{#if meta.structuredData.settings}
|
|
177
|
+
{@html serializeSchema(meta.structuredData.settings)}
|
|
178
|
+
{/if}
|
|
179
|
+
<!-- Structured Data - Page -->
|
|
180
|
+
{#if meta.structuredData.page}
|
|
181
|
+
{@html serializeSchema(meta.structuredData.page)}
|
|
182
|
+
{/if}
|
|
183
|
+
<!-- Website Schema -->
|
|
184
|
+
{#if websiteSchema}
|
|
185
|
+
{@html serializeSchema(websiteSchema)}
|
|
186
|
+
{/if}
|
|
187
|
+
<!-- Social Organisation Schema -->
|
|
188
|
+
{#if organizationSchema}
|
|
189
|
+
{@html serializeSchema(organizationSchema)}
|
|
190
|
+
{/if}
|
|
191
|
+
<!-- Code Injection - Settings -->
|
|
192
|
+
{#if codeInjectionSettings?.head}
|
|
193
|
+
{@html codeInjectionSettings.head}
|
|
194
|
+
{/if}
|
|
195
|
+
</svelte:head>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PayloadSEOProps } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* PayloadSEO renders all head meta tags for a page, including Open Graph,
|
|
4
|
+
* Twitter Card, canonical URL, structured data, and code injection from
|
|
5
|
+
* Payload CMS settings.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```svelte
|
|
9
|
+
* <PayloadSEO
|
|
10
|
+
* siteName="My Site"
|
|
11
|
+
* settings={globalSettings}
|
|
12
|
+
* pageMeta={page.meta}
|
|
13
|
+
* />
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare const PayloadSEO: import("svelte").Component<PayloadSEOProps, {}, "">;
|
|
17
|
+
type PayloadSEO = ReturnType<typeof PayloadSEO>;
|
|
18
|
+
export default PayloadSEO;
|
|
19
|
+
//# sourceMappingURL=PayloadSEO.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PayloadSEO.svelte.d.ts","sourceRoot":"","sources":["../../../src/components/payload/PayloadSEO.svelte.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAyLlD;;;;;;;;;;;;;GAaG;AACH,QAAA,MAAM,UAAU,qDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as PayloadForm } from './PayloadForm.svelte';
|
|
2
2
|
export { default as PayloadMedia } from './PayloadMedia.svelte';
|
|
3
|
-
export
|
|
3
|
+
export { default as PayloadSEO } from './PayloadSEO.svelte';
|
|
4
|
+
export { default as PayloadFooter } from './PayloadFooter.svelte';
|
|
5
|
+
export { resolveItems } from './resolve.js';
|
|
6
|
+
export type { Media, MediaSizes, PayloadMediaProps, PayloadSEOProps, PayloadFooterProps, PayloadMeta, PayloadSettings, PayloadSocial, PayloadCodeInjection, } from './types.js';
|
|
4
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/payload/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,YAAY,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/payload/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACX,KAAK,EACL,UAAU,EACV,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,aAAa,EACb,oBAAoB,GACpB,MAAM,YAAY,CAAC"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { default as PayloadForm } from './PayloadForm.svelte';
|
|
2
2
|
export { default as PayloadMedia } from './PayloadMedia.svelte';
|
|
3
|
+
export { default as PayloadSEO } from './PayloadSEO.svelte';
|
|
4
|
+
export { default as PayloadFooter } from './PayloadFooter.svelte';
|
|
5
|
+
export { resolveItems } from './resolve.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a Payload relationship field value to its populated object.
|
|
3
|
+
* Returns null if the value is an unresolved ID (number), null or undefined.
|
|
4
|
+
*
|
|
5
|
+
* @param {number | null | undefined | T} item - The relationship field value to resolve.
|
|
6
|
+
* @returns {T | null} The populated object, or null if unresolved.
|
|
7
|
+
*/
|
|
8
|
+
export declare const resolveItems: <T>(item: number | null | undefined | T) => T | null;
|
|
9
|
+
//# sourceMappingURL=resolve.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../src/components/payload/resolve.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,CAAC,KAAG,CAAC,GAAG,IAGzE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a Payload relationship field value to its populated object.
|
|
3
|
+
* Returns null if the value is an unresolved ID (number), null or undefined.
|
|
4
|
+
*
|
|
5
|
+
* @param {number | null | undefined | T} item - The relationship field value to resolve.
|
|
6
|
+
* @returns {T | null} The populated object, or null if unresolved.
|
|
7
|
+
*/
|
|
8
|
+
export const resolveItems = (item) => {
|
|
9
|
+
if (item === null || item === undefined || typeof item === 'number')
|
|
10
|
+
return null;
|
|
11
|
+
return item;
|
|
12
|
+
};
|
|
@@ -30,4 +30,76 @@ export type Media = {
|
|
|
30
30
|
focalY?: number | null;
|
|
31
31
|
sizes?: MediaSizes;
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Props that the PayloadSEO component expects. Accepts site-level settings
|
|
35
|
+
* and an optional page meta object which is merged with higher priority.
|
|
36
|
+
*/
|
|
37
|
+
export type PayloadSEOProps = {
|
|
38
|
+
siteName: string;
|
|
39
|
+
settings: PayloadSettings;
|
|
40
|
+
pageMeta?: PayloadMeta;
|
|
41
|
+
pageCodeInjection?: PayloadCodeInjection;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Props that the PayloadFooter component expects.
|
|
45
|
+
* Renders code injection scripts for both settings and page level.
|
|
46
|
+
*/
|
|
47
|
+
export type PayloadFooterProps = {
|
|
48
|
+
settings: PayloadSettings;
|
|
49
|
+
pageCodeInjection?: PayloadCodeInjection;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Meta exported from the Payload SEO plugin. Appears on
|
|
53
|
+
* both page and settings level.
|
|
54
|
+
*/
|
|
55
|
+
export type PayloadMeta = {
|
|
56
|
+
title?: string | null;
|
|
57
|
+
description?: string | null;
|
|
58
|
+
image?: (number | null) | Media;
|
|
59
|
+
private?: boolean | null;
|
|
60
|
+
canonicalURL?: string | null;
|
|
61
|
+
structuredData?: unknown;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Settings compatible with the type generated in Payload
|
|
65
|
+
* under the webkit settings global.
|
|
66
|
+
*/
|
|
67
|
+
export type PayloadSettings = {
|
|
68
|
+
siteName?: string | null;
|
|
69
|
+
locale?: string;
|
|
70
|
+
tagLine?: string | null;
|
|
71
|
+
contact?: {
|
|
72
|
+
email?: string | null;
|
|
73
|
+
telephone?: string | null;
|
|
74
|
+
};
|
|
75
|
+
address?: {
|
|
76
|
+
line1?: string | null;
|
|
77
|
+
line2?: string | null;
|
|
78
|
+
city?: string | null;
|
|
79
|
+
county?: string | null;
|
|
80
|
+
postcode?: string | null;
|
|
81
|
+
country?: string | null;
|
|
82
|
+
};
|
|
83
|
+
meta?: PayloadMeta;
|
|
84
|
+
social?: PayloadSocial;
|
|
85
|
+
codeInjection?: PayloadCodeInjection;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Social links that appear in the organisation settings.
|
|
89
|
+
*/
|
|
90
|
+
export type PayloadSocial = {
|
|
91
|
+
linkedIn?: string | null;
|
|
92
|
+
x?: string | null;
|
|
93
|
+
facebook?: string | null;
|
|
94
|
+
instagram?: string | null;
|
|
95
|
+
youtube?: string | null;
|
|
96
|
+
tiktok?: string | null;
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Header and footer scripts to be injected.
|
|
100
|
+
*/
|
|
101
|
+
export type PayloadCodeInjection = {
|
|
102
|
+
head?: string | null;
|
|
103
|
+
footer?: string | null;
|
|
104
|
+
};
|
|
33
105
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/payload/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,MAAM,CAC9B,MAAM,EACJ,OAAO,CAAC;IACR,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,CAAC,GACF,SAAS,CACX,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,WAAW,CAAC,GAAG;IAC7D,IAAI,EAAE,KAAK,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK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QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,uBAAuB,CAAC;AACtC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/seo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { serializeSchema } from './ld-json.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialises a value as a JSON-LD script tag for embedding
|
|
3
|
+
* structured data in HTML.
|
|
4
|
+
*
|
|
5
|
+
* @param {unknown} thing - The structured data object to serialise.
|
|
6
|
+
* @returns {string} An application/ld+json script tag containing the serialised data.
|
|
7
|
+
*/
|
|
8
|
+
export declare const serializeSchema: (thing: unknown) => string;
|
|
9
|
+
//# sourceMappingURL=ld-json.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ld-json.d.ts","sourceRoot":"","sources":["../../../src/utils/seo/ld-json.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAAI,OAAO,OAAO,KAAG,MAEhD,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialises a value as a JSON-LD script tag for embedding
|
|
3
|
+
* structured data in HTML.
|
|
4
|
+
*
|
|
5
|
+
* @param {unknown} thing - The structured data object to serialise.
|
|
6
|
+
* @returns {string} An application/ld+json script tag containing the serialised data.
|
|
7
|
+
*/
|
|
8
|
+
export const serializeSchema = (thing) => {
|
|
9
|
+
return `<script type="application/ld+json">${JSON.stringify(thing)}</script>`;
|
|
10
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { serializeSchema } from './ld-json';
|
|
3
|
+
describe('serializeSchema', () => {
|
|
4
|
+
test('serialises a simple object to a JSON-LD script tag', () => {
|
|
5
|
+
const input = { '@context': 'https://schema.org', '@type': 'WebSite', name: 'Test' };
|
|
6
|
+
const got = serializeSchema(input);
|
|
7
|
+
expect(got).toBe('<script type="application/ld+json">{"@context":"https://schema.org","@type":"WebSite","name":"Test"}</script>');
|
|
8
|
+
});
|
|
9
|
+
test('serialises a string value', () => {
|
|
10
|
+
const got = serializeSchema('hello');
|
|
11
|
+
expect(got).toBe('<script type="application/ld+json">"hello"</script>');
|
|
12
|
+
});
|
|
13
|
+
test('serialises null', () => {
|
|
14
|
+
const got = serializeSchema(null);
|
|
15
|
+
expect(got).toBe('<script type="application/ld+json">null</script>');
|
|
16
|
+
});
|
|
17
|
+
test('serialises nested objects', () => {
|
|
18
|
+
const input = {
|
|
19
|
+
'@context': 'https://schema.org',
|
|
20
|
+
'@type': 'Organization',
|
|
21
|
+
address: {
|
|
22
|
+
'@type': 'PostalAddress',
|
|
23
|
+
streetAddress: '123 Main St',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
const got = serializeSchema(input);
|
|
27
|
+
expect(got).toContain('"@type":"Organization"');
|
|
28
|
+
expect(got).toContain('"streetAddress":"123 Main St"');
|
|
29
|
+
expect(got).toMatch(/^<script type="application\/ld\+json">.*<\/script>$/);
|
|
30
|
+
});
|
|
31
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ainsleydev/sveltekit-helper",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "SvelteKit utilities, components and helpers for ainsley.dev builds",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
"types": "./dist/utils/strings/index.d.ts",
|
|
58
58
|
"import": "./dist/utils/strings/index.js"
|
|
59
59
|
},
|
|
60
|
+
"./utils/seo": {
|
|
61
|
+
"types": "./dist/utils/seo/index.d.ts",
|
|
62
|
+
"import": "./dist/utils/seo/index.js"
|
|
63
|
+
},
|
|
60
64
|
"./package.json": "./package.json"
|
|
61
65
|
},
|
|
62
66
|
"files": [
|