@nekm/svelte-core 1.0.0 → 1.0.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/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export * from "./google-analytics.svelte";
1
+ export { default as GoogleAnalytics } from "./google-analytics.svelte";
2
2
  export * from "./google-analytics.js";
3
+ export { default as Seo } from "./seo.svelte";
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export * from "./google-analytics.svelte";
1
+ export { default as GoogleAnalytics } from "./google-analytics.svelte";
2
2
  export * from "./google-analytics.js";
3
+ export { default as Seo } from "./seo.svelte";
@@ -0,0 +1,76 @@
1
+ <script lang="ts">
2
+ import icon from "../assets/icon.png";
3
+ import {assets} from "$app/paths";
4
+
5
+ interface Canonical {
6
+ readonly path?: string;
7
+ readonly queryString?: string;
8
+ }
9
+
10
+ interface Props {
11
+ readonly appName: string;
12
+ readonly description: string;
13
+ readonly title: string;
14
+ readonly canonical?: Canonical;
15
+ readonly next?: Canonical;
16
+ }
17
+
18
+ const { appName, description, title, canonical, next }: Props = $props();
19
+
20
+ function createCanonical(canonical?: Canonical, includeBaseUrl = false): string | undefined {
21
+ let url;
22
+
23
+ if (canonical || includeBaseUrl) {
24
+ url = assets;
25
+ }
26
+
27
+ if (canonical?.path) {
28
+ url += `/${canonical.path}`;
29
+ }
30
+
31
+ if (canonical?.queryString) {
32
+ url += `?${canonical.queryString}`;
33
+ }
34
+
35
+ return url;
36
+ }
37
+
38
+ let canonicalUrl = $state(createCanonical(canonical, true));
39
+ let nextUrl = $state(createCanonical(next));
40
+
41
+ $effect(() => {
42
+ canonicalUrl = createCanonical(canonical, true);
43
+ });
44
+
45
+ $effect(() => {
46
+ nextUrl = createCanonical(next);
47
+ });
48
+ </script>
49
+
50
+ <svelte:head>
51
+ <title>{appName} &raquo; {title}</title>
52
+ <meta name="description" content={description} />
53
+ <link rel="canonical" href={canonicalUrl} />
54
+
55
+ {#if nextUrl}
56
+ <link rel="next" href={nextUrl} />
57
+ {/if}
58
+
59
+ <meta property="og:site_name" content={appName} />
60
+ <meta property="og:title" content={title} />
61
+ <meta property="og:description" content={description} />
62
+ <meta property="og:image" content={icon} />
63
+ <meta property="og:image:secure_url" content={icon} />
64
+ <meta property="og:image:width" content="1024" />
65
+ <meta property="og:image:height" content="1024" />
66
+ <meta property="og:image:type" content="image/png" />
67
+ <meta property="og:image:alt" content={`${appName} logo`} />
68
+ <meta property="og:url" content={canonicalUrl} />
69
+ <meta property="og:type" content="website" />
70
+
71
+ <meta name="twitter:card" content="summary_large_image">
72
+ <meta name="twitter:title" content={title} />
73
+ <meta name="twitter:description" content={description} />
74
+ <meta name="twitter:image" content={icon} />
75
+ <meta name="twitter:creator" content="@iamBraska" />
76
+ </svelte:head>
@@ -0,0 +1,14 @@
1
+ interface Canonical {
2
+ readonly path?: string;
3
+ readonly queryString?: string;
4
+ }
5
+ interface Props {
6
+ readonly appName: string;
7
+ readonly description: string;
8
+ readonly title: string;
9
+ readonly canonical?: Canonical;
10
+ readonly next?: Canonical;
11
+ }
12
+ declare const Seo: import("svelte").Component<Props, {}, "">;
13
+ type Seo = ReturnType<typeof Seo>;
14
+ export default Seo;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nekm/svelte-core",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",