@rune-kit/rune 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +357 -0
- package/agents/.gitkeep +0 -0
- package/agents/architect.md +29 -0
- package/agents/asset-creator.md +11 -0
- package/agents/audit.md +11 -0
- package/agents/autopsy.md +11 -0
- package/agents/brainstorm.md +11 -0
- package/agents/browser-pilot.md +11 -0
- package/agents/coder.md +29 -0
- package/agents/completion-gate.md +11 -0
- package/agents/constraint-check.md +11 -0
- package/agents/context-engine.md +11 -0
- package/agents/cook.md +11 -0
- package/agents/db.md +11 -0
- package/agents/debug.md +11 -0
- package/agents/dependency-doctor.md +11 -0
- package/agents/deploy.md +11 -0
- package/agents/design.md +11 -0
- package/agents/docs-seeker.md +11 -0
- package/agents/fix.md +11 -0
- package/agents/hallucination-guard.md +11 -0
- package/agents/incident.md +11 -0
- package/agents/integrity-check.md +11 -0
- package/agents/journal.md +11 -0
- package/agents/launch.md +11 -0
- package/agents/logic-guardian.md +11 -0
- package/agents/marketing.md +11 -0
- package/agents/onboard.md +11 -0
- package/agents/perf.md +11 -0
- package/agents/plan.md +11 -0
- package/agents/preflight.md +11 -0
- package/agents/problem-solver.md +11 -0
- package/agents/rescue.md +11 -0
- package/agents/research.md +11 -0
- package/agents/researcher.md +29 -0
- package/agents/review-intake.md +11 -0
- package/agents/review.md +11 -0
- package/agents/reviewer.md +28 -0
- package/agents/safeguard.md +11 -0
- package/agents/sast.md +11 -0
- package/agents/scanner.md +28 -0
- package/agents/scope-guard.md +11 -0
- package/agents/scout.md +11 -0
- package/agents/sentinel.md +11 -0
- package/agents/sequential-thinking.md +11 -0
- package/agents/session-bridge.md +11 -0
- package/agents/skill-forge.md +11 -0
- package/agents/skill-router.md +11 -0
- package/agents/surgeon.md +11 -0
- package/agents/team.md +11 -0
- package/agents/test.md +11 -0
- package/agents/trend-scout.md +11 -0
- package/agents/verification.md +11 -0
- package/agents/video-creator.md +11 -0
- package/agents/watchdog.md +11 -0
- package/agents/worktree.md +11 -0
- package/commands/.gitkeep +0 -0
- package/commands/rune.md +168 -0
- package/compiler/__tests__/openclaw-adapter.test.js +140 -0
- package/compiler/__tests__/parser.test.js +55 -0
- package/compiler/adapters/antigravity.js +59 -0
- package/compiler/adapters/claude.js +37 -0
- package/compiler/adapters/cursor.js +67 -0
- package/compiler/adapters/generic.js +60 -0
- package/compiler/adapters/index.js +45 -0
- package/compiler/adapters/openclaw.js +150 -0
- package/compiler/adapters/windsurf.js +60 -0
- package/compiler/bin/rune.js +288 -0
- package/compiler/doctor.js +153 -0
- package/compiler/emitter.js +240 -0
- package/compiler/parser.js +208 -0
- package/compiler/transformer.js +69 -0
- package/compiler/transforms/branding.js +27 -0
- package/compiler/transforms/cross-references.js +29 -0
- package/compiler/transforms/frontmatter.js +38 -0
- package/compiler/transforms/hooks.js +68 -0
- package/compiler/transforms/subagents.js +36 -0
- package/compiler/transforms/tool-names.js +60 -0
- package/contexts/dev.md +34 -0
- package/contexts/research.md +43 -0
- package/contexts/review.md +55 -0
- package/extensions/ai-ml/PACK.md +517 -0
- package/extensions/analytics/PACK.md +557 -0
- package/extensions/backend/PACK.md +678 -0
- package/extensions/chrome-ext/PACK.md +995 -0
- package/extensions/content/PACK.md +381 -0
- package/extensions/devops/PACK.md +520 -0
- package/extensions/ecommerce/PACK.md +280 -0
- package/extensions/gamedev/PACK.md +393 -0
- package/extensions/mobile/PACK.md +273 -0
- package/extensions/saas/PACK.md +805 -0
- package/extensions/security/PACK.md +536 -0
- package/extensions/trading/PACK.md +597 -0
- package/extensions/ui/PACK.md +947 -0
- package/package.json +47 -0
- package/skills/.gitkeep +0 -0
- package/skills/adversary/SKILL.md +271 -0
- package/skills/asset-creator/SKILL.md +157 -0
- package/skills/audit/SKILL.md +466 -0
- package/skills/autopsy/SKILL.md +200 -0
- package/skills/ba/SKILL.md +279 -0
- package/skills/brainstorm/SKILL.md +266 -0
- package/skills/browser-pilot/SKILL.md +168 -0
- package/skills/completion-gate/SKILL.md +151 -0
- package/skills/constraint-check/SKILL.md +165 -0
- package/skills/context-engine/SKILL.md +176 -0
- package/skills/cook/SKILL.md +636 -0
- package/skills/db/SKILL.md +256 -0
- package/skills/debug/SKILL.md +240 -0
- package/skills/dependency-doctor/SKILL.md +235 -0
- package/skills/deploy/SKILL.md +174 -0
- package/skills/design/DESIGN-REFERENCE.md +365 -0
- package/skills/design/SKILL.md +462 -0
- package/skills/doc-processor/SKILL.md +254 -0
- package/skills/docs/SKILL.md +336 -0
- package/skills/docs-seeker/SKILL.md +166 -0
- package/skills/fix/SKILL.md +192 -0
- package/skills/git/SKILL.md +285 -0
- package/skills/hallucination-guard/SKILL.md +204 -0
- package/skills/incident/SKILL.md +241 -0
- package/skills/integrity-check/SKILL.md +169 -0
- package/skills/journal/SKILL.md +190 -0
- package/skills/launch/SKILL.md +330 -0
- package/skills/logic-guardian/SKILL.md +240 -0
- package/skills/marketing/SKILL.md +229 -0
- package/skills/mcp-builder/SKILL.md +311 -0
- package/skills/onboard/SKILL.md +298 -0
- package/skills/perf/SKILL.md +297 -0
- package/skills/plan/SKILL.md +520 -0
- package/skills/preflight/SKILL.md +231 -0
- package/skills/problem-solver/SKILL.md +284 -0
- package/skills/rescue/SKILL.md +434 -0
- package/skills/research/SKILL.md +122 -0
- package/skills/review/SKILL.md +354 -0
- package/skills/review-intake/SKILL.md +222 -0
- package/skills/safeguard/SKILL.md +188 -0
- package/skills/sast/SKILL.md +190 -0
- package/skills/scaffold/SKILL.md +276 -0
- package/skills/scope-guard/SKILL.md +150 -0
- package/skills/scout/SKILL.md +232 -0
- package/skills/sentinel/SKILL.md +320 -0
- package/skills/sentinel-env/SKILL.md +226 -0
- package/skills/sequential-thinking/SKILL.md +234 -0
- package/skills/session-bridge/SKILL.md +287 -0
- package/skills/skill-forge/SKILL.md +317 -0
- package/skills/skill-router/SKILL.md +267 -0
- package/skills/surgeon/SKILL.md +203 -0
- package/skills/team/SKILL.md +397 -0
- package/skills/test/SKILL.md +271 -0
- package/skills/trend-scout/SKILL.md +145 -0
- package/skills/verification/SKILL.md +201 -0
- package/skills/video-creator/SKILL.md +201 -0
- package/skills/watchdog/SKILL.md +166 -0
- package/skills/worktree/SKILL.md +140 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "@rune/content"
|
|
3
|
+
description: Content platform patterns — blog systems, CMS integration, MDX authoring, internationalization, and SEO.
|
|
4
|
+
metadata:
|
|
5
|
+
author: runedev
|
|
6
|
+
version: "0.1.0"
|
|
7
|
+
layer: L4
|
|
8
|
+
price: "$9"
|
|
9
|
+
target: Content creators
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
# @rune/content
|
|
13
|
+
|
|
14
|
+
## Purpose
|
|
15
|
+
|
|
16
|
+
Content-driven sites break in ways that don't show up until production: blog pages that return 404 after a CMS slug change, MDX files that crash the build when a custom component is missing, translations that show raw keys because the fallback chain is misconfigured, and pages that rank poorly because structured data is malformed or canonical URLs point to the wrong locale. This pack covers the full content stack — authoring, management, localization, and discovery — with patterns that keep content sites correct, fast, and findable.
|
|
17
|
+
|
|
18
|
+
## Triggers
|
|
19
|
+
|
|
20
|
+
- Auto-trigger: when `contentlayer`, `@sanity`, `contentful`, `strapi`, `mdx`, `next-intl`, `i18next`, `*.mdx` detected
|
|
21
|
+
- `/rune blog-patterns` — build or audit blog architecture
|
|
22
|
+
- `/rune cms-integration` — set up or audit headless CMS
|
|
23
|
+
- `/rune mdx-authoring` — configure MDX pipeline with custom components
|
|
24
|
+
- `/rune i18n` — implement or audit internationalization
|
|
25
|
+
- `/rune seo-patterns` — audit SEO, structured data, and meta tags
|
|
26
|
+
- Called by `cook` (L1) when content project detected
|
|
27
|
+
- Called by `marketing` (L2) when creating blog content
|
|
28
|
+
|
|
29
|
+
## Skills Included
|
|
30
|
+
|
|
31
|
+
### blog-patterns
|
|
32
|
+
|
|
33
|
+
Blog system patterns — post management, categories/tags, pagination, RSS feeds, reading time, related posts, comment systems.
|
|
34
|
+
|
|
35
|
+
#### Workflow
|
|
36
|
+
|
|
37
|
+
**Step 1 — Detect blog architecture**
|
|
38
|
+
Use Glob to find blog-related files: `blog/`, `posts/`, `articles/`, `*.mdx`, `*.md` in content directories. Use Grep to find blog utilities: `getStaticPaths`, `generateStaticParams`, `allPosts`, `contentlayer`, `reading-time`. Read the post listing page and individual post page to understand: data source, routing strategy, and rendering pipeline.
|
|
39
|
+
|
|
40
|
+
**Step 2 — Audit blog completeness**
|
|
41
|
+
Check for: missing RSS feed (`feed.xml` or `/api/rss`), no reading time estimation, pagination absent on listing pages (all posts loaded at once), no category/tag filtering, missing related posts, no draft/published state, and OG images not generated per-post.
|
|
42
|
+
|
|
43
|
+
**Step 3 — Emit blog patterns**
|
|
44
|
+
Emit: typed post schema with frontmatter validation, paginated listing with category filter, RSS feed generator, reading time calculator, and related posts by tag similarity.
|
|
45
|
+
|
|
46
|
+
#### Example
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// Next.js App Router — blog listing with pagination and categories
|
|
50
|
+
import { allPosts, type Post } from 'contentlayer/generated';
|
|
51
|
+
|
|
52
|
+
function getPublishedPosts(category?: string): Post[] {
|
|
53
|
+
return allPosts
|
|
54
|
+
.filter(p => p.status === 'published')
|
|
55
|
+
.filter(p => !category || p.category === category)
|
|
56
|
+
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime());
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Reading time utility
|
|
60
|
+
function readingTime(content: string): string {
|
|
61
|
+
const words = content.trim().split(/\s+/).length;
|
|
62
|
+
const minutes = Math.ceil(words / 238);
|
|
63
|
+
return `${minutes} min read`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// RSS feed — app/feed.xml/route.ts
|
|
67
|
+
export async function GET() {
|
|
68
|
+
const posts = getPublishedPosts();
|
|
69
|
+
const xml = `<?xml version="1.0" encoding="UTF-8"?>
|
|
70
|
+
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
|
71
|
+
<channel>
|
|
72
|
+
<title>My Blog</title>
|
|
73
|
+
<link>${process.env.SITE_URL}</link>
|
|
74
|
+
<atom:link href="${process.env.SITE_URL}/feed.xml" rel="self" type="application/rss+xml"/>
|
|
75
|
+
${posts.slice(0, 20).map(p => `<item>
|
|
76
|
+
<title>${escapeXml(p.title)}</title>
|
|
77
|
+
<link>${process.env.SITE_URL}${p.url}</link>
|
|
78
|
+
<pubDate>${new Date(p.date).toUTCString()}</pubDate>
|
|
79
|
+
<description>${escapeXml(p.excerpt)}</description>
|
|
80
|
+
</item>`).join('\n')}
|
|
81
|
+
</channel>
|
|
82
|
+
</rss>`;
|
|
83
|
+
return new Response(xml, { headers: { 'Content-Type': 'application/xml' } });
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### cms-integration
|
|
90
|
+
|
|
91
|
+
CMS integration — Sanity, Contentful, Strapi, PocketBase. Content modeling, preview mode, webhook-triggered rebuilds, draft/published workflows.
|
|
92
|
+
|
|
93
|
+
#### Workflow
|
|
94
|
+
|
|
95
|
+
**Step 1 — Detect CMS setup**
|
|
96
|
+
Use Grep to find CMS SDK usage: `createClient` (Sanity), `contentful`, `strapi`, `PocketBase`, `GROQ`, `graphql` in content-fetching files. Read the CMS client initialization and content queries to understand: CMS provider, content types, preview mode setup, and caching strategy.
|
|
97
|
+
|
|
98
|
+
**Step 2 — Audit CMS integration**
|
|
99
|
+
Check for: no preview/draft mode (editors can't preview before publish), missing webhook for on-demand ISR (content updates require full rebuild), no content validation (malformed CMS data crashes the page), stale cache without revalidation strategy, images served from CMS without optimization (no next/image or equivalent), and missing error boundary for CMS fetch failures.
|
|
100
|
+
|
|
101
|
+
**Step 3 — Emit CMS patterns**
|
|
102
|
+
For Sanity: emit typed GROQ queries with Zod validation, preview mode toggle, and webhook handler. For Contentful: emit typed GraphQL queries, draft/published content switching. For any CMS: emit ISR revalidation endpoint and image optimization pipeline.
|
|
103
|
+
|
|
104
|
+
#### Example
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
// Sanity — typed client with preview mode and ISR webhook
|
|
108
|
+
import { createClient, type QueryParams } from '@sanity/client';
|
|
109
|
+
import { z } from 'zod';
|
|
110
|
+
|
|
111
|
+
const client = createClient({
|
|
112
|
+
projectId: process.env.SANITY_PROJECT_ID!,
|
|
113
|
+
dataset: 'production',
|
|
114
|
+
apiVersion: '2024-01-01',
|
|
115
|
+
useCdn: true,
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const previewClient = client.withConfig({ useCdn: false, token: process.env.SANITY_PREVIEW_TOKEN });
|
|
119
|
+
|
|
120
|
+
const PostSchema = z.object({
|
|
121
|
+
_id: z.string(),
|
|
122
|
+
title: z.string(),
|
|
123
|
+
slug: z.string(),
|
|
124
|
+
body: z.array(z.any()),
|
|
125
|
+
publishedAt: z.string().datetime(),
|
|
126
|
+
author: z.object({ name: z.string(), image: z.string().url().optional() }),
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
export async function getPost(slug: string, preview = false) {
|
|
130
|
+
const query = `*[_type == "post" && slug.current == $slug][0]{
|
|
131
|
+
_id, title, "slug": slug.current, body, publishedAt,
|
|
132
|
+
"author": author->{ name, "image": image.asset->url }
|
|
133
|
+
}`;
|
|
134
|
+
const result = await (preview ? previewClient : client).fetch(query, { slug });
|
|
135
|
+
return PostSchema.parse(result);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Webhook handler for on-demand ISR — app/api/revalidate/route.ts
|
|
139
|
+
export async function POST(req: Request) {
|
|
140
|
+
const body = await req.json();
|
|
141
|
+
const secret = req.headers.get('x-sanity-webhook-secret');
|
|
142
|
+
if (secret !== process.env.SANITY_WEBHOOK_SECRET) {
|
|
143
|
+
return new Response('Unauthorized', { status: 401 });
|
|
144
|
+
}
|
|
145
|
+
const { revalidatePath } = await import('next/cache');
|
|
146
|
+
revalidatePath(`/blog/${body.slug.current}`);
|
|
147
|
+
return Response.json({ revalidated: true });
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
### mdx-authoring
|
|
154
|
+
|
|
155
|
+
MDX authoring patterns — custom components in markdown, code blocks with syntax highlighting, interactive examples, table of contents generation.
|
|
156
|
+
|
|
157
|
+
#### Workflow
|
|
158
|
+
|
|
159
|
+
**Step 1 — Detect MDX setup**
|
|
160
|
+
Use Grep to find MDX configuration: `@next/mdx`, `mdx-bundler`, `next-mdx-remote`, `contentlayer`, `rehype`, `remark`. Read the MDX pipeline config to understand: compilation method, custom components registered, and remark/rehype plugin chain.
|
|
161
|
+
|
|
162
|
+
**Step 2 — Audit MDX pipeline**
|
|
163
|
+
Check for: no custom component fallback (missing component crashes build), code blocks without syntax highlighting (plain text), no table of contents generation (long articles hard to navigate), missing image optimization in MDX (raw `<img>` tags), no frontmatter validation (typos in dates or categories silently pass), and no interactive component sandboxing.
|
|
164
|
+
|
|
165
|
+
**Step 3 — Emit MDX patterns**
|
|
166
|
+
Emit: MDX component registry with fallback for missing components, code block with syntax highlighting (Shiki or Prism), auto-generated TOC from headings, frontmatter schema validation, and callout/admonition components.
|
|
167
|
+
|
|
168
|
+
#### Example
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
// MDX component registry with safe fallback
|
|
172
|
+
import { type MDXComponents } from 'mdx/types';
|
|
173
|
+
import { Callout } from '@/components/callout';
|
|
174
|
+
import { CodeBlock } from '@/components/code-block';
|
|
175
|
+
import Image from 'next/image';
|
|
176
|
+
|
|
177
|
+
export function useMDXComponents(): MDXComponents {
|
|
178
|
+
return {
|
|
179
|
+
// Override default elements
|
|
180
|
+
img: ({ src, alt, ...props }) => (
|
|
181
|
+
<Image src={src!} alt={alt || ''} width={800} height={400} className="rounded-lg" {...props} />
|
|
182
|
+
),
|
|
183
|
+
pre: ({ children, ...props }) => <CodeBlock {...props}>{children}</CodeBlock>,
|
|
184
|
+
// Custom components available in MDX
|
|
185
|
+
Callout,
|
|
186
|
+
// Fallback for unknown components — warn instead of crash
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
// Auto-generated TOC from MDX content
|
|
191
|
+
interface TocItem { id: string; text: string; level: number }
|
|
192
|
+
|
|
193
|
+
function extractToc(raw: string): TocItem[] {
|
|
194
|
+
const headingRegex = /^(#{2,4})\s+(.+)$/gm;
|
|
195
|
+
const items: TocItem[] = [];
|
|
196
|
+
let match;
|
|
197
|
+
while ((match = headingRegex.exec(raw))) {
|
|
198
|
+
const text = match[2].replace(/[`*_~]/g, '');
|
|
199
|
+
items.push({ id: text.toLowerCase().replace(/\s+/g, '-'), text, level: match[1].length });
|
|
200
|
+
}
|
|
201
|
+
return items;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Callout component for MDX
|
|
205
|
+
function Callout({ type = 'info', children }: { type?: 'info' | 'warning' | 'error'; children: React.ReactNode }) {
|
|
206
|
+
const styles = { info: 'bg-blue-50 border-blue-400', warning: 'bg-amber-50 border-amber-400', error: 'bg-red-50 border-red-400' };
|
|
207
|
+
return <div className={`border-l-4 p-4 my-4 rounded-r ${styles[type]}`}>{children}</div>;
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
### i18n
|
|
214
|
+
|
|
215
|
+
Internationalization — locale routing, translation management, RTL support, date/number formatting, content translation workflows, language detection.
|
|
216
|
+
|
|
217
|
+
#### Workflow
|
|
218
|
+
|
|
219
|
+
**Step 1 — Detect i18n setup**
|
|
220
|
+
Use Grep to find i18n libraries: `next-intl`, `i18next`, `react-intl`, `@formatjs`, `lingui`, `paraglide`. Use Glob to find translation files: `locales/`, `messages/`, `translations/`, `*.json` in locale directories. Read the i18n configuration to understand: supported locales, default locale, routing strategy, and translation loading method.
|
|
221
|
+
|
|
222
|
+
**Step 2 — Audit i18n correctness**
|
|
223
|
+
Check for: missing translations (keys present in default locale but not in others), no fallback chain (missing key shows raw key to user), locale not in URL (breaks SEO — Google can't index per-locale pages), no `hreflang` tags (search engines don't know about locale variants), hardcoded strings in components (bypassing translation system), date/number formatting without locale context (`toLocaleDateString()` without explicit locale), and no RTL support for Arabic/Hebrew locales.
|
|
224
|
+
|
|
225
|
+
**Step 3 — Emit i18n patterns**
|
|
226
|
+
Emit: type-safe translation keys with IDE autocomplete, locale routing middleware, `hreflang` tag generator, date/number formatting utilities, missing translation detection script, and RTL-aware layout component.
|
|
227
|
+
|
|
228
|
+
#### Example
|
|
229
|
+
|
|
230
|
+
```typescript
|
|
231
|
+
// next-intl — type-safe translations with locale routing (Next.js App Router)
|
|
232
|
+
// messages/en.json: { "home": { "title": "Welcome", "posts": "Latest {count, plural, one {post} other {posts}}" } }
|
|
233
|
+
// messages/vi.json: { "home": { "title": "Chao mung", "posts": "{count} bai viet moi nhat" } }
|
|
234
|
+
|
|
235
|
+
// middleware.ts — locale routing
|
|
236
|
+
import createMiddleware from 'next-intl/middleware';
|
|
237
|
+
|
|
238
|
+
export default createMiddleware({
|
|
239
|
+
locales: ['en', 'vi', 'ja'],
|
|
240
|
+
defaultLocale: 'en',
|
|
241
|
+
localePrefix: 'as-needed', // /en/about → /about (default), /vi/about stays
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
export const config = { matcher: ['/((?!api|_next|.*\\..*).*)'] };
|
|
245
|
+
|
|
246
|
+
// Hreflang tags — app/[locale]/layout.tsx
|
|
247
|
+
function HreflangTags({ locale, path }: { locale: string; path: string }) {
|
|
248
|
+
const locales = ['en', 'vi', 'ja'];
|
|
249
|
+
return (
|
|
250
|
+
<>
|
|
251
|
+
{locales.map(l => (
|
|
252
|
+
<link key={l} rel="alternate" hrefLang={l} href={`${process.env.SITE_URL}/${l}${path}`} />
|
|
253
|
+
))}
|
|
254
|
+
<link rel="alternate" hrefLang="x-default" href={`${process.env.SITE_URL}${path}`} />
|
|
255
|
+
</>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// Type-safe translations in components
|
|
260
|
+
import { useTranslations } from 'next-intl';
|
|
261
|
+
|
|
262
|
+
function HomePage() {
|
|
263
|
+
const t = useTranslations('home');
|
|
264
|
+
return <h1>{t('title')}</h1>; // IDE autocomplete for keys
|
|
265
|
+
}
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
---
|
|
269
|
+
|
|
270
|
+
### seo-patterns
|
|
271
|
+
|
|
272
|
+
SEO patterns — structured data (JSON-LD), sitemap generation, canonical URLs, meta tags, Open Graph, Twitter Cards, robots.txt, Core Web Vitals optimization.
|
|
273
|
+
|
|
274
|
+
#### Workflow
|
|
275
|
+
|
|
276
|
+
**Step 1 — Detect SEO implementation**
|
|
277
|
+
Use Grep to find SEO code: `generateMetadata`, `Head`, `next-seo`, `json-ld`, `sitemap`, `robots.txt`, `og:title`, `twitter:card`. Read the metadata configuration and sitemap generation to understand: current meta tag strategy, structured data presence, and sitemap coverage.
|
|
278
|
+
|
|
279
|
+
**Step 2 — Audit SEO completeness**
|
|
280
|
+
Check for: missing or duplicate `<title>` tags, no meta description (or same description on every page), no Open Graph tags (poor social sharing), missing canonical URL (duplicate content risk), no JSON-LD structured data (no rich snippets in search), sitemap not listing all public pages, robots.txt blocking important paths, missing `alt` text on images, and no Core Web Vitals monitoring (LCP, CLS, INP).
|
|
281
|
+
|
|
282
|
+
**Step 3 — Emit SEO patterns**
|
|
283
|
+
Emit: metadata generator with per-page overrides, JSON-LD templates (Article, Product, FAQ, BreadcrumbList), dynamic sitemap generator, canonical URL helper, and Core Web Vitals reporter.
|
|
284
|
+
|
|
285
|
+
#### Example
|
|
286
|
+
|
|
287
|
+
```typescript
|
|
288
|
+
// Next.js App Router — metadata + JSON-LD + sitemap
|
|
289
|
+
import { type Metadata } from 'next';
|
|
290
|
+
|
|
291
|
+
// Reusable metadata generator
|
|
292
|
+
function createMetadata({ title, description, path, image, type = 'website' }: {
|
|
293
|
+
title: string; description: string; path: string; image?: string; type?: string;
|
|
294
|
+
}): Metadata {
|
|
295
|
+
const url = `${process.env.SITE_URL}${path}`;
|
|
296
|
+
return {
|
|
297
|
+
title, description,
|
|
298
|
+
alternates: { canonical: url },
|
|
299
|
+
openGraph: { title, description, url, type, images: image ? [{ url: image, width: 1200, height: 630 }] : [] },
|
|
300
|
+
twitter: { card: 'summary_large_image', title, description, images: image ? [image] : [] },
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// JSON-LD for blog posts
|
|
305
|
+
function ArticleJsonLd({ post }: { post: Post }) {
|
|
306
|
+
const jsonLd = {
|
|
307
|
+
'@context': 'https://schema.org',
|
|
308
|
+
'@type': 'Article',
|
|
309
|
+
headline: post.title,
|
|
310
|
+
datePublished: post.publishedAt,
|
|
311
|
+
dateModified: post.updatedAt || post.publishedAt,
|
|
312
|
+
author: { '@type': 'Person', name: post.author.name },
|
|
313
|
+
image: post.ogImage,
|
|
314
|
+
description: post.excerpt,
|
|
315
|
+
};
|
|
316
|
+
return <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} />;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Dynamic sitemap — app/sitemap.ts
|
|
320
|
+
export default async function sitemap() {
|
|
321
|
+
const posts = await getAllPublishedPosts();
|
|
322
|
+
const staticPages = ['', '/about', '/blog', '/contact'];
|
|
323
|
+
return [
|
|
324
|
+
...staticPages.map(path => ({ url: `${process.env.SITE_URL}${path}`, lastModified: new Date(), changeFrequency: 'monthly' as const })),
|
|
325
|
+
...posts.map(post => ({ url: `${process.env.SITE_URL}/blog/${post.slug}`, lastModified: new Date(post.updatedAt || post.publishedAt), changeFrequency: 'weekly' as const })),
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
---
|
|
331
|
+
|
|
332
|
+
## Connections
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
Calls → research (L3): SEO data and competitor analysis
|
|
336
|
+
Calls → marketing (L2): content promotion
|
|
337
|
+
Called By ← cook (L1): when content project detected
|
|
338
|
+
Called By ← marketing (L2): when creating blog content
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
## Tech Stack Support
|
|
342
|
+
|
|
343
|
+
| Area | Options | Notes |
|
|
344
|
+
|------|---------|-------|
|
|
345
|
+
| Blog Framework | Contentlayer, MDX, Velite | Contentlayer most mature for Next.js |
|
|
346
|
+
| Headless CMS | Sanity, Contentful, Strapi, PocketBase | Sanity best DX; PocketBase self-hosted |
|
|
347
|
+
| MDX | next-mdx-remote, mdx-bundler, @next/mdx | next-mdx-remote for dynamic content |
|
|
348
|
+
| i18n | next-intl, i18next, Paraglide | next-intl for App Router |
|
|
349
|
+
| SEO | Next.js Metadata API, next-seo | Metadata API built-in since Next.js 13 |
|
|
350
|
+
|
|
351
|
+
## Constraints
|
|
352
|
+
|
|
353
|
+
1. MUST validate all CMS content against a schema before rendering — malformed data from CMS should not crash pages.
|
|
354
|
+
2. MUST include `hreflang` tags on all locale-specific pages — missing hreflang hurts international SEO ranking.
|
|
355
|
+
3. MUST NOT hardcode strings in components when i18n is configured — every user-visible string goes through the translation system.
|
|
356
|
+
4. MUST generate sitemap dynamically from actual content — static sitemaps go stale and list nonexistent pages.
|
|
357
|
+
5. MUST provide fallback for missing MDX components — a missing custom component should render a warning, not crash the build.
|
|
358
|
+
|
|
359
|
+
## Sharp Edges
|
|
360
|
+
|
|
361
|
+
| Failure Mode | Severity | Mitigation |
|
|
362
|
+
|---|---|---|
|
|
363
|
+
| CMS slug change breaks all inbound links (404 on old URLs) | HIGH | Implement redirect map in CMS; check for broken links on content publish webhook |
|
|
364
|
+
| Missing translation key shows raw key string (`home.title`) to users | HIGH | Configure fallback to default locale; run missing key detection in CI |
|
|
365
|
+
| MDX build crashes because custom component removed but still referenced in old posts | HIGH | Register fallback component that renders warning in dev, empty div in prod |
|
|
366
|
+
| Sitemap includes draft/unpublished pages (indexed by Google before ready) | MEDIUM | Filter sitemap to `status === 'published'` only; add `noindex` to draft preview pages |
|
|
367
|
+
| `hreflang` tags point to wrong locale (en page links to vi version of different page) | MEDIUM | Generate hreflang from route params, not hardcoded; test with hreflang validator |
|
|
368
|
+
| JSON-LD structured data has schema errors (no rich snippets in search) | MEDIUM | Validate JSON-LD against Schema.org; test with Google Rich Results Test |
|
|
369
|
+
|
|
370
|
+
## Done When
|
|
371
|
+
|
|
372
|
+
- Blog system serves paginated posts with RSS feed and reading time
|
|
373
|
+
- CMS integration has preview mode, webhook revalidation, and content validation
|
|
374
|
+
- MDX pipeline renders custom components with fallback for missing ones
|
|
375
|
+
- All user-facing strings go through i18n with fallback chain configured
|
|
376
|
+
- Every public page has unique title, description, OG tags, canonical URL, and JSON-LD
|
|
377
|
+
- Structured report emitted for each skill invoked
|
|
378
|
+
|
|
379
|
+
## Cost Profile
|
|
380
|
+
|
|
381
|
+
~10,000–18,000 tokens per full pack run (all 5 skills). Individual skill: ~2,000–4,000 tokens. Sonnet default. Use haiku for detection scans; escalate to sonnet for CMS integration and SEO audit.
|