@nekm/svelte-core 1.8.0 → 1.9.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/dist/seo.svelte +62 -28
- package/dist/seo.svelte.d.ts +7 -1
- package/package.json +9 -9
package/dist/seo.svelte
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import { page } from "$app/state";
|
|
3
|
+
import {
|
|
4
|
+
type QueryParams,
|
|
5
|
+
queryParamsCreate,
|
|
6
|
+
strTrimStart,
|
|
7
|
+
urlSetOrigin,
|
|
8
|
+
} from "@nekm/core";
|
|
3
9
|
|
|
4
10
|
export interface SeoCanonical {
|
|
5
11
|
readonly path?: string;
|
|
@@ -13,52 +19,73 @@
|
|
|
13
19
|
readonly mimeContentType: string;
|
|
14
20
|
}
|
|
15
21
|
|
|
22
|
+
export interface SeoTwitter {
|
|
23
|
+
readonly creator?: string;
|
|
24
|
+
readonly site?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
16
27
|
export interface SeoProps {
|
|
17
28
|
readonly siteTitle: string;
|
|
18
29
|
readonly pageTitle: string;
|
|
19
30
|
readonly description: string;
|
|
20
|
-
readonly origin
|
|
31
|
+
readonly origin?: string;
|
|
21
32
|
readonly icon: SeoIcon;
|
|
33
|
+
readonly additionalIcons: ReadonlyArray<SeoIcon>;
|
|
22
34
|
readonly canonical?: SeoCanonical;
|
|
23
35
|
readonly next?: SeoCanonical;
|
|
36
|
+
readonly twitter?: SeoTwitter;
|
|
24
37
|
}
|
|
25
38
|
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
const {
|
|
40
|
+
siteTitle,
|
|
41
|
+
pageTitle,
|
|
42
|
+
description,
|
|
43
|
+
icon,
|
|
44
|
+
additionalIcons,
|
|
45
|
+
canonical,
|
|
46
|
+
next,
|
|
47
|
+
origin: propsOrigin,
|
|
48
|
+
twitter,
|
|
49
|
+
}: SeoProps = $props();
|
|
30
50
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
51
|
+
function createCanonical(canonical: SeoCanonical): string | undefined {
|
|
52
|
+
if (!canonical.path) return origin;
|
|
34
53
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
54
|
+
const path = strTrimStart(canonical.path, "/");
|
|
55
|
+
const canonicalWithPath = `${origin}/${path}`;
|
|
38
56
|
|
|
39
|
-
if (canonical
|
|
40
|
-
const queryParamsStr = queryParamsCreate(canonical.queryParams)
|
|
41
|
-
url += `?${queryParamsStr}`;
|
|
42
|
-
}
|
|
57
|
+
if (!canonical.queryParams) return canonicalWithPath;
|
|
43
58
|
|
|
44
|
-
return
|
|
59
|
+
return `${canonicalWithPath}?${queryParamsCreate(canonical.queryParams)}`;
|
|
45
60
|
}
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
const iconHref = $derived
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const canonicalUrl = $derived(createCanonical(canonical, true));
|
|
55
|
-
const nextUrl = $derived(createCanonical(next));
|
|
62
|
+
const origin = $derived(propsOrigin ?? page.url.origin);
|
|
63
|
+
const iconHref = $derived(urlSetOrigin(origin, icon.href));
|
|
64
|
+
const canonicalUrl = $derived(
|
|
65
|
+
!canonical ? origin : createCanonical(canonical),
|
|
66
|
+
);
|
|
67
|
+
const nextUrl = $derived(!next ? undefined : createCanonical(next));
|
|
56
68
|
</script>
|
|
57
69
|
|
|
58
70
|
<svelte:head>
|
|
59
71
|
<title>{pageTitle} | {siteTitle}</title>
|
|
60
72
|
<meta name="description" content={description} />
|
|
61
73
|
<link rel="canonical" href={canonicalUrl} />
|
|
74
|
+
<link
|
|
75
|
+
rel="icon"
|
|
76
|
+
type={icon.mimeContentType}
|
|
77
|
+
sizes="{icon.width}x{icon.height}"
|
|
78
|
+
href={icon.href}
|
|
79
|
+
/>
|
|
80
|
+
|
|
81
|
+
{#each additionalIcons as icon}
|
|
82
|
+
<link
|
|
83
|
+
rel="icon"
|
|
84
|
+
type={icon.mimeContentType}
|
|
85
|
+
sizes="{icon.width}x{icon.height}"
|
|
86
|
+
href={icon.href}
|
|
87
|
+
/>
|
|
88
|
+
{/each}
|
|
62
89
|
|
|
63
90
|
{#if nextUrl}
|
|
64
91
|
<link rel="next" href={nextUrl} />
|
|
@@ -76,9 +103,16 @@
|
|
|
76
103
|
<meta property="og:url" content={canonicalUrl} />
|
|
77
104
|
<meta property="og:type" content="website" />
|
|
78
105
|
|
|
79
|
-
<meta name="twitter:card" content="summary_large_image"
|
|
106
|
+
<meta name="twitter:card" content="summary_large_image" />
|
|
80
107
|
<meta name="twitter:title" content={pageTitle} />
|
|
81
108
|
<meta name="twitter:description" content={description} />
|
|
82
109
|
<meta name="twitter:image" content={iconHref} />
|
|
83
|
-
|
|
110
|
+
|
|
111
|
+
{#if twitter?.creator}
|
|
112
|
+
<meta name="twitter:creator" content="@{twitter.creator}" />
|
|
113
|
+
{/if}
|
|
114
|
+
|
|
115
|
+
{#if twitter?.site}
|
|
116
|
+
<meta name="twitter:site" content="@{twitter.site}" />
|
|
117
|
+
{/if}
|
|
84
118
|
</svelte:head>
|
package/dist/seo.svelte.d.ts
CHANGED
|
@@ -9,14 +9,20 @@ export interface SeoIcon {
|
|
|
9
9
|
readonly width: number;
|
|
10
10
|
readonly mimeContentType: string;
|
|
11
11
|
}
|
|
12
|
+
export interface SeoTwitter {
|
|
13
|
+
readonly creator?: string;
|
|
14
|
+
readonly site?: string;
|
|
15
|
+
}
|
|
12
16
|
export interface SeoProps {
|
|
13
17
|
readonly siteTitle: string;
|
|
14
18
|
readonly pageTitle: string;
|
|
15
19
|
readonly description: string;
|
|
16
|
-
readonly origin
|
|
20
|
+
readonly origin?: string;
|
|
17
21
|
readonly icon: SeoIcon;
|
|
22
|
+
readonly additionalIcons: ReadonlyArray<SeoIcon>;
|
|
18
23
|
readonly canonical?: SeoCanonical;
|
|
19
24
|
readonly next?: SeoCanonical;
|
|
25
|
+
readonly twitter?: SeoTwitter;
|
|
20
26
|
}
|
|
21
27
|
declare const Seo: import("svelte").Component<SeoProps, {}, "">;
|
|
22
28
|
type Seo = ReturnType<typeof Seo>;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@nekm/svelte-core",
|
|
3
3
|
"description": "Code I find myself re-writing over-and-over, Svelte edition.",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.9.1",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite dev",
|
|
8
8
|
"build": "vite build && npm run prepack",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@sveltejs/adapter-auto": "^7.0.
|
|
37
|
+
"@sveltejs/adapter-auto": "^7.0.1",
|
|
38
38
|
"@sveltejs/package": "^2.5.7",
|
|
39
|
-
"@sveltejs/vite-plugin-svelte": "^6
|
|
40
|
-
"@types/node": "^25.0
|
|
41
|
-
"mongodb": "^7.1.
|
|
42
|
-
"publint": "^0.3.
|
|
43
|
-
"svelte-check": "^4.
|
|
39
|
+
"@sveltejs/vite-plugin-svelte": "^6",
|
|
40
|
+
"@types/node": "^25.5.0",
|
|
41
|
+
"mongodb": "^7.1.1",
|
|
42
|
+
"publint": "^0.3.18",
|
|
43
|
+
"svelte-check": "^4.4.5",
|
|
44
44
|
"svelte-kit-sessions": "^0.4.0",
|
|
45
|
-
"typescript": "^5
|
|
46
|
-
"vite": "^7
|
|
45
|
+
"typescript": "^5",
|
|
46
|
+
"vite": "^7",
|
|
47
47
|
"vite-plugin-devtools-json": "^1.0.0"
|
|
48
48
|
},
|
|
49
49
|
"keywords": [
|