|
1 | | -import { db } from '@sim/db' |
2 | | -import { templateCreators, templates } from '@sim/db/schema' |
3 | | -import { createLogger } from '@sim/logger' |
4 | | -import { eq } from 'drizzle-orm' |
5 | | -import type { Metadata } from 'next' |
6 | | -import { getBaseUrl } from '@/lib/core/utils/urls' |
7 | | -import TemplateDetails from '@/app/templates/[id]/template' |
| 1 | +import { notFound } from 'next/navigation' |
8 | 2 |
|
9 | | -const logger = createLogger('TemplateMetadata') |
| 3 | +// import { db } from '@sim/db' |
| 4 | +// import { templateCreators, templates } from '@sim/db/schema' |
| 5 | +// import { createLogger } from '@sim/logger' |
| 6 | +// import { eq } from 'drizzle-orm' |
| 7 | +// import type { Metadata } from 'next' |
| 8 | +// import { getBaseUrl } from '@/lib/core/utils/urls' |
| 9 | +// import TemplateDetails from '@/app/templates/[id]/template' |
10 | 10 |
|
11 | | -/** |
12 | | - * Generate dynamic metadata for template pages. |
13 | | - * This provides OpenGraph images for social media sharing. |
14 | | - */ |
15 | | -export async function generateMetadata({ |
16 | | - params, |
17 | | -}: { |
18 | | - params: Promise<{ id: string }> |
19 | | -}): Promise<Metadata> { |
20 | | - const { id } = await params |
21 | | - |
22 | | - try { |
23 | | - const result = await db |
24 | | - .select({ |
25 | | - template: templates, |
26 | | - creator: templateCreators, |
27 | | - }) |
28 | | - .from(templates) |
29 | | - .leftJoin(templateCreators, eq(templates.creatorId, templateCreators.id)) |
30 | | - .where(eq(templates.id, id)) |
31 | | - .limit(1) |
32 | | - |
33 | | - if (result.length === 0) { |
34 | | - return { |
35 | | - title: 'Template Not Found', |
36 | | - description: 'The requested template could not be found.', |
37 | | - } |
38 | | - } |
| 11 | +// const logger = createLogger('TemplateMetadata') |
39 | 12 |
|
40 | | - const { template, creator } = result[0] |
41 | | - const baseUrl = getBaseUrl() |
42 | | - |
43 | | - const details = template.details as { tagline?: string; about?: string } | null |
44 | | - const description = details?.tagline || 'AI workflow template on Sim' |
45 | | - |
46 | | - const hasOgImage = !!template.ogImageUrl |
47 | | - const ogImageUrl = template.ogImageUrl || `${baseUrl}/logo/primary/rounded.png` |
48 | | - |
49 | | - return { |
50 | | - title: template.name, |
51 | | - description, |
52 | | - openGraph: { |
53 | | - title: template.name, |
54 | | - description, |
55 | | - type: 'website', |
56 | | - url: `${baseUrl}/templates/${id}`, |
57 | | - siteName: 'Sim', |
58 | | - images: [ |
59 | | - { |
60 | | - url: ogImageUrl, |
61 | | - width: hasOgImage ? 1200 : 512, |
62 | | - height: hasOgImage ? 630 : 512, |
63 | | - alt: `${template.name} - Workflow Preview`, |
64 | | - }, |
65 | | - ], |
66 | | - }, |
67 | | - twitter: { |
68 | | - card: hasOgImage ? 'summary_large_image' : 'summary', |
69 | | - title: template.name, |
70 | | - description, |
71 | | - images: [ogImageUrl], |
72 | | - creator: creator?.details |
73 | | - ? ((creator.details as Record<string, unknown>).xHandle as string) || undefined |
74 | | - : undefined, |
75 | | - }, |
76 | | - } |
77 | | - } catch (error) { |
78 | | - logger.error('Failed to generate template metadata:', error) |
79 | | - return { |
80 | | - title: 'Template', |
81 | | - description: 'AI workflow template on Sim', |
82 | | - } |
83 | | - } |
84 | | -} |
| 13 | +// /** |
| 14 | +// * Generate dynamic metadata for template pages. |
| 15 | +// * This provides OpenGraph images for social media sharing. |
| 16 | +// */ |
| 17 | +// export async function generateMetadata({ |
| 18 | +// params, |
| 19 | +// }: { |
| 20 | +// params: Promise<{ id: string }> |
| 21 | +// }): Promise<Metadata> { |
| 22 | +// const { id } = await params |
| 23 | +// |
| 24 | +// try { |
| 25 | +// const result = await db |
| 26 | +// .select({ |
| 27 | +// template: templates, |
| 28 | +// creator: templateCreators, |
| 29 | +// }) |
| 30 | +// .from(templates) |
| 31 | +// .leftJoin(templateCreators, eq(templates.creatorId, templateCreators.id)) |
| 32 | +// .where(eq(templates.id, id)) |
| 33 | +// .limit(1) |
| 34 | +// |
| 35 | +// if (result.length === 0) { |
| 36 | +// return { |
| 37 | +// title: 'Template Not Found', |
| 38 | +// description: 'The requested template could not be found.', |
| 39 | +// } |
| 40 | +// } |
| 41 | +// |
| 42 | +// const { template, creator } = result[0] |
| 43 | +// const baseUrl = getBaseUrl() |
| 44 | +// |
| 45 | +// const details = template.details as { tagline?: string; about?: string } | null |
| 46 | +// const description = details?.tagline || 'AI workflow template on Sim' |
| 47 | +// |
| 48 | +// const hasOgImage = !!template.ogImageUrl |
| 49 | +// const ogImageUrl = template.ogImageUrl || `${baseUrl}/logo/primary/rounded.png` |
| 50 | +// |
| 51 | +// return { |
| 52 | +// title: template.name, |
| 53 | +// description, |
| 54 | +// openGraph: { |
| 55 | +// title: template.name, |
| 56 | +// description, |
| 57 | +// type: 'website', |
| 58 | +// url: `${baseUrl}/templates/${id}`, |
| 59 | +// siteName: 'Sim', |
| 60 | +// images: [ |
| 61 | +// { |
| 62 | +// url: ogImageUrl, |
| 63 | +// width: hasOgImage ? 1200 : 512, |
| 64 | +// height: hasOgImage ? 630 : 512, |
| 65 | +// alt: `${template.name} - Workflow Preview`, |
| 66 | +// }, |
| 67 | +// ], |
| 68 | +// }, |
| 69 | +// twitter: { |
| 70 | +// card: hasOgImage ? 'summary_large_image' : 'summary', |
| 71 | +// title: template.name, |
| 72 | +// description, |
| 73 | +// images: [ogImageUrl], |
| 74 | +// creator: creator?.details |
| 75 | +// ? ((creator.details as Record<string, unknown>).xHandle as string) || undefined |
| 76 | +// : undefined, |
| 77 | +// }, |
| 78 | +// } |
| 79 | +// } catch (error) { |
| 80 | +// logger.error('Failed to generate template metadata:', error) |
| 81 | +// return { |
| 82 | +// title: 'Template', |
| 83 | +// description: 'AI workflow template on Sim', |
| 84 | +// } |
| 85 | +// } |
| 86 | +// } |
85 | 87 |
|
86 | 88 | /** |
87 | | - * Public template detail page for unauthenticated users. |
88 | | - * Authenticated-user redirect is handled in templates/[id]/layout.tsx. |
| 89 | + * Public template detail page — currently disabled, returns 404. |
89 | 90 | */ |
90 | 91 | export default function TemplatePage() { |
91 | | - return <TemplateDetails /> |
| 92 | + notFound() |
92 | 93 | } |
0 commit comments