{
+
+ return {
+ name: 'svelte-composably',
+
+ async load(id) {
+ if (id === 'virtual:content') {
+ const entries = discoverContentPaths();
+ const code = `
+ export default {
+ ${entries.map(p => `'${p}': () => import('virtual:content/${p}')`).join(',\n')}
+ };
+ `;
+ return code;
+
+ };
+
+ if (id.startsWith('virtual:content/')) {
+ const path = id.slice('virtual:content/'.length);
+ const page = await loadContent(path);
+
+ let code = `
+ export default ${JSON.stringify(page)};
+ `;
+ code = code.replace(/"component":"([^"]+)"/g, (_, path) =>
+ `"component":(await import('${componentRoot}/${path}.svelte')).default`);
+
+ return code;
+ }
+
+ return null;
+ },
+
+ resolveId(source) {
+ if (source.startsWith('virtual:content')) {
+ return source;
+ }
+ },
+
+ };
+}
diff --git a/package-lock.json b/package-lock.json
index cada6f3..e2e6558 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -21,6 +21,7 @@
"@testing-library/svelte": "^5.2.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.13.17",
+ "acorn": "^8.14.1",
"animate.css": "^4.1.1",
"daisyui": "^5.0.9",
"eslint": "^9.18.0",
@@ -32,6 +33,7 @@
"hastscript": "^9.0.1",
"js-yaml": "^4.1.0",
"jsdom": "^26.0.0",
+ "json5": "^2.2.3",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.11",
@@ -3925,6 +3927,19 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/json5": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz",
+ "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==",
+ "dev": true,
+ "license": "MIT",
+ "bin": {
+ "json5": "lib/cli.js"
+ },
+ "engines": {
+ "node": ">=6"
+ }
+ },
"node_modules/keyv": {
"version": "4.5.4",
"resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz",
diff --git a/package.json b/package.json
index 5f9dd45..528d6e4 100644
--- a/package.json
+++ b/package.json
@@ -29,6 +29,7 @@
"@testing-library/svelte": "^5.2.4",
"@types/js-yaml": "^4.0.9",
"@types/node": "^22.13.17",
+ "acorn": "^8.14.1",
"animate.css": "^4.1.1",
"daisyui": "^5.0.9",
"eslint": "^9.18.0",
@@ -40,6 +41,7 @@
"hastscript": "^9.0.1",
"js-yaml": "^4.1.0",
"jsdom": "^26.0.0",
+ "json5": "^2.2.3",
"prettier": "^3.4.2",
"prettier-plugin-svelte": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.11",
diff --git a/src/lib/components/Footer.svelte b/src/lib/components/Footer.svelte
index ef9ff6d..6e030d8 100644
--- a/src/lib/components/Footer.svelte
+++ b/src/lib/components/Footer.svelte
@@ -1,11 +1,10 @@
diff --git a/src/lib/components/Head.svelte b/src/lib/components/Head.svelte
index 514df92..6ae7765 100644
--- a/src/lib/components/Head.svelte
+++ b/src/lib/components/Head.svelte
@@ -1,12 +1,12 @@
diff --git a/src/lib/components/Hero.svelte b/src/lib/components/Hero.svelte
index fdb36a8..236fc7c 100644
--- a/src/lib/components/Hero.svelte
+++ b/src/lib/components/Hero.svelte
@@ -1,13 +1,10 @@
@@ -65,7 +62,7 @@
- {@html body.html}
+ {body}
{#if buttons}
diff --git a/src/lib/components/Nav.svelte b/src/lib/components/Nav.svelte
index 3f8c84f..f7667ff 100644
--- a/src/lib/components/Nav.svelte
+++ b/src/lib/components/Nav.svelte
@@ -1,12 +1,11 @@
diff --git a/src/lib/content/index.yaml b/src/lib/content/index.yaml
index e3f3e41..d912f66 100644
--- a/src/lib/content/index.yaml
+++ b/src/lib/content/index.yaml
@@ -5,7 +5,7 @@ components:
body: |
# NixOS-baserad infrastruktur till er tjänst!
En molnbyrå som hjälper människor och företag att
- förverkliga [idéer](https://example.com) och hantera sin IT-miljö.
+ förverkliga idéer och hantera sin IT-miljö.
Här hittar du konsulttjänster och decentraliseratde alternativ till
Google drive, Dropbox, iCloud, Zoom, AWS, Heroku med flera.
buttons:
diff --git a/src/routes/[...path]/+layout.svelte b/src/routes/[...path]/+layout.svelte
index ac781bd..b3befce 100644
--- a/src/routes/[...path]/+layout.svelte
+++ b/src/routes/[...path]/+layout.svelte
@@ -10,13 +10,6 @@
import Nav from '$lib/components/Nav.svelte';
import Footer from '$lib/components/Footer.svelte';
- const head = $derived({
- siteName: config.siteName,
- pageName: page.data.title,
- pagePath: page.url.pathname,
- siteUrl: config.siteUrl,
- siteDescription: config.siteDescription
- });
const nav = {
logo: config.logo,
@@ -34,7 +27,6 @@
let { children }: LayoutProps = $props();
-
diff --git a/src/routes/[...path]/+page.server.ts b/src/routes/[...path]/+page.server.ts
index 3c5dd6e..6ba2dc1 100644
--- a/src/routes/[...path]/+page.server.ts
+++ b/src/routes/[...path]/+page.server.ts
@@ -1,7 +1,3 @@
-import type { PageServerLoad } from './$types';
-import { loadPageContent, discoverContentPaths } from 'compis/content.loader';
-
-export const load: PageServerLoad = async ({ params }) =>
- await loadPageContent(params.path);
+import { discoverContentPaths } from 'compis/content.loader';
export const entries = () => discoverContentPaths().map((path) => ({ path }));
diff --git a/src/routes/[...path]/+page.ts b/src/routes/[...path]/+page.ts
index f417fe0..d35449e 100644
--- a/src/routes/[...path]/+page.ts
+++ b/src/routes/[...path]/+page.ts
@@ -1,10 +1,7 @@
-import type { PageContent } from 'compis/types';
import type { PageLoad } from './$types';
-import { resolvePage } from 'compis/component.loader';
-import { setComponentMap } from 'compis/component.loader';
+import content from 'virtual:content';
-const svelteComponents = import.meta.glob('$lib/components/**/*.svelte');
-
-setComponentMap(svelteComponents);
-
-export const load: PageLoad = ({ data }) => resolvePage(data as PageContent);
+export const load: PageLoad = async ({ params }) => {
+ const page = await content[params.path]();
+ return page;
+};
diff --git a/tsconfig.json b/tsconfig.json
index f4d0a0e..1f5796e 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -1,5 +1,6 @@
{
"extends": "./.svelte-kit/tsconfig.json",
+ "exclude": [ ".direnv" ],
"compilerOptions": {
"allowJs": true,
"checkJs": true,
diff --git a/vite.config.ts b/vite.config.ts
index fe19060..99a126f 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,15 +1,22 @@
-import Inspect from 'vite-plugin-inspect';
import tailwindcss from '@tailwindcss/vite';
+import composably from './compis/vite';
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
server: {
+ watch: {
+ ignored: [ '**/.direnv/**' ],
+ },
host: '0.0.0.0',
allowedHosts: true,
fs: {
allow: ['compis']
}
},
- plugins: [Inspect(), tailwindcss(), sveltekit()]
+ plugins: [
+ tailwindcss(),
+ sveltekit(),
+ composably(),
+ ]
});