@contentbit/studio 0.4.2 → 0.6.0
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/README.md +8 -4
- package/dist/client/assets/api-DbvlDnoO.js +1 -0
- package/dist/client/assets/document-RcoEgi0r.js +1 -0
- package/dist/client/assets/{index-DTXIZgkK.js → index-BOeG6kVU.js} +2 -2
- package/dist/client/assets/routes-cJNV3NIG.js +1 -0
- package/dist/server/assets/{_tanstack-start-manifest_v-wPlN1Hjy.js → _tanstack-start-manifest_v-BSt6T4tK.js} +4 -4
- package/dist/server/assets/{document-DjmCb_Rp.js → document-DlS34LM6.js} +1 -1
- package/dist/server/assets/{document-CxPFBdxd.js → document-G8TsI311.js} +49 -15
- package/dist/server/assets/{router-D4DnWGjU.js → router-734kIJxk.js} +2 -2
- package/dist/server/assets/{routes-BVJt9Z6a.js → routes-FGdym0e5.js} +28 -4
- package/dist/server/assets/{routes-6jOjWQ0D.js → routes-p0tk6PAr.js} +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +27 -8
- package/dist/server/preview.d.ts +4 -2
- package/dist/server/preview.d.ts.map +1 -1
- package/dist/server/preview.js +1 -1
- package/dist/server/scan.d.ts.map +1 -1
- package/dist/server/scan.js +84 -222
- package/dist/server/server.js +2 -2
- package/dist/server/types.d.ts +21 -2
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/src/routes/document.tsx +39 -0
- package/src/routes/index.tsx +21 -1
- package/src/server/index.ts +43 -14
- package/src/server/preview.ts +3 -2
- package/src/server/scan.test.ts +138 -0
- package/src/server/scan.ts +107 -277
- package/src/server/types.ts +21 -2
- package/dist/client/assets/api-MWiK2l_P.js +0 -1
- package/dist/client/assets/document-w62o-wDp.js +0 -1
- package/dist/client/assets/routes-Dg9spe-7.js +0 -1
package/dist/server/scan.js
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { basename, isAbsolute, join, relative } from 'node:path';
|
|
5
|
-
import { pathToFileURL } from 'node:url';
|
|
6
|
-
import { glob } from 'tinyglobby';
|
|
1
|
+
import { compareContentProjectFindings, createLinkGraphView, createSeoBrief, readContentPageFacts, summarizeContentProjectFindings, } from '@contentbit/core';
|
|
2
|
+
import { loadContentProject } from '@contentbit/project';
|
|
3
|
+
import { basename, relative } from 'node:path';
|
|
7
4
|
import { renderStudioPreview } from './preview.js';
|
|
8
|
-
const DEFAULT_MIN_SECTION_WORDS = 25;
|
|
9
|
-
const BLOCKLESS_WORDS = 250;
|
|
10
5
|
export async function scanProject(options) {
|
|
11
6
|
const context = await scanContext(options);
|
|
12
7
|
const blockUsage = {};
|
|
@@ -49,7 +44,18 @@ export async function scanProject(options) {
|
|
|
49
44
|
withPrimary,
|
|
50
45
|
withSecondary,
|
|
51
46
|
},
|
|
52
|
-
...(context.
|
|
47
|
+
...(context.scan.linkGraph ? { linkGraph: context.scan.linkGraph } : {}),
|
|
48
|
+
...(context.scan.seo
|
|
49
|
+
? {
|
|
50
|
+
seo: {
|
|
51
|
+
schemaVersion: context.scan.seo.schemaVersion,
|
|
52
|
+
pages: context.scan.seo.pages.length,
|
|
53
|
+
existing: context.scan.seo.pages.filter((page) => page.source === 'existing').length,
|
|
54
|
+
planned: context.scan.seo.pages.filter((page) => page.source === 'planned').length,
|
|
55
|
+
findings: context.scan.seo.findings.length,
|
|
56
|
+
},
|
|
57
|
+
}
|
|
58
|
+
: {}),
|
|
53
59
|
findings: context.findings,
|
|
54
60
|
};
|
|
55
61
|
}
|
|
@@ -58,21 +64,23 @@ export async function scanDocument(options, requestedPath) {
|
|
|
58
64
|
const file = findAllowedFile(context, options.cwd ?? process.cwd(), requestedPath);
|
|
59
65
|
if (!file)
|
|
60
66
|
return null;
|
|
61
|
-
const
|
|
67
|
+
const scanned = context.scan.files.find((item) => item.path === file);
|
|
68
|
+
if (!scanned)
|
|
69
|
+
return null;
|
|
62
70
|
const summary = context.summaries.find((item) => item.path === file);
|
|
63
71
|
if (!summary)
|
|
64
72
|
return null;
|
|
65
|
-
const
|
|
66
|
-
const previewHtml = renderStudioPreview(validation.document, (await options.previewComponents?.()) ?? {});
|
|
67
|
-
const stats = analyzeDocument(source, { path: file });
|
|
73
|
+
const previewHtml = renderStudioPreview(scanned.validation.document, (await options.previewComponents?.()) ?? {}, { includeGenericComponents: options.includeGenericBlocks !== false });
|
|
68
74
|
const page = context.index
|
|
69
75
|
? [...context.index.pages.values()].find((entry) => entry.path === file)
|
|
70
76
|
: undefined;
|
|
77
|
+
const seoPage = context.scan.seo?.pages.find((entry) => entry.path === file);
|
|
78
|
+
const seoBrief = context.scan.seo && seoPage ? createSeoBrief(context.scan.seo, seoPage.id) : undefined;
|
|
71
79
|
return {
|
|
72
80
|
file: summary,
|
|
73
|
-
source,
|
|
74
|
-
frontmatter:
|
|
75
|
-
stats,
|
|
81
|
+
source: scanned.source,
|
|
82
|
+
frontmatter: scanned.frontmatter,
|
|
83
|
+
stats: scanned.stats,
|
|
76
84
|
findings: context.findings.filter((finding) => finding.file === file),
|
|
77
85
|
linksTo: page ? (page.linkRefs.length > 0 ? page.linkRefs : page.linksTo) : [],
|
|
78
86
|
linkedFrom: page
|
|
@@ -80,6 +88,7 @@ export async function scanDocument(options, requestedPath) {
|
|
|
80
88
|
? page.linkedFromRefs
|
|
81
89
|
: page.linkedFrom
|
|
82
90
|
: [],
|
|
91
|
+
...(seoBrief ? { seoBrief } : {}),
|
|
83
92
|
previewHtml,
|
|
84
93
|
};
|
|
85
94
|
}
|
|
@@ -88,168 +97,67 @@ export async function scanGraph(options) {
|
|
|
88
97
|
if (!context.index)
|
|
89
98
|
return { nodes: [], edges: [] };
|
|
90
99
|
const summaryByPath = new Map(context.summaries.map((summary) => [summary.path, summary]));
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
...(
|
|
100
|
+
const view = createLinkGraphView(context.index, context.scan.linkDiagnostics ?? []);
|
|
101
|
+
const nodes = view.nodes.map((node) => ({
|
|
102
|
+
id: node.id,
|
|
103
|
+
label: node.label,
|
|
104
|
+
path: node.path,
|
|
105
|
+
status: summaryByPath.get(node.path)?.status ?? 'healthy',
|
|
106
|
+
slug: node.slug,
|
|
107
|
+
...(node.key ? { key: node.key } : {}),
|
|
108
|
+
...(node.locale ? { locale: node.locale } : {}),
|
|
99
109
|
}));
|
|
100
|
-
const
|
|
101
|
-
const edges = [];
|
|
102
|
-
for (const page of context.index.pages.values()) {
|
|
103
|
-
for (const ref of page.linkRefs) {
|
|
104
|
-
const target = [...context.index.pages.values()].find((candidate) => candidate.slug === ref.slug &&
|
|
105
|
-
candidate.key === ref.key &&
|
|
106
|
-
candidate.locale === ref.locale);
|
|
107
|
-
edges.push({
|
|
108
|
-
from: pageIdentity(page),
|
|
109
|
-
to: target ? pageIdentity(target) : undefined,
|
|
110
|
-
target: ref.target ?? ref.key ?? ref.slug,
|
|
111
|
-
status: target === page
|
|
112
|
-
? 'self'
|
|
113
|
-
: ref.locale && ref.locale !== page.locale
|
|
114
|
-
? 'cross-locale'
|
|
115
|
-
: 'resolved',
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
for (const finding of context.findings) {
|
|
120
|
-
if (finding.source !== 'links')
|
|
121
|
-
continue;
|
|
122
|
-
if (finding.code !== 'CB_LINK_UNRESOLVED' && finding.code !== 'CB_LINK_LOCALE_MISSING')
|
|
123
|
-
continue;
|
|
124
|
-
const page = pageByPath.get(finding.file);
|
|
125
|
-
if (!page)
|
|
126
|
-
continue;
|
|
127
|
-
edges.push({
|
|
128
|
-
from: pageIdentity(page),
|
|
129
|
-
target: targetFromMessage(finding.message) ?? 'unresolved',
|
|
130
|
-
status: 'unresolved',
|
|
131
|
-
});
|
|
132
|
-
}
|
|
110
|
+
const edges = view.edges;
|
|
133
111
|
return { nodes, edges };
|
|
134
112
|
}
|
|
135
113
|
async function scanContext(options) {
|
|
136
|
-
if (options.globs.length === 0)
|
|
137
|
-
throw new Error('studio: provide at least one file or glob.');
|
|
138
114
|
const cwd = options.cwd ?? process.cwd();
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const stats = analyzeDocument(source, { path: file });
|
|
159
|
-
findings.push(...statsFindings(file, cwd, stats, options.minSectionWords ?? DEFAULT_MIN_SECTION_WORDS));
|
|
160
|
-
summaries.push(fileSummary(file, cwd, fm, stats, findings.filter((finding) => finding.file === file), options));
|
|
161
|
-
}
|
|
162
|
-
let index;
|
|
163
|
-
if (hasLinkFrontmatter(linkInputs, options.linkOptions?.slugField)) {
|
|
164
|
-
for (const { file, diagnostic } of validateLinks(linkInputs, options.linkOptions)) {
|
|
165
|
-
findings.push(findingFromDiagnostic('links', file, cwd, diagnostic));
|
|
166
|
-
}
|
|
167
|
-
index = buildLinkIndex(linkInputs, options.linkOptions);
|
|
168
|
-
refreshSummaryFindings(summaries, findings);
|
|
169
|
-
}
|
|
115
|
+
const project = await loadContentProject({
|
|
116
|
+
cmd: 'studio',
|
|
117
|
+
positionals: options.globs,
|
|
118
|
+
cwd,
|
|
119
|
+
registry: options.registryPath,
|
|
120
|
+
includeGenericBlocks: options.includeGenericBlocks,
|
|
121
|
+
linkOptions: options.linkOptions,
|
|
122
|
+
scan: {
|
|
123
|
+
minSectionWords: options.minSectionWords,
|
|
124
|
+
seoConfig: options.seoConfig,
|
|
125
|
+
seoConfigPath: options.seoConfigPath,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
const { files, scan } = project;
|
|
129
|
+
const findings = scan.findings
|
|
130
|
+
.map((finding) => findingFromProjectFinding(finding, cwd))
|
|
131
|
+
.sort(compareFindings);
|
|
132
|
+
const summaries = scan.files.map((file) => fileSummary(file.path, cwd, file.frontmatter, file.stats, findings.filter((finding) => finding.file === file.path), options, scan.seo?.pages.find((page) => page.path === file.path)));
|
|
133
|
+
const index = scan.linkIndex;
|
|
170
134
|
findings.sort(compareFindings);
|
|
171
|
-
return { files,
|
|
172
|
-
}
|
|
173
|
-
async function loadStudioRegistry(registryPath, cwd = process.cwd()) {
|
|
174
|
-
const registry = createBlockRegistry().use(genericBlocks());
|
|
175
|
-
if (!registryPath)
|
|
176
|
-
return registry;
|
|
177
|
-
const resolvedPath = isAbsolute(registryPath) ? registryPath : join(cwd, registryPath);
|
|
178
|
-
const mod = (await import(pathToFileURL(resolvedPath).href));
|
|
179
|
-
if (!Array.isArray(mod.default)) {
|
|
180
|
-
throw new Error(`--registry module must default-export an array of block definitions: ${resolvedPath}`);
|
|
181
|
-
}
|
|
182
|
-
registry.use(mod.default);
|
|
183
|
-
return registry;
|
|
184
|
-
}
|
|
185
|
-
function statsFindings(file, cwd, stats, minSectionWords) {
|
|
186
|
-
const findings = [];
|
|
187
|
-
for (const section of stats.outline) {
|
|
188
|
-
if (section.words < minSectionWords) {
|
|
189
|
-
findings.push({
|
|
190
|
-
severity: 'info',
|
|
191
|
-
source: 'stats',
|
|
192
|
-
code: 'CB_THIN_SECTION',
|
|
193
|
-
file,
|
|
194
|
-
relativePath: relativePath(cwd, file),
|
|
195
|
-
line: section.line,
|
|
196
|
-
column: 1,
|
|
197
|
-
message: `section "${section.text}" has ${section.words} words`,
|
|
198
|
-
hint: `Add detail or merge it with a nearby section. Threshold: ${minSectionWords} words.`,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
if (stats.length.words >= BLOCKLESS_WORDS && stats.blocks.total === 0) {
|
|
203
|
-
findings.push({
|
|
204
|
-
severity: 'info',
|
|
205
|
-
source: 'stats',
|
|
206
|
-
code: 'CB_BLOCKLESS_DOCUMENT',
|
|
207
|
-
file,
|
|
208
|
-
relativePath: relativePath(cwd, file),
|
|
209
|
-
message: `document has ${stats.length.words} words and no structured blocks`,
|
|
210
|
-
hint: 'Consider a callout, steps, comparison, FAQ, or another registered block if it clarifies the page.',
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
if (stats.images.missingAlt > 0) {
|
|
214
|
-
findings.push({
|
|
215
|
-
severity: 'info',
|
|
216
|
-
source: 'stats',
|
|
217
|
-
code: 'CB_IMAGE_ALT_MISSING',
|
|
218
|
-
file,
|
|
219
|
-
relativePath: relativePath(cwd, file),
|
|
220
|
-
message: `${stats.images.missingAlt} image(s) are missing alt text`,
|
|
221
|
-
hint: 'Add descriptive alt text for meaningful images; use empty alt only for decorative images.',
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
return findings;
|
|
135
|
+
return { files, scan, findings, summaries, index };
|
|
225
136
|
}
|
|
226
|
-
function
|
|
137
|
+
function findingFromProjectFinding(finding, cwd) {
|
|
227
138
|
return {
|
|
228
|
-
severity:
|
|
229
|
-
source,
|
|
230
|
-
code:
|
|
231
|
-
file,
|
|
232
|
-
relativePath: relativePath(cwd, file),
|
|
233
|
-
line:
|
|
234
|
-
column:
|
|
235
|
-
message:
|
|
236
|
-
...(
|
|
139
|
+
severity: finding.severity,
|
|
140
|
+
source: finding.source,
|
|
141
|
+
code: finding.code,
|
|
142
|
+
file: finding.file,
|
|
143
|
+
relativePath: relativePath(cwd, finding.file),
|
|
144
|
+
...(finding.line !== undefined ? { line: finding.line } : {}),
|
|
145
|
+
...(finding.column !== undefined ? { column: finding.column } : {}),
|
|
146
|
+
message: finding.message,
|
|
147
|
+
...(finding.hint ? { hint: finding.hint } : {}),
|
|
237
148
|
};
|
|
238
149
|
}
|
|
239
|
-
function fileSummary(file, cwd, frontmatter, stats, findings, options) {
|
|
150
|
+
function fileSummary(file, cwd, frontmatter, stats, findings, options, seoPage) {
|
|
240
151
|
const counts = summarize(findings);
|
|
241
|
-
const
|
|
242
|
-
const slug = stringValue(frontmatter[options.linkOptions?.slugField ?? 'slug']);
|
|
243
|
-
const key = stringValue(frontmatter[options.linkOptions?.keyField ?? 'key']);
|
|
244
|
-
const locale = stringValue(frontmatter[options.linkOptions?.localeField ?? 'locale']);
|
|
152
|
+
const facts = readContentPageFacts(frontmatter, options.linkOptions);
|
|
245
153
|
return {
|
|
246
154
|
path: file,
|
|
247
155
|
relativePath: relativePath(cwd, file),
|
|
248
156
|
title: titleFor(file, frontmatter, stats),
|
|
249
|
-
...(slug ? { slug } : {}),
|
|
250
|
-
...(key ? { key } : {}),
|
|
251
|
-
...(locale ? { locale } : {}),
|
|
252
|
-
...(keywords ? { keywords } : {}),
|
|
157
|
+
...(facts.slug ? { slug: facts.slug } : {}),
|
|
158
|
+
...(facts.key ? { key: facts.key } : {}),
|
|
159
|
+
...(facts.locale ? { locale: facts.locale } : {}),
|
|
160
|
+
...(facts.keywords ? { keywords: facts.keywords } : {}),
|
|
253
161
|
words: stats.length.words,
|
|
254
162
|
readingMinutes: stats.length.readingMinutes,
|
|
255
163
|
blocks: stats.blocks.total,
|
|
@@ -257,37 +165,26 @@ function fileSummary(file, cwd, frontmatter, stats, findings, options) {
|
|
|
257
165
|
links: stats.links.total,
|
|
258
166
|
externalLinks: stats.links.external,
|
|
259
167
|
missingAlt: stats.images.missingAlt,
|
|
168
|
+
...(seoPage
|
|
169
|
+
? {
|
|
170
|
+
seo: {
|
|
171
|
+
id: seoPage.id,
|
|
172
|
+
source: seoPage.source,
|
|
173
|
+
...(seoPage.type ? { type: seoPage.type } : {}),
|
|
174
|
+
...(seoPage.intent ? { intent: seoPage.intent } : {}),
|
|
175
|
+
findings: findings.filter((finding) => finding.source === 'seo').length,
|
|
176
|
+
},
|
|
177
|
+
}
|
|
178
|
+
: {}),
|
|
260
179
|
findings: counts,
|
|
261
180
|
status: statusFor(counts),
|
|
262
181
|
};
|
|
263
182
|
}
|
|
264
|
-
function refreshSummaryFindings(summaries, findings) {
|
|
265
|
-
for (const summary of summaries) {
|
|
266
|
-
summary.findings = summarize(findings.filter((finding) => finding.file === summary.path));
|
|
267
|
-
summary.status = statusFor(summary.findings);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
183
|
function titleFor(file, frontmatter, stats) {
|
|
271
184
|
return stringValue(frontmatter.title) ?? stats.outline[0]?.text ?? basename(file);
|
|
272
185
|
}
|
|
273
|
-
function keywordData(value) {
|
|
274
|
-
if (!value || typeof value !== 'object')
|
|
275
|
-
return undefined;
|
|
276
|
-
const record = value;
|
|
277
|
-
const primary = stringValue(record.primary);
|
|
278
|
-
const secondary = Array.isArray(record.secondary)
|
|
279
|
-
? record.secondary.filter((item) => typeof item === 'string')
|
|
280
|
-
: undefined;
|
|
281
|
-
return primary || (secondary?.length ?? 0) > 0
|
|
282
|
-
? { ...(primary ? { primary } : {}), ...(secondary ? { secondary } : {}) }
|
|
283
|
-
: undefined;
|
|
284
|
-
}
|
|
285
186
|
function summarize(findings) {
|
|
286
|
-
return
|
|
287
|
-
errors: findings.filter((finding) => finding.severity === 'error').length,
|
|
288
|
-
warnings: findings.filter((finding) => finding.severity === 'warning').length,
|
|
289
|
-
suggestions: findings.filter((finding) => finding.severity === 'info').length,
|
|
290
|
-
};
|
|
187
|
+
return summarizeContentProjectFindings(findings);
|
|
291
188
|
}
|
|
292
189
|
function statusFor(findings) {
|
|
293
190
|
if (findings.errors > 0)
|
|
@@ -298,51 +195,16 @@ function statusFor(findings) {
|
|
|
298
195
|
return 'suggestion';
|
|
299
196
|
return 'healthy';
|
|
300
197
|
}
|
|
301
|
-
function graphSummary(index) {
|
|
302
|
-
let links = 0;
|
|
303
|
-
for (const page of index.pages.values())
|
|
304
|
-
links += page.linksTo.length;
|
|
305
|
-
return {
|
|
306
|
-
pages: index.pages.size,
|
|
307
|
-
links,
|
|
308
|
-
orphans: [...index.pages.values()].filter((page) => page.linkedFrom.length === 0).length,
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
function hasLinkFrontmatter(inputs, configuredSlugField) {
|
|
312
|
-
const slugField = configuredSlugField ?? 'slug';
|
|
313
|
-
return inputs.some((input) => Object.prototype.hasOwnProperty.call(input.data, slugField));
|
|
314
|
-
}
|
|
315
198
|
function findAllowedFile(context, cwd, requestedPath) {
|
|
316
199
|
return (context.files.find((file) => file === requestedPath || relativePath(cwd, file) === requestedPath) ?? null);
|
|
317
200
|
}
|
|
318
201
|
function compareFindings(a, b) {
|
|
319
|
-
return (
|
|
202
|
+
return (compareContentProjectFindings(a, b) ||
|
|
320
203
|
a.relativePath.localeCompare(b.relativePath) ||
|
|
321
204
|
(a.line ?? 0) - (b.line ?? 0) ||
|
|
322
205
|
(a.column ?? 0) - (b.column ?? 0) ||
|
|
323
206
|
a.code.localeCompare(b.code));
|
|
324
207
|
}
|
|
325
|
-
function rank(finding) {
|
|
326
|
-
if (finding.severity === 'error' && finding.source === 'validation')
|
|
327
|
-
return 0;
|
|
328
|
-
if (finding.severity === 'error' && finding.source === 'links')
|
|
329
|
-
return 1;
|
|
330
|
-
if (finding.severity === 'warning')
|
|
331
|
-
return 2;
|
|
332
|
-
if (finding.code === 'CB_THIN_SECTION')
|
|
333
|
-
return 3;
|
|
334
|
-
if (finding.code === 'CB_BLOCKLESS_DOCUMENT')
|
|
335
|
-
return 4;
|
|
336
|
-
if (finding.code === 'CB_IMAGE_ALT_MISSING')
|
|
337
|
-
return 5;
|
|
338
|
-
return 6;
|
|
339
|
-
}
|
|
340
|
-
function pageIdentity(page) {
|
|
341
|
-
return `${page.locale ?? ''}\0${page.key ?? page.slug}`;
|
|
342
|
-
}
|
|
343
|
-
function targetFromMessage(message) {
|
|
344
|
-
return message.match(/linksTo "([^"]+)"/)?.[1];
|
|
345
|
-
}
|
|
346
208
|
function stringValue(value) {
|
|
347
209
|
return typeof value === 'string' && value.trim().length > 0 ? value : undefined;
|
|
348
210
|
}
|
package/dist/server/server.js
CHANGED
|
@@ -3415,7 +3415,7 @@ var defaultSerovalPlugins = [
|
|
|
3415
3415
|
* the dev styles URL for route-scoped CSS collection.
|
|
3416
3416
|
*/
|
|
3417
3417
|
async function getStartManifest(matchedRoutes) {
|
|
3418
|
-
const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-
|
|
3418
|
+
const { tsrStartManifest } = await import("./assets/_tanstack-start-manifest_v-BSt6T4tK.js");
|
|
3419
3419
|
const startManifest = tsrStartManifest();
|
|
3420
3420
|
let routes = startManifest.routes;
|
|
3421
3421
|
routes[rootRouteId];
|
|
@@ -5130,7 +5130,7 @@ var getBaseManifest = getProdBaseManifest;
|
|
|
5130
5130
|
var createEarlyHintsForRequest = createEarlyHintsCollector;
|
|
5131
5131
|
async function loadEntries() {
|
|
5132
5132
|
const [routerEntry, startEntry, pluginAdapters] = await Promise.all([
|
|
5133
|
-
import("./assets/router-
|
|
5133
|
+
import("./assets/router-734kIJxk.js"),
|
|
5134
5134
|
import("./assets/start-q50h9Mc3.js"),
|
|
5135
5135
|
import("./assets/empty-plugin-adapters-DKUlnwwl.js")
|
|
5136
5136
|
]);
|
package/dist/server/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { DocumentStats, LinkReference, LinkResolverOptions } from '@contentbit/core';
|
|
1
|
+
import type { DocumentStats, LinkReference, LinkResolverOptions, SeoBrief } from '@contentbit/core';
|
|
2
2
|
import type { BlockComponent } from '@contentbit/react';
|
|
3
3
|
export type StudioSeverity = 'error' | 'warning' | 'info';
|
|
4
4
|
export type StudioStatus = 'error' | 'warning' | 'suggestion' | 'healthy';
|
|
5
|
-
export type StudioFindingSource = 'validation' | 'links' | 'stats';
|
|
5
|
+
export type StudioFindingSource = 'validation' | 'links' | 'stats' | 'seo';
|
|
6
6
|
export interface StudioFinding {
|
|
7
7
|
severity: StudioSeverity;
|
|
8
8
|
source: StudioFindingSource;
|
|
@@ -17,6 +17,7 @@ export interface StudioFinding {
|
|
|
17
17
|
export interface StudioKeywordData {
|
|
18
18
|
primary?: string;
|
|
19
19
|
secondary?: string[];
|
|
20
|
+
lsi?: string[];
|
|
20
21
|
}
|
|
21
22
|
export interface StudioFileSummary {
|
|
22
23
|
path: string;
|
|
@@ -33,6 +34,13 @@ export interface StudioFileSummary {
|
|
|
33
34
|
links: number;
|
|
34
35
|
externalLinks: number;
|
|
35
36
|
missingAlt: number;
|
|
37
|
+
seo?: {
|
|
38
|
+
id: string;
|
|
39
|
+
source: 'existing' | 'planned';
|
|
40
|
+
type?: string;
|
|
41
|
+
intent?: string;
|
|
42
|
+
findings: number;
|
|
43
|
+
};
|
|
36
44
|
findings: {
|
|
37
45
|
errors: number;
|
|
38
46
|
warnings: number;
|
|
@@ -64,6 +72,13 @@ export interface StudioProject {
|
|
|
64
72
|
links: number;
|
|
65
73
|
orphans: number;
|
|
66
74
|
};
|
|
75
|
+
seo?: {
|
|
76
|
+
schemaVersion: string;
|
|
77
|
+
pages: number;
|
|
78
|
+
existing: number;
|
|
79
|
+
planned: number;
|
|
80
|
+
findings: number;
|
|
81
|
+
};
|
|
67
82
|
findings: StudioFinding[];
|
|
68
83
|
}
|
|
69
84
|
export interface StudioDocument {
|
|
@@ -74,6 +89,7 @@ export interface StudioDocument {
|
|
|
74
89
|
findings: StudioFinding[];
|
|
75
90
|
linksTo: string[] | LinkReference[];
|
|
76
91
|
linkedFrom: string[] | LinkReference[];
|
|
92
|
+
seoBrief?: SeoBrief;
|
|
77
93
|
previewHtml: string;
|
|
78
94
|
}
|
|
79
95
|
export interface StudioGraphNode {
|
|
@@ -98,9 +114,12 @@ export interface StudioGraph {
|
|
|
98
114
|
export interface StudioOptions {
|
|
99
115
|
globs: string[];
|
|
100
116
|
registryPath?: string;
|
|
117
|
+
includeGenericBlocks?: boolean;
|
|
101
118
|
cwd?: string;
|
|
102
119
|
linkOptions?: LinkResolverOptions;
|
|
103
120
|
minSectionWords?: number;
|
|
121
|
+
seoConfig?: unknown;
|
|
122
|
+
seoConfigPath?: string;
|
|
104
123
|
previewComponents?: () => Promise<Record<string, BlockComponent> | undefined>;
|
|
105
124
|
}
|
|
106
125
|
export interface StartStudioOptions extends StudioOptions {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACnG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAEvD,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,SAAS,GAAG,MAAM,CAAA;AACzD,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,SAAS,GAAG,YAAY,GAAG,SAAS,CAAA;AACzE,MAAM,MAAM,mBAAmB,GAAG,YAAY,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAA;AAE1E,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,cAAc,CAAA;IACxB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAA;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,I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CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,cAAc,GAAG,MAAM,CAAA;CAC5D;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,eAAe,EAAE,CAAA;IACxB,KAAK,EAAE,eAAe,EAAE,CAAA;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,WAAW,CAAC,EAAE,mBAAmB,CAAA;IACjC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,SAAS,CAAC,CAAA;CAC9E;AAED,MAAM,WAAW,kBAAmB,SAAQ,aAAa;IACvD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentbit/studio",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Local read-only content studio for contentbit projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"tinyglobby": "^0.2.10",
|
|
49
49
|
"tw-animate-css": "^1.4.0",
|
|
50
50
|
"vite": "^8",
|
|
51
|
-
"@contentbit/blocks": "0.
|
|
52
|
-
"@contentbit/core": "0.
|
|
53
|
-
"@contentbit/
|
|
54
|
-
"@contentbit/react": "0.
|
|
51
|
+
"@contentbit/blocks": "0.6.0",
|
|
52
|
+
"@contentbit/core": "0.6.0",
|
|
53
|
+
"@contentbit/project": "0.6.0",
|
|
54
|
+
"@contentbit/react": "0.6.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@testing-library/dom": "^10.4.1",
|
package/src/routes/document.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Link2,
|
|
9
9
|
RefreshCw,
|
|
10
10
|
Search,
|
|
11
|
+
Target,
|
|
11
12
|
} from 'lucide-react'
|
|
12
13
|
import type { ReactNode } from 'react'
|
|
13
14
|
import { useEffect, useState } from 'react'
|
|
@@ -163,12 +164,50 @@ function DocumentDetail() {
|
|
|
163
164
|
</div>
|
|
164
165
|
</div>
|
|
165
166
|
)}
|
|
167
|
+
{(document.file.keywords.lsi?.length ?? 0) > 0 && (
|
|
168
|
+
<div>
|
|
169
|
+
<p className="text-xs uppercase text-muted-foreground">LSI</p>
|
|
170
|
+
<div className="mt-2 flex flex-wrap gap-1">
|
|
171
|
+
{document.file.keywords.lsi?.map((keyword) => (
|
|
172
|
+
<Badge key={keyword}>{keyword}</Badge>
|
|
173
|
+
))}
|
|
174
|
+
</div>
|
|
175
|
+
</div>
|
|
176
|
+
)}
|
|
166
177
|
</div>
|
|
167
178
|
) : (
|
|
168
179
|
<p className="text-sm text-muted-foreground">No keyword frontmatter found.</p>
|
|
169
180
|
)}
|
|
170
181
|
</Panel>
|
|
171
182
|
|
|
183
|
+
{document.seoBrief && (
|
|
184
|
+
<Panel title="SEO Brief" icon={<Target className="size-4" />}>
|
|
185
|
+
<div className="space-y-3 text-sm">
|
|
186
|
+
<div className="flex flex-wrap gap-1">
|
|
187
|
+
{document.seoBrief.target.type && (
|
|
188
|
+
<Badge>{document.seoBrief.target.type}</Badge>
|
|
189
|
+
)}
|
|
190
|
+
{document.seoBrief.target.intent && (
|
|
191
|
+
<Badge>{document.seoBrief.target.intent}</Badge>
|
|
192
|
+
)}
|
|
193
|
+
<Badge>{document.seoBrief.target.source}</Badge>
|
|
194
|
+
</div>
|
|
195
|
+
{document.seoBrief.acceptanceChecks.length > 0 && (
|
|
196
|
+
<div>
|
|
197
|
+
<p className="text-xs uppercase text-muted-foreground">Acceptance</p>
|
|
198
|
+
<ul className="mt-2 space-y-1">
|
|
199
|
+
{document.seoBrief.acceptanceChecks.map((check) => (
|
|
200
|
+
<li key={check} className="border bg-muted/40 px-2 py-1">
|
|
201
|
+
{check}
|
|
202
|
+
</li>
|
|
203
|
+
))}
|
|
204
|
+
</ul>
|
|
205
|
+
</div>
|
|
206
|
+
)}
|
|
207
|
+
</div>
|
|
208
|
+
</Panel>
|
|
209
|
+
)}
|
|
210
|
+
|
|
172
211
|
<Panel title="Findings" icon={<AlertTriangle className="size-4" />}>
|
|
173
212
|
{document.findings.length > 0 ? (
|
|
174
213
|
<ul className="space-y-3">
|
package/src/routes/index.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
RefreshCw,
|
|
10
10
|
Search,
|
|
11
11
|
ChevronsUpDown,
|
|
12
|
+
Target,
|
|
12
13
|
} from 'lucide-react'
|
|
13
14
|
import type { ReactNode } from 'react'
|
|
14
15
|
import { useEffect, useMemo, useState } from 'react'
|
|
@@ -77,6 +78,7 @@ function Dashboard() {
|
|
|
77
78
|
file.locale,
|
|
78
79
|
file.keywords?.primary,
|
|
79
80
|
...(file.keywords?.secondary ?? []),
|
|
81
|
+
...(file.keywords?.lsi ?? []),
|
|
80
82
|
]
|
|
81
83
|
.filter(Boolean)
|
|
82
84
|
.join(' ')
|
|
@@ -224,6 +226,20 @@ function Dashboard() {
|
|
|
224
226
|
</div>
|
|
225
227
|
|
|
226
228
|
<aside className="flex flex-col gap-4">
|
|
229
|
+
{project?.seo && (
|
|
230
|
+
<Panel title="SEO">
|
|
231
|
+
<div className="grid grid-cols-3 gap-px overflow-hidden border bg-border text-center">
|
|
232
|
+
<TinyMetric value={project.seo.pages} label="pages" />
|
|
233
|
+
<TinyMetric value={project.seo.planned} label="planned" />
|
|
234
|
+
<TinyMetric value={project.seo.findings} label="findings" />
|
|
235
|
+
</div>
|
|
236
|
+
<div className="mt-3 flex items-center gap-2 text-xs text-muted-foreground">
|
|
237
|
+
<Target className="size-4" />
|
|
238
|
+
<span>{project.seo.schemaVersion}</span>
|
|
239
|
+
</div>
|
|
240
|
+
</Panel>
|
|
241
|
+
)}
|
|
242
|
+
|
|
227
243
|
<Panel title="Link graph">
|
|
228
244
|
{project?.linkGraph ? (
|
|
229
245
|
<div className="grid grid-cols-3 gap-px overflow-hidden border bg-border text-center">
|
|
@@ -447,7 +463,11 @@ function compareFiles(a: StudioFileSummary, b: StudioFileSummary, sort: SortKey,
|
|
|
447
463
|
}
|
|
448
464
|
|
|
449
465
|
function keywordScore(file: StudioFileSummary): number {
|
|
450
|
-
return (
|
|
466
|
+
return (
|
|
467
|
+
(file.keywords?.primary ? 1 : 0) +
|
|
468
|
+
(file.keywords?.secondary?.length ? 1 : 0) +
|
|
469
|
+
(file.keywords?.lsi?.length ? 1 : 0)
|
|
470
|
+
)
|
|
451
471
|
}
|
|
452
472
|
|
|
453
473
|
function findingScore(file: StudioFileSummary): number {
|