diff --git a/demos/ai-chat/app/globals.css b/demos/ai-chat/app/globals.css index df29e2c..cb3aa81 100644 --- a/demos/ai-chat/app/globals.css +++ b/demos/ai-chat/app/globals.css @@ -2,15 +2,9 @@ @import "tw-animate-css"; @import "@btst/stack/plugins/ai-chat/css"; @import "@btst/stack/plugins/route-docs/css"; -/* WebContainers workaround: the WASM Tailwind scanner cannot traverse node_modules - * (https://github.com/tailwindlabs/tailwindcss/issues/18418). copy-stack-src.mjs - * (run via predev/prebuild) copies @btst/stack/src outside node_modules so Tailwind - * can scan it. Safe to remove once the upstream bug is fixed. */ +/* WebContainers workaround: the WASM Tailwind scanner cannot traverse node_modules (https://github.com/tailwindlabs/tailwindcss/issues/18418). copy-stack-src.mjs (run via dev/build) copies @btst/stack/src outside node_modules so Tailwind can scan it. Safe to remove once the upstream bug is fixed. */ @source "./.btst-stack-src/**/*.{ts,tsx}"; @source "./.btst-stack-ui/**/*.{ts,tsx}"; -/* Monorepo fallback: direct source path used in local development */ -@source "../../../packages/stack/src/**/*.{ts,tsx}"; -@source "../../../packages/ui/src/**/*.{ts,tsx}"; @custom-variant dark (&:is(.dark *)); diff --git a/demos/ai-chat/app/pages/layout.tsx b/demos/ai-chat/app/pages/layout.tsx index 3856470..6c94754 100644 --- a/demos/ai-chat/app/pages/layout.tsx +++ b/demos/ai-chat/app/pages/layout.tsx @@ -9,7 +9,7 @@ import type { AiChatPluginOverrides } from "@btst/stack/plugins/ai-chat/client"; import { getOrCreateQueryClient } from "@/lib/query-client"; type PluginOverrides = { - aiChat: AiChatPluginOverrides; + "ai-chat": AiChatPluginOverrides; }; const hasApiKey = @@ -33,7 +33,7 @@ export default function PagesLayout({ basePath="/pages" overrides={{ - aiChat: { + "ai-chat": { apiBaseURL: baseURL, apiBasePath: "/api/data", mode: "public", diff --git a/demos/ai-chat/copy-stack-src.mjs b/demos/ai-chat/copy-stack-src.mjs index dc457f0..eca1c4d 100644 --- a/demos/ai-chat/copy-stack-src.mjs +++ b/demos/ai-chat/copy-stack-src.mjs @@ -12,10 +12,10 @@ import { cp, mkdir, rm } from "fs/promises"; import { existsSync } from "fs"; const src = "node_modules/@btst/stack/src"; -const dest = ".btst-stack-src"; +const dest = "app/.btst-stack-src"; const uiSrc = "node_modules/@btst/stack/dist/packages/ui"; -const uiDest = ".btst-stack-ui"; +const uiDest = "app/.btst-stack-ui"; if (!existsSync(src)) { // Likely running in the monorepo where the workspace symlink does not expose diff --git a/demos/blog/app/globals.css b/demos/blog/app/globals.css index 2829890..e183a2c 100644 --- a/demos/blog/app/globals.css +++ b/demos/blog/app/globals.css @@ -2,15 +2,9 @@ @import "tw-animate-css"; @import "@btst/stack/plugins/blog/css"; @import "@btst/stack/plugins/route-docs/css"; -/* WebContainers workaround: the WASM Tailwind scanner cannot traverse node_modules - * (https://github.com/tailwindlabs/tailwindcss/issues/18418). copy-stack-src.mjs - * (run via predev/prebuild) copies @btst/stack/src outside node_modules so Tailwind - * can scan it. Safe to remove once the upstream bug is fixed. */ +/* WebContainers workaround: the WASM Tailwind scanner cannot traverse node_modules (https://github.com/tailwindlabs/tailwindcss/issues/18418). copy-stack-src.mjs (run via dev/build) copies @btst/stack/src outside node_modules so Tailwind can scan it. Safe to remove once the upstream bug is fixed. */ @source "./.btst-stack-src/**/*.{ts,tsx}"; @source "./.btst-stack-ui/**/*.{ts,tsx}"; -/* Monorepo fallback: direct source path used in local development */ -@source "../../../packages/stack/src/**/*.{ts,tsx}"; -@source "../../../packages/ui/src/**/*.{ts,tsx}"; @custom-variant dark (&:is(.dark *)); diff --git a/demos/blog/copy-stack-src.mjs b/demos/blog/copy-stack-src.mjs index dc457f0..eca1c4d 100644 --- a/demos/blog/copy-stack-src.mjs +++ b/demos/blog/copy-stack-src.mjs @@ -12,10 +12,10 @@ import { cp, mkdir, rm } from "fs/promises"; import { existsSync } from "fs"; const src = "node_modules/@btst/stack/src"; -const dest = ".btst-stack-src"; +const dest = "app/.btst-stack-src"; const uiSrc = "node_modules/@btst/stack/dist/packages/ui"; -const uiDest = ".btst-stack-ui"; +const uiDest = "app/.btst-stack-ui"; if (!existsSync(src)) { // Likely running in the monorepo where the workspace symlink does not expose diff --git a/demos/cms/app/globals.css b/demos/cms/app/globals.css index 5b5e523..e14b130 100644 --- a/demos/cms/app/globals.css +++ b/demos/cms/app/globals.css @@ -2,15 +2,9 @@ @import "tw-animate-css"; @import "@btst/stack/plugins/cms/css"; @import "@btst/stack/plugins/route-docs/css"; -/* WebContainers workaround: the WASM Tailwind scanner cannot traverse node_modules - * (https://github.com/tailwindlabs/tailwindcss/issues/18418). copy-stack-src.mjs - * (run via predev/prebuild) copies @btst/stack/src outside node_modules so Tailwind - * can scan it. Safe to remove once the upstream bug is fixed. */ +/* WebContainers workaround: the WASM Tailwind scanner cannot traverse node_modules (https://github.com/tailwindlabs/tailwindcss/issues/18418). copy-stack-src.mjs (run via dev/build) copies @btst/stack/src outside node_modules so Tailwind can scan it. Safe to remove once the upstream bug is fixed. */ @source "./.btst-stack-src/**/*.{ts,tsx}"; @source "./.btst-stack-ui/**/*.{ts,tsx}"; -/* Monorepo fallback: direct source path used in local development */ -@source "../../../packages/stack/src/**/*.{ts,tsx}"; -@source "../../../packages/ui/src/**/*.{ts,tsx}"; @custom-variant dark (&:is(.dark *)); diff --git a/demos/cms/app/pages/articles/[slug]/page.tsx b/demos/cms/app/pages/articles/[slug]/page.tsx new file mode 100644 index 0000000..92ae0e9 --- /dev/null +++ b/demos/cms/app/pages/articles/[slug]/page.tsx @@ -0,0 +1,82 @@ +import { myStack } from "@/lib/stack"; +import Link from "next/link"; +import { notFound } from "next/navigation"; +import type { Metadata } from "next"; + +export const dynamic = "force-dynamic"; + +type ArticleData = { + title: string; + summary: string; + body: string; + publishedAt?: string; + published: boolean; +}; + +export async function generateMetadata({ + params, +}: { + params: Promise<{ slug: string }>; +}): Promise { + const { slug } = await params; + const item = await myStack.api.cms.getContentItemBySlug("article", slug); + if (!item) return { title: "Not Found" }; + const data = item.parsedData as ArticleData; + return { + title: data.title, + description: data.summary, + }; +} + +export default async function ArticlePage({ + params, +}: { + params: Promise<{ slug: string }>; +}) { + const { slug } = await params; + const item = await myStack.api.cms.getContentItemBySlug("article", slug); + + if (!item) notFound(); + + const data = item.parsedData as ArticleData; + + return ( +
+ + ← All articles + + +
+
+

{data.title}

+ {data.publishedAt && ( + + )} +
+ +

+ {data.summary} +

+ +
+ {data.body.split("\n\n").map((paragraph, i) => + paragraph.trim() ? ( +

+ {paragraph.trim()} +

+ ) : null, + )} +
+
+
+ ); +} diff --git a/demos/cms/app/pages/articles/page.tsx b/demos/cms/app/pages/articles/page.tsx new file mode 100644 index 0000000..2c8ec79 --- /dev/null +++ b/demos/cms/app/pages/articles/page.tsx @@ -0,0 +1,67 @@ +import { myStack } from "@/lib/stack"; +import Link from "next/link"; + +export const dynamic = "force-dynamic"; + +type ArticleData = { + title: string; + summary: string; + body: string; + publishedAt?: string; + published: boolean; +}; + +export default async function ArticlesPage() { + const { items } = await myStack.api.cms.getAllContentItems("article"); + const published = items.filter( + (item) => (item.parsedData as ArticleData).published, + ); + + return ( +
+
+

Articles

+

+ Content managed with the BTST CMS plugin. +

+
+ + {published.length === 0 ? ( +

No published articles yet.

+ ) : ( +
+ {published.map((item) => { + const data = item.parsedData as ArticleData; + return ( + +
+
+

+ {data.title} +

+

+ {data.summary} +

+
+ {data.publishedAt && ( + + )} +
+ + ); + })} +
+ )} +
+ ); +} diff --git a/demos/cms/app/pages/layout.tsx b/demos/cms/app/pages/layout.tsx index 28ccac9..a4d9c73 100644 --- a/demos/cms/app/pages/layout.tsx +++ b/demos/cms/app/pages/layout.tsx @@ -47,6 +47,12 @@ export default function PagesLayout({ BTST CMS Demo
+ + Articles + basePath="/pages" overrides={{ - formBuilder: { + "form-builder": { apiBaseURL: baseURL, apiBasePath: "/api/data", navigate: (path) => router.push(path), @@ -41,18 +41,24 @@ export default function PagesLayout({