-
Notifications
You must be signed in to change notification settings - Fork 18
feat: add routes list to demo pages #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3f7066e
feat: enhance demo pages with structured route navigation and update …
olliethedev 0a83b77
lint: fix
olliethedev 80827ce
chore: streamline copy-stack-src script
olliethedev 5283cdc
chore: update CSS imports in demo projects to use correct paths
olliethedev db54345
chore: enhance copy-stack-src script to conditionally copy workspace-…
olliethedev e185534
feat: refactor demo pages to dynamically generate route groups and im…
olliethedev b22f972
chore: update @btst/stack dependency to version 2.5.3 across all demo…
olliethedev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,81 @@ | ||
| export default function Home() { | ||
| return null; | ||
| import Link from "next/link"; | ||
| import { getOrCreateQueryClient } from "@/lib/query-client"; | ||
| import { getStackClient } from "@/lib/stack-client"; | ||
| import { generateSchema } from "@btst/stack/plugins/route-docs/client"; | ||
|
|
||
| type RouteItem = { label: string; path: string }; | ||
| type RouteGroup = { heading: string; routes: RouteItem[] }; | ||
|
|
||
| const SITE_BASE_PATH = "/pages"; | ||
|
|
||
| function routeKeyToLabel(key: string): string { | ||
| return key | ||
| .replace(/([A-Z])/g, " $1") | ||
| .replace(/^./, (s) => s.toUpperCase()) | ||
| .trim(); | ||
| } | ||
|
|
||
| export default async function Home() { | ||
| const queryClient = getOrCreateQueryClient(); | ||
| getStackClient(queryClient); | ||
| const schema = await generateSchema(); | ||
|
|
||
| const aiChatPlugin = schema.plugins.find((p) => p.key === "aiChat"); | ||
| const staticChatRoutes: RouteItem[] = | ||
| aiChatPlugin?.routes | ||
| .filter((r) => r.pathParams.length === 0) | ||
| .map((r) => ({ | ||
| label: routeKeyToLabel(r.key), | ||
| path: `${SITE_BASE_PATH}${r.path}`, | ||
| })) ?? []; | ||
|
|
||
| const groups: RouteGroup[] = [ | ||
| { heading: "Chat", routes: staticChatRoutes }, | ||
| { | ||
| heading: "Docs", | ||
| routes: [ | ||
| { label: "Route Docs", path: `${SITE_BASE_PATH}/route-docs` }, | ||
| { label: "API Reference", path: "/api/data/reference" }, | ||
| ], | ||
| }, | ||
| ].filter((g) => g.routes.length > 0); | ||
|
|
||
| return ( | ||
| <main className="min-h-screen flex items-center justify-center bg-background p-8"> | ||
| <div className="w-full max-w-lg space-y-8"> | ||
| <div className="space-y-1"> | ||
| <h1 className="text-2xl font-semibold tracking-tight"> | ||
| BTST AI Chat Demo | ||
| </h1> | ||
| <p className="text-sm text-muted-foreground"> | ||
| Available routes in this demo | ||
| </p> | ||
| </div> | ||
| <div className="space-y-6"> | ||
| {groups.map((group) => ( | ||
| <div key={group.heading} className="space-y-1"> | ||
| <p className="text-xs font-medium text-muted-foreground uppercase tracking-wider px-1 pb-1"> | ||
| {group.heading} | ||
| </p> | ||
| <ul className="space-y-1"> | ||
| {group.routes.map(({ label, path }) => ( | ||
| <li key={path}> | ||
| <Link | ||
| href={path} | ||
| className="flex items-center justify-between rounded-lg border px-4 py-3 text-sm hover:bg-accent hover:text-accent-foreground transition-colors group" | ||
| > | ||
| <div className="font-medium truncate mr-4">{label}</div> | ||
| <code className="text-xs text-muted-foreground font-mono shrink-0 group-hover:text-accent-foreground/70"> | ||
| {path} | ||
| </code> | ||
| </Link> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </main> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| /// <reference types="next" /> | ||
| /// <reference types="next/image-types/global" /> | ||
| import "./.next/types/routes.d.ts"; | ||
|
|
||
| // NOTE: This file should not be edited | ||
| // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,100 @@ | ||
| export default function Home() { | ||
| return null; | ||
| import Link from "next/link"; | ||
| import { getOrCreateQueryClient } from "@/lib/query-client"; | ||
| import { getStackClient } from "@/lib/stack-client"; | ||
| import { generateSchema } from "@btst/stack/plugins/route-docs/client"; | ||
| import { myStack } from "@/lib/stack"; | ||
|
|
||
| type RouteItem = { label: string; path: string }; | ||
| type RouteGroup = { heading: string; routes: RouteItem[] }; | ||
|
|
||
| const SITE_BASE_PATH = "/pages"; | ||
|
|
||
| function routeKeyToLabel(key: string): string { | ||
| return key | ||
| .replace(/([A-Z])/g, " $1") | ||
| .replace(/^./, (s) => s.toUpperCase()) | ||
| .trim(); | ||
| } | ||
|
|
||
| export default async function Home() { | ||
| const queryClient = getOrCreateQueryClient(); | ||
| getStackClient(queryClient); | ||
| const schema = await generateSchema(); | ||
|
|
||
| const blogPlugin = schema.plugins.find((p) => p.key === "blog"); | ||
| const staticBlogRoutes: RouteItem[] = | ||
| blogPlugin?.routes | ||
| .filter((r) => r.pathParams.length === 0) | ||
| .map((r) => ({ | ||
| label: routeKeyToLabel(r.key), | ||
| path: `${SITE_BASE_PATH}${r.path}`, | ||
| })) ?? []; | ||
|
|
||
| const { items: posts } = await myStack.api.blog.getAllPosts({ | ||
| published: true, | ||
| }); | ||
|
|
||
| const groups: RouteGroup[] = [ | ||
| { heading: "Blog", routes: staticBlogRoutes }, | ||
| { | ||
| heading: "Posts (seeded)", | ||
| routes: posts.map((p) => ({ | ||
| label: p.title, | ||
| path: `${SITE_BASE_PATH}/blog/${p.slug}`, | ||
| })), | ||
| }, | ||
| { | ||
| heading: "Edit Posts (seeded)", | ||
| routes: posts.map((p) => ({ | ||
| label: p.title, | ||
| path: `${SITE_BASE_PATH}/blog/${p.slug}/edit`, | ||
| })), | ||
| }, | ||
| { | ||
| heading: "Docs", | ||
| routes: [ | ||
| { label: "Route Docs", path: `${SITE_BASE_PATH}/route-docs` }, | ||
| { label: "API Reference", path: "/api/data/reference" }, | ||
| ], | ||
| }, | ||
| ].filter((g) => g.routes.length > 0); | ||
|
|
||
| return ( | ||
| <main className="min-h-screen flex items-center justify-center bg-background p-8"> | ||
| <div className="w-full max-w-lg space-y-8"> | ||
| <div className="space-y-1"> | ||
| <h1 className="text-2xl font-semibold tracking-tight"> | ||
| BTST Blog Demo | ||
| </h1> | ||
| <p className="text-sm text-muted-foreground"> | ||
| Available routes in this demo | ||
| </p> | ||
| </div> | ||
| <div className="space-y-6"> | ||
| {groups.map((group) => ( | ||
| <div key={group.heading} className="space-y-1"> | ||
| <p className="text-xs font-medium text-muted-foreground uppercase tracking-wider px-1 pb-1"> | ||
| {group.heading} | ||
| </p> | ||
| <ul className="space-y-1"> | ||
| {group.routes.map(({ label, path }) => ( | ||
| <li key={path}> | ||
| <Link | ||
| href={path} | ||
| className="flex items-center justify-between rounded-lg border px-4 py-3 text-sm hover:bg-accent hover:text-accent-foreground transition-colors group" | ||
| > | ||
| <div className="font-medium truncate mr-4">{label}</div> | ||
| <code className="text-xs text-muted-foreground font-mono shrink-0 group-hover:text-accent-foreground/70"> | ||
| {path} | ||
| </code> | ||
| </Link> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| </main> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,5 @@ | ||
| import type { NextConfig } from "next"; | ||
|
|
||
| const nextConfig: NextConfig = { | ||
| async redirects() { | ||
| return [{ source: "/", destination: "/pages/blog", permanent: false }]; | ||
| }, | ||
| }; | ||
| const nextConfig: NextConfig = {}; | ||
|
|
||
| export default nextConfig; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.