Skip to content

Commit 9e3a529

Browse files
committed
fix: wip
1 parent 51dc2b7 commit 9e3a529

File tree

17 files changed

+1001
-36
lines changed

17 files changed

+1001
-36
lines changed

apps/www/app/(app)/blocks/page.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Link from "next/link";
2+
3+
import { BlockDisplay } from "@/components/block-display";
4+
import { Button } from "@/components/ui/button";
5+
6+
export const dynamic = "force-static";
7+
export const revalidate = false;
8+
9+
const FEATURED_BLOCKS = [
10+
"footer-1",
11+
"faq-3",
12+
// "dashboard-01",
13+
// "sidebar-07",
14+
// "sidebar-03",
15+
// "login-03",
16+
// "login-04",
17+
];
18+
19+
export default async function BlocksPage() {
20+
return (
21+
<div className="flex flex-col gap-12 md:gap-24">
22+
{FEATURED_BLOCKS.map((name) => (
23+
<BlockDisplay name={name} key={name} />
24+
))}
25+
<div className="container-wrapper">
26+
<div className="container flex justify-center py-6">
27+
<Button asChild variant="outline">
28+
<Link href="/blocks/sidebar">Browse more blocks</Link>
29+
</Button>
30+
</div>
31+
</div>
32+
</div>
33+
);
34+
}

apps/www/app/(blog)/blog/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ export default async function Page({
3030
const selectedTag = params?.tag ?? "";
3131

3232
const posts = blogSource.getPages().sort((a, b) => {
33-
const dateA = new Date(a.data?.publishedOn || 0).getTime();
34-
const dateB = new Date(b.data?.publishedOn || 0).getTime();
33+
const dateA = new Date(a.data?.publishedOn).getTime();
34+
const dateB = new Date(b.data?.publishedOn).getTime();
3535
return dateB - dateA;
3636
});
3737

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import * as React from "react";
2+
import { registryItemFileSchema } from "shadcn/schema";
3+
import { z } from "zod";
4+
5+
import { BlockViewer } from "@/components/block-viewer";
6+
import { ComponentPreview } from "@/components/component-preview";
7+
import { highlightCode } from "@/lib/highlight-code";
8+
import {
9+
createFileTreeForRegistryItemFiles,
10+
getRegistryItem,
11+
} from "@/lib/registry";
12+
import { cn } from "@/lib/utils";
13+
14+
export async function BlockDisplay({ name }: { name: string }) {
15+
// const item = await getCachedRegistryItem(name);
16+
17+
// if (!item?.files) {
18+
// return null;
19+
// }
20+
21+
// const [tree, highlightedFiles] = await Promise.all([
22+
// getCachedFileTree(item.files),
23+
// getCachedHighlightedFiles(item.files),
24+
// ]);
25+
26+
return (
27+
<BlockViewer
28+
name={name}
29+
// item={item}
30+
// tree={tree}
31+
// highlightedFiles={highlightedFiles}
32+
>
33+
<ComponentPreview
34+
name={name}
35+
// name={item.name}
36+
hideCode
37+
className={cn(
38+
"my-0 **:[.preview]:h-auto **:[.preview]:p-4 **:[.preview>.p-6]:p-0",
39+
// item.meta?.containerClassName,
40+
)}
41+
/>
42+
</BlockViewer>
43+
);
44+
}
45+
46+
const getCachedRegistryItem = React.cache(async (name: string) => {
47+
return await getRegistryItem(name);
48+
});
49+
50+
const getCachedFileTree = React.cache(
51+
async (files: Array<{ path: string; target?: string }>) => {
52+
if (!files) {
53+
return null;
54+
}
55+
56+
return await createFileTreeForRegistryItemFiles(files);
57+
},
58+
);
59+
60+
const getCachedHighlightedFiles = React.cache(
61+
async (files: z.infer<typeof registryItemFileSchema>[]) => {
62+
return await Promise.all(
63+
files.map(async (file) => ({
64+
...file,
65+
highlightedContent: await highlightCode(file.content ?? ""),
66+
})),
67+
);
68+
},
69+
);

0 commit comments

Comments
 (0)