@basalf/cms-next 0.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.
Files changed (2) hide show
  1. package/README.md +87 -0
  2. package/package.json +37 -0
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # @basalf/cms-next
2
+
3
+ Next.js (App Router) components to render a published [`@basalf/cms`](../cms) page by `slug` + `locale`. Server-only.
4
+
5
+ ```tsx
6
+ import { Page } from "@basalf/cms-next";
7
+
8
+ export default function PricingPage() {
9
+ return <Page slug="pricing" locale="en" url="https://example.com/en/pricing" />;
10
+ }
11
+ ```
12
+
13
+ That's it — `Page` fetches the CMS page for that slug/locale, renders its content blocks (text, list, image, table, faq, headings, related pages, ...), and emits Article/FAQ JSON-LD. Calls Next's `notFound()` if no page matches.
14
+
15
+ ## Setup
16
+
17
+ ### 1. Env var (server-only)
18
+
19
+ ```
20
+ BASALF_CMS_TOKEN=eyJhbGciOi...
21
+ ```
22
+
23
+ Same token you'd pass to `new CMS(token)` from `@basalf/cms` — it's scoped to one organization/website. `Page`, `getPageMetadata`, `getAllPages` and `getPageBySlug` all import [`server-only`](https://www.npmjs.com/package/server-only), so bundling any of them into a Client Component throws a build error instead of leaking the token to the browser.
24
+
25
+ ### 2. Tailwind
26
+
27
+ This package ships **no CSS and no Tailwind config of its own** — its components only reference Tailwind utility classes that must already be defined by your app's Tailwind setup (the same design-token classes used across Basalf apps, from `@repo/ui`'s `createTailwindConfig`):
28
+
29
+ - Colors (each backed by a `hsl(var(--token))` CSS var): `background`/`foreground`, `muted`/`muted-foreground`, `border`, `card`/`card-foreground`, `info`/`info-foreground`
30
+ - Used as: `text-foreground`, `text-muted-foreground`, `bg-muted`, `bg-muted/30`, `hover:bg-muted/50`, `border-border`, `bg-card`, `hover:border-info/60`, plus one arbitrary value `hover:shadow-[0_4px_16px_-4px_hsl(var(--info)/0.25)]`
31
+ - Everything else used is stock Tailwind (`space-y-4`, `rounded-lg`, `aspect-video`, `list-disc`, etc.)
32
+
33
+ If your app already uses `@repo/ui/tailwind.config` (every Basalf app does), the tokens exist — you only need to make sure Tailwind's `content` globs actually scan this package's compiled output, otherwise the classes above get purged:
34
+
35
+ ```ts
36
+ // apps/<app>/tailwind.config.ts
37
+ content: [
38
+ "./src/**/*.{ts,tsx}",
39
+ "../../packages/ui/src/**/*.{ts,tsx}",
40
+ // ...
41
+ "../../packages/cms-next/dist/**/*.js", // workspace usage
42
+ "../../node_modules/@basalf/cms-next/dist/**/*.js", // pure npm usage
43
+ ],
44
+ ```
45
+
46
+ If you're consuming this from a non-Basalf app (plain npm install, no `@repo/ui` preset), define these color tokens yourself — see `packages/ui/src/tailwind.config.ts` for the exact mapping to copy.
47
+
48
+ ## API
49
+
50
+ ### `<Page />`
51
+
52
+ ```tsx
53
+ type PageProps = {
54
+ slug: string;
55
+ locale: string;
56
+ url: string; // canonical URL, used in JSON-LD
57
+ getHref?: (slug: string, locale: string) => string; // default: `/{locale}/{slug}`
58
+ imageUrl?: string; // Article JSON-LD image
59
+ author?: { name: string; url?: string }; // Article JSON-LD author/publisher
60
+ className?: string; // appended to the outer <article>
61
+ };
62
+ ```
63
+
64
+ `getHref` controls how links to *related* pages are built — this package doesn't know your routing, so pass your own (e.g. `(slug, locale) => \`/${locale}/service-provider/${orgId}/blog/${slug}\`` for book-style routes).
65
+
66
+ ### `getPageMetadata(slug, locale, options?)`
67
+
68
+ Drop into `generateMetadata` for the matching route:
69
+
70
+ ```tsx
71
+ export async function generateMetadata({ params }) {
72
+ const { slug, locale } = await params;
73
+ return getPageMetadata(slug, locale, { image: "https://example.com/og.png" });
74
+ }
75
+ ```
76
+
77
+ ### `getAllPages(locale?)` / `getPageBySlug(slug, locale)`
78
+
79
+ Lower-level data helpers — use for `generateStaticParams`, sitemaps, or building your own listing page.
80
+
81
+ ### `ArticleSchema` / `FaqSchema`
82
+
83
+ The JSON-LD components `Page` renders internally — exported in case you need them standalone.
84
+
85
+ ## Supported blocks
86
+
87
+ `description`, `text`, `heading` (h2/h3), `list` (ordered/unordered), `image`, `faq`, `table`, `space`, `related` — same shape as `@basalf/cms`'s `Block` type.
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@basalf/cms-next",
3
+ "version": "0.0.1",
4
+ "type": "module",
5
+ "exports": {
6
+ ".": {
7
+ "types": "./dist/index.d.ts",
8
+ "import": "./dist/index.js"
9
+ }
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "dependencies": {
18
+ "server-only": "^0.0.1",
19
+ "@basalf/cms": "0.0.6"
20
+ },
21
+ "peerDependencies": {
22
+ "next": "^14 || ^15 || ^16",
23
+ "react": "^18 || ^19"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^22.0.0",
27
+ "@types/react": "^19.0.0",
28
+ "next": "^16.2.0",
29
+ "react": "19.2.8",
30
+ "tsup": "^8.0.0",
31
+ "typescript": "^5.6.0"
32
+ },
33
+ "scripts": {
34
+ "build": "tsup",
35
+ "dev": "tsup --watch"
36
+ }
37
+ }