@opinly/sveltekit 1.0.0-alpha.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.
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ import { buildMetadata, type OpinlyConfig, type SeoResolved } from "@opinly/shared";
3
+
4
+ let {
5
+ resolved,
6
+ config,
7
+ jsonLd = [],
8
+ }: { resolved: SeoResolved; config: OpinlyConfig; jsonLd?: object[] } = $props();
9
+
10
+ const meta = $derived(buildMetadata(resolved, config));
11
+
12
+ // JSON-LD must be injected via {@html}; the closing tag is escaped so Svelte's
13
+ // compiler doesn't treat it as the end of this component's <script> block.
14
+ const ldScript = (d: object) =>
15
+ `<script type="application/ld+json">${JSON.stringify(d)}<\/script>`;
16
+ </script>
17
+
18
+ <svelte:head>
19
+ <title>{meta.title}</title>
20
+ {#if meta.description}<meta name="description" content={meta.description} />{/if}
21
+ <meta property="og:title" content={meta.title} />
22
+ {#if meta.description}<meta property="og:description" content={meta.description} />{/if}
23
+ {#if meta.ogType}<meta property="og:type" content={meta.ogType} />{/if}
24
+ {#if meta.ogImage}<meta property="og:image" content={meta.ogImage} />{/if}
25
+ {#if meta.canonicalUrl}<link rel="canonical" href={meta.canonicalUrl} />{/if}
26
+ {#each jsonLd as d}
27
+ <!-- eslint-disable-next-line svelte/no-at-html-tags -->
28
+ {@html ldScript(d)}
29
+ {/each}
30
+ </svelte:head>
@@ -0,0 +1,9 @@
1
+ import { type OpinlyConfig, type SeoResolved } from "@opinly/shared";
2
+ type $$ComponentProps = {
3
+ resolved: SeoResolved;
4
+ config: OpinlyConfig;
5
+ jsonLd?: object[];
6
+ };
7
+ declare const OpinlySeo: import("svelte").Component<$$ComponentProps, {}, "">;
8
+ type OpinlySeo = ReturnType<typeof OpinlySeo>;
9
+ export default OpinlySeo;
@@ -0,0 +1,2 @@
1
+ export { default as OpinlySeo } from "./OpinlySeo.svelte";
2
+ export type { OpinlyConfig, SeoResolved, OpinlyMeta } from "@opinly/shared";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default as OpinlySeo } from "./OpinlySeo.svelte";
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@opinly/sveltekit",
3
+ "description": "SvelteKit SEO for Opinly content — <OpinlySeo> renders <svelte:head>.",
4
+ "version": "1.0.0-alpha.0",
5
+ "private": false,
6
+ "type": "module",
7
+ "svelte": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "svelte": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "dependencies": {
17
+ "@opinly/shared": "1.0.0-alpha.0"
18
+ },
19
+ "peerDependencies": {
20
+ "svelte": "^4.0.0 || ^5.0.0"
21
+ },
22
+ "devDependencies": {
23
+ "@sveltejs/package": "^2.3.0",
24
+ "@sveltejs/vite-plugin-svelte": "^4.0.0",
25
+ "svelte": "^5.1.0",
26
+ "svelte-check": "^4.0.0",
27
+ "typescript": "^5.3.3"
28
+ },
29
+ "engines": {
30
+ "node": ">=16"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "sideEffects": [
39
+ "**/*.svelte"
40
+ ],
41
+ "scripts": {
42
+ "build": "svelte-package",
43
+ "check-types": "svelte-check --tsconfig ./tsconfig.json",
44
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
45
+ }
46
+ }