|
| 1 | +import { notFound } from "next/navigation"; |
| 2 | +import type { Metadata } from "next"; |
| 3 | +import MarkdownContent from "@/components/MarkdownContent"; |
| 4 | +import { getDocPage } from "@/lib/content/loader"; |
| 5 | +import { |
| 6 | + findSetupToolBySlug, |
| 7 | + setupToolEntries, |
| 8 | +} from "@/lib/seo/setup-tools"; |
| 9 | + |
| 10 | +const siteUrl = process.env.NEXT_PUBLIC_SITE_URL || "https://ai-devkit.com"; |
| 11 | +const baseDocSlug = "1-getting-started"; |
| 12 | + |
| 13 | +interface SetupPageProps { |
| 14 | + params: Promise<{ tool: string }>; |
| 15 | +} |
| 16 | + |
| 17 | +function buildTitle(tool: string): string { |
| 18 | + return `Setting up AI DevKit for ${tool}`; |
| 19 | +} |
| 20 | + |
| 21 | +function buildDescription(tool: string): string { |
| 22 | + return `Set up AI DevKit for ${tool} with structured workflows, commands, and memory to keep AI-assisted development consistent.`; |
| 23 | +} |
| 24 | + |
| 25 | +function buildSeoContent(tool: string, baseContent: string): string { |
| 26 | + const intro = [ |
| 27 | + "", |
| 28 | + `Learn how to set up AI DevKit for **${tool}** so your team can rely on consistent AI-assisted workflows.`, |
| 29 | + "", |
| 30 | + `AI DevKit adds structured phases, reusable commands, and memory to ${tool} so every project follows the same playbook.`, |
| 31 | + "", |
| 32 | + "## What you'll configure", |
| 33 | + "", |
| 34 | + "- Project initialization and environment selection", |
| 35 | + "- AI editor files like rules, agents, and commands", |
| 36 | + "- Memory and skills for repeatable workflows", |
| 37 | + "", |
| 38 | + ].join("\n"); |
| 39 | + |
| 40 | + const outro = [ |
| 41 | + "", |
| 42 | + "## Next steps", |
| 43 | + "", |
| 44 | + `Once AI DevKit is set up in ${tool}, follow the getting started guide and run your first workflow command.`, |
| 45 | + ].join("\n"); |
| 46 | + |
| 47 | + return `${intro}${baseContent}${outro}`; |
| 48 | +} |
| 49 | + |
| 50 | +export async function generateStaticParams() { |
| 51 | + return setupToolEntries.map((entry) => ({ |
| 52 | + tool: entry.slug, |
| 53 | + })); |
| 54 | +} |
| 55 | + |
| 56 | +export async function generateMetadata({ |
| 57 | + params, |
| 58 | +}: SetupPageProps): Promise<Metadata> { |
| 59 | + const { tool: slug } = await params; |
| 60 | + const entry = findSetupToolBySlug(slug); |
| 61 | + |
| 62 | + if (!entry) { |
| 63 | + return { |
| 64 | + title: "Page Not Found", |
| 65 | + description: "The requested setup page could not be found.", |
| 66 | + }; |
| 67 | + } |
| 68 | + |
| 69 | + const title = buildTitle(entry.tool); |
| 70 | + const description = buildDescription(entry.tool); |
| 71 | + const pageUrl = `${siteUrl}/faq/getting-started/${entry.slug}`; |
| 72 | + |
| 73 | + return { |
| 74 | + title, |
| 75 | + description, |
| 76 | + keywords: [ |
| 77 | + title, |
| 78 | + entry.tool, |
| 79 | + "AI DevKit", |
| 80 | + "AI coding assistant", |
| 81 | + "setup guide", |
| 82 | + "structured workflows", |
| 83 | + "commands", |
| 84 | + "memory", |
| 85 | + ], |
| 86 | + openGraph: { |
| 87 | + title, |
| 88 | + description, |
| 89 | + url: pageUrl, |
| 90 | + siteName: "AI DevKit", |
| 91 | + locale: "en_US", |
| 92 | + type: "article", |
| 93 | + }, |
| 94 | + twitter: { |
| 95 | + card: "summary_large_image", |
| 96 | + title, |
| 97 | + description, |
| 98 | + }, |
| 99 | + alternates: { |
| 100 | + canonical: pageUrl, |
| 101 | + }, |
| 102 | + }; |
| 103 | +} |
| 104 | + |
| 105 | +export default async function SetupToolPage({ params }: SetupPageProps) { |
| 106 | + const { tool: slug } = await params; |
| 107 | + const entry = findSetupToolBySlug(slug); |
| 108 | + |
| 109 | + if (!entry) { |
| 110 | + notFound(); |
| 111 | + } |
| 112 | + |
| 113 | + const baseDoc = getDocPage(baseDocSlug); |
| 114 | + const baseContent = |
| 115 | + baseDoc?.content || |
| 116 | + "AI DevKit provides structured workflows, reusable commands, and memory to improve AI-assisted development."; |
| 117 | + |
| 118 | + const content = buildSeoContent(entry.tool, baseContent); |
| 119 | + const pageUrl = `${siteUrl}/faq/getting-started/${entry.slug}`; |
| 120 | + const structuredData = { |
| 121 | + "@context": "https://schema.org", |
| 122 | + "@type": "Article", |
| 123 | + headline: buildTitle(entry.tool), |
| 124 | + description: buildDescription(entry.tool), |
| 125 | + url: pageUrl, |
| 126 | + author: { |
| 127 | + "@type": "Organization", |
| 128 | + name: "AI DevKit", |
| 129 | + }, |
| 130 | + publisher: { |
| 131 | + "@type": "Organization", |
| 132 | + name: "AI DevKit", |
| 133 | + url: siteUrl, |
| 134 | + }, |
| 135 | + }; |
| 136 | + |
| 137 | + return ( |
| 138 | + <div className="bg-white py-16"> |
| 139 | + <article className="mx-auto max-w-4xl px-4 sm:px-6 lg:px-8"> |
| 140 | + <script |
| 141 | + type="application/ld+json" |
| 142 | + dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData) }} |
| 143 | + /> |
| 144 | + <h1 className="text-4xl md:text-5xl font-bold mb-4"> |
| 145 | + {buildTitle(entry.tool)} |
| 146 | + </h1> |
| 147 | + <p className="text-xl text-gray-600 mb-12"> |
| 148 | + {buildDescription(entry.tool)} |
| 149 | + </p> |
| 150 | + <MarkdownContent content={content} /> |
| 151 | + </article> |
| 152 | + </div> |
| 153 | + ); |
| 154 | +} |
0 commit comments