@wunderweb/next 0.0.0-stage → 0.5.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/LICENSE +21 -0
- package/dist/index.d.mts +47 -0
- package/dist/index.mjs +87 -0
- package/dist/sitemap.d.mts +5 -0
- package/dist/sitemap.mjs +15 -0
- package/dist/source-C_wHroCk.mjs +10 -0
- package/dist/source-WfL8LJKf.d.mts +6 -0
- package/package.json +45 -3
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 wunderwerk software GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { a as defaultSource, i as SourcePage, n as PageEntry, o as fileSource, r as SiteIndex, t as ContentSource } from "./source-WfL8LJKf.mjs";
|
|
2
|
+
import { Registry } from "@wunderweb/react";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { LoadedSite } from "@wunderweb/core";
|
|
5
|
+
import { Metadata } from "next";
|
|
6
|
+
//#region src/site.d.ts
|
|
7
|
+
type Loaded = LoadedSite;
|
|
8
|
+
/**
|
|
9
|
+
* Loads and validates the site (throws on content errors). Cached once per
|
|
10
|
+
* process in production; reloaded per call in dev so content edits show up.
|
|
11
|
+
*/
|
|
12
|
+
export declare function site(root?: string): Loaded;
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/index.d.ts
|
|
15
|
+
export interface RouteParams {
|
|
16
|
+
slug?: string[];
|
|
17
|
+
}
|
|
18
|
+
/** URL of the catch-all params: undefined → "/", ["en", "about"] → "/en/about". */
|
|
19
|
+
export declare function urlOf(params: RouteParams): string;
|
|
20
|
+
type Props = {
|
|
21
|
+
params: Promise<RouteParams>;
|
|
22
|
+
};
|
|
23
|
+
export interface PageOptions {
|
|
24
|
+
registry: Registry;
|
|
25
|
+
/** Default: the project files. */
|
|
26
|
+
source?: ContentSource;
|
|
27
|
+
}
|
|
28
|
+
export declare function createPage({ registry, source }: PageOptions): {
|
|
29
|
+
generateStaticParams(): Promise<RouteParams[]>;
|
|
30
|
+
generateMetadata({ params }: Props): Promise<Metadata>;
|
|
31
|
+
Page({ params }: Props): Promise<import("react").JSX.Element>;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Root layout of the catch-all route: <html lang> is the page's locale.
|
|
35
|
+
* `htmlClassName` carries font variables (next/font), so theme variables on
|
|
36
|
+
* :root can reference them.
|
|
37
|
+
*/
|
|
38
|
+
export declare function createLayout(opts?: {
|
|
39
|
+
htmlClassName?: string;
|
|
40
|
+
bodyClassName?: string;
|
|
41
|
+
source?: ContentSource;
|
|
42
|
+
}): ({ children, params }: {
|
|
43
|
+
children: ReactNode;
|
|
44
|
+
params: Promise<RouteParams>;
|
|
45
|
+
}) => Promise<import("react").JSX.Element>;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { type ContentSource, type PageEntry, type SiteIndex, type SourcePage, defaultSource, fileSource };
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { n as fileSource, t as defaultSource } from "./source-C_wHroCk.mjs";
|
|
2
|
+
import { Page } from "@wunderweb/react";
|
|
3
|
+
import { notFound } from "next/navigation.js";
|
|
4
|
+
import { cache } from "react";
|
|
5
|
+
import { loadProjectSite } from "@wunderweb/core";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/site.ts
|
|
8
|
+
/**
|
|
9
|
+
* Loads and validates the site (throws on content errors). Cached once per
|
|
10
|
+
* process in production; reloaded per call in dev so content edits show up.
|
|
11
|
+
*/
|
|
12
|
+
function site(root) {
|
|
13
|
+
return loadProjectSite(root);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/index.tsx
|
|
17
|
+
/** URL of the catch-all params: undefined → "/", ["en", "about"] → "/en/about". */
|
|
18
|
+
function urlOf(params) {
|
|
19
|
+
return `/${(params.slug ?? []).map((p) => decodeURIComponent(p)).join("/")}`;
|
|
20
|
+
}
|
|
21
|
+
/** One load per source and URL per render: layout, metadata and page share it. */
|
|
22
|
+
const load = cache((source, url) => source.page(url));
|
|
23
|
+
async function pageFor(source, params) {
|
|
24
|
+
const found = await load(source, urlOf(params));
|
|
25
|
+
if (!found) notFound();
|
|
26
|
+
return found;
|
|
27
|
+
}
|
|
28
|
+
function createPage({ registry, source = defaultSource() }) {
|
|
29
|
+
return {
|
|
30
|
+
async generateStaticParams() {
|
|
31
|
+
return (await source.index()).pages.map((p) => ({ slug: p.url === "/" ? [] : p.url.slice(1).split("/") }));
|
|
32
|
+
},
|
|
33
|
+
async generateMetadata({ params }) {
|
|
34
|
+
const { page, config } = await pageFor(source, await params);
|
|
35
|
+
const siteUrl = config.siteUrl;
|
|
36
|
+
const image = page.image;
|
|
37
|
+
const meta = {
|
|
38
|
+
title: page.title,
|
|
39
|
+
alternates: {
|
|
40
|
+
canonical: page.url,
|
|
41
|
+
languages: page.alternates
|
|
42
|
+
},
|
|
43
|
+
robots: page.noindex ? {
|
|
44
|
+
index: false,
|
|
45
|
+
follow: true
|
|
46
|
+
} : null
|
|
47
|
+
};
|
|
48
|
+
if (siteUrl) meta.metadataBase = new URL(siteUrl);
|
|
49
|
+
if (page.description) meta.description = page.description;
|
|
50
|
+
if (image?.url) meta.openGraph = { images: [{
|
|
51
|
+
url: image.url,
|
|
52
|
+
...image.width ? { width: image.width } : {},
|
|
53
|
+
...image.height ? { height: image.height } : {}
|
|
54
|
+
}] };
|
|
55
|
+
return meta;
|
|
56
|
+
},
|
|
57
|
+
async Page({ params }) {
|
|
58
|
+
const { page, breakpoints } = await pageFor(source, await params);
|
|
59
|
+
return /* @__PURE__ */ jsx(Page, {
|
|
60
|
+
page,
|
|
61
|
+
registry,
|
|
62
|
+
breakpoints
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Root layout of the catch-all route: <html lang> is the page's locale.
|
|
69
|
+
* `htmlClassName` carries font variables (next/font), so theme variables on
|
|
70
|
+
* :root can reference them.
|
|
71
|
+
*/
|
|
72
|
+
function createLayout(opts = {}) {
|
|
73
|
+
const source = opts.source ?? defaultSource();
|
|
74
|
+
return async function Layout({ children, params }) {
|
|
75
|
+
const lang = (await load(source, urlOf(await params)))?.page.locale ?? (await source.index()).config.defaultLocale;
|
|
76
|
+
return /* @__PURE__ */ jsx("html", {
|
|
77
|
+
lang,
|
|
78
|
+
className: opts.htmlClassName,
|
|
79
|
+
children: /* @__PURE__ */ jsx("body", {
|
|
80
|
+
className: opts.bodyClassName,
|
|
81
|
+
children
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { createLayout, createPage, defaultSource, fileSource, site, urlOf };
|
package/dist/sitemap.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { t as defaultSource } from "./source-C_wHroCk.mjs";
|
|
2
|
+
//#region src/sitemap.ts
|
|
3
|
+
function createSitemap(source = defaultSource()) {
|
|
4
|
+
return async function sitemap() {
|
|
5
|
+
const { config, pages } = await source.index();
|
|
6
|
+
const base = config.siteUrl?.replace(/\/$/, "") ?? "";
|
|
7
|
+
const abs = (u) => `${base}${u}`;
|
|
8
|
+
return pages.filter((p) => !p.noindex).map((p) => ({
|
|
9
|
+
url: abs(p.url),
|
|
10
|
+
alternates: { languages: Object.fromEntries(Object.entries(p.alternates).map(([l, u]) => [l, abs(u)])) }
|
|
11
|
+
}));
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { createSitemap };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { fileSource, fileSource as fileSource$1 } from "@wunderweb/core";
|
|
2
|
+
//#region src/source.ts
|
|
3
|
+
let fallback;
|
|
4
|
+
/** The project's files (fileSource()). */
|
|
5
|
+
function defaultSource() {
|
|
6
|
+
fallback ??= fileSource();
|
|
7
|
+
return fallback;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { fileSource$1 as n, defaultSource as t };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ContentSource, ContentSource as ContentSource$1, PageEntry, SiteIndex, SourcePage, fileSource as fileSource$1 } from "@wunderweb/core";
|
|
2
|
+
//#region src/source.d.ts
|
|
3
|
+
/** The project's files (fileSource()). */
|
|
4
|
+
declare function defaultSource(): ContentSource;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { defaultSource as a, SourcePage as i, PageEntry as n, fileSource$1 as o, SiteIndex as r, ContentSource$1 as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,48 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wunderweb/next",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "Next.js 16 App Router adapter.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/wunderwerkio/wunderweb.git",
|
|
10
|
+
"directory": "packages/next"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org",
|
|
14
|
+
"access": "public",
|
|
15
|
+
"provenance": true
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.mts",
|
|
23
|
+
"import": "./dist/index.mjs"
|
|
24
|
+
},
|
|
25
|
+
"./sitemap": {
|
|
26
|
+
"types": "./dist/sitemap.d.mts",
|
|
27
|
+
"import": "./dist/sitemap.mjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@wunderweb/core": "0.5.0",
|
|
32
|
+
"@wunderweb/react": "0.5.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"next": "^16",
|
|
36
|
+
"react": "^19"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@types/react": "19.3.0",
|
|
40
|
+
"next": "^16.3.6",
|
|
41
|
+
"react": "^19.3.0",
|
|
42
|
+
"react-dom": "19.3.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsdown src/index.tsx src/sitemap.ts --dts --format esm --external next --external react",
|
|
46
|
+
"typecheck": "tsc -p ."
|
|
47
|
+
}
|
|
6
48
|
}
|
package/README.md
DELETED