@contentbit/studio 1.0.0-rc.2 → 2.0.0-next.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 +19 -9
- package/dist/client/assets/api-aCc2x-IO.js +1 -0
- package/dist/client/assets/arrow-right-tp4VknZo.js +1 -0
- package/dist/client/assets/document-DIh3ZPXr.js +56 -0
- package/dist/client/assets/documents-CjBZYbQ4.js +1 -0
- package/dist/client/assets/file-code-corner-Fzc5liO9.js +1 -0
- package/dist/client/assets/file-text-B8O46COn.js +1 -0
- package/dist/client/assets/index-Cd04OFZT.js +11 -0
- package/dist/client/assets/page-BMU8eIrR.js +1 -0
- package/dist/client/assets/routes-WndCJoku.js +1 -0
- package/dist/client/assets/search-BnUPH8AI.js +1 -0
- package/dist/client/assets/styles-hAsz_paS.css +2 -0
- package/dist/client/assets/target-BMSXP2fU.js +1 -0
- package/dist/client/assets/templates-IJid1Zwh.js +1 -0
- package/dist/server/api.d.ts.map +1 -1
- package/dist/server/assets/_tanstack-start-manifest_v-WfZ3uz_l.js +69 -0
- package/dist/server/assets/api-CHfynRIj.js +342 -0
- package/dist/server/assets/{document-DSV89Ser.js → document-BjPXZ9gS.js} +2529 -1317
- package/dist/server/assets/{routes-FGdym0e5.js → documents-jT4KnSkA.js} +63 -112
- package/dist/server/assets/empty-plugin-adapters-Ctp1ZmyT.js +4 -0
- package/dist/server/assets/page--xw7NmtK.js +388 -0
- package/dist/server/assets/router-xI8HUWRI.js +125 -0
- package/dist/server/assets/routes-CfwU-Ww2.js +372 -0
- package/dist/server/assets/start-Dk-BJfGT.js +3 -0
- package/dist/server/assets/templates--9wK-MK9.js +123 -0
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +6104 -110
- package/dist/server/scan.d.ts +1 -2
- package/dist/server/scan.d.ts.map +1 -1
- package/dist/server/server.js +3150 -1878
- package/dist/server/site.d.ts +38 -0
- package/dist/server/site.d.ts.map +1 -0
- package/dist/server/types.d.ts +33 -31
- package/dist/server/types.d.ts.map +1 -1
- package/package.json +26 -15
- package/src/components/studio.test.ts +10 -0
- package/src/components/studio.tsx +209 -0
- package/src/lib/api.test.ts +80 -0
- package/src/lib/api.ts +68 -7
- package/src/routeTree.gen.ts +57 -3
- package/src/routes/document.tsx +34 -88
- package/src/routes/documents.tsx +433 -0
- package/src/routes/index.tsx +295 -414
- package/src/routes/page.tsx +401 -0
- package/src/routes/templates.tsx +104 -0
- package/src/server/api.ts +19 -3
- package/src/server/index.ts +31 -12
- package/src/server/scan.test.ts +31 -44
- package/src/server/scan.ts +56 -82
- package/src/server/site.test.ts +355 -0
- package/src/server/site.ts +164 -0
- package/src/server/types.ts +28 -30
- package/tsconfig.json +1 -1
- package/dist/client/assets/api-BX-WUPtV.js +0 -1
- package/dist/client/assets/document-BOMp4_F5.js +0 -65
- package/dist/client/assets/index-C0ybJ4zQ.js +0 -12
- package/dist/client/assets/routes-ACKdIhYm.js +0 -1
- package/dist/client/assets/styles-DogO4Wcf.css +0 -2
- package/dist/server/assets/_tanstack-start-manifest_v-BC1PNuB0.js +0 -25
- package/dist/server/assets/api-Bqt_atjc.js +0 -72
- package/dist/server/assets/document-BB_UYqNL.js +0 -9
- package/dist/server/assets/empty-plugin-adapters-De7E1vAI.js +0 -5
- package/dist/server/assets/router-BJiN6b7L.js +0 -63
- package/dist/server/assets/routes-p0tk6PAr.js +0 -20
- package/dist/server/assets/start-m8EQRpUf.js +0 -4
package/src/routes/index.tsx
CHANGED
|
@@ -2,112 +2,79 @@ import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
|
|
|
2
2
|
import {
|
|
3
3
|
AlertTriangle,
|
|
4
4
|
ArrowRight,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Link2,
|
|
5
|
+
Bot,
|
|
6
|
+
KeyRound,
|
|
7
|
+
Link2Off,
|
|
9
8
|
RefreshCw,
|
|
10
9
|
Search,
|
|
11
|
-
|
|
12
|
-
Target,
|
|
10
|
+
SlidersHorizontal,
|
|
13
11
|
} from 'lucide-react'
|
|
14
|
-
import
|
|
15
|
-
import { useEffect, useMemo, useState } from 'react'
|
|
12
|
+
import { useMemo } from 'react'
|
|
16
13
|
|
|
14
|
+
import {
|
|
15
|
+
FileFindings,
|
|
16
|
+
Metric,
|
|
17
|
+
NoBuild,
|
|
18
|
+
Panel,
|
|
19
|
+
plural,
|
|
20
|
+
relativeTo,
|
|
21
|
+
severityTone,
|
|
22
|
+
SiteFindingItem,
|
|
23
|
+
StudioNav,
|
|
24
|
+
} from '../components/studio'
|
|
17
25
|
import { Button } from '../components/ui/button'
|
|
18
|
-
import {
|
|
19
|
-
import type {
|
|
20
|
-
|
|
21
|
-
type StatusFilter = 'all' | StudioStatus
|
|
22
|
-
type SortKey = 'document' | 'status' | 'blocks' | 'keywords' | 'findings'
|
|
23
|
-
type SortDir = 'asc' | 'desc'
|
|
26
|
+
import { useSite } from '../lib/api'
|
|
27
|
+
import type { FindingCounts, StudioSite } from '../server/site'
|
|
24
28
|
|
|
25
|
-
interface
|
|
29
|
+
interface SiteSearch {
|
|
26
30
|
q: string
|
|
27
|
-
status: StatusFilter
|
|
28
|
-
sort: SortKey
|
|
29
|
-
dir: SortDir
|
|
30
31
|
}
|
|
31
32
|
|
|
33
|
+
const ORIGIN_SOURCES = {
|
|
34
|
+
flag: 'from --origin',
|
|
35
|
+
config: 'from site.origin',
|
|
36
|
+
canonicals: 'inferred from canonicals',
|
|
37
|
+
} as const
|
|
38
|
+
|
|
32
39
|
export const Route = createFileRoute('/')({
|
|
33
|
-
validateSearch: (search: Record<string, unknown>):
|
|
40
|
+
validateSearch: (search: Record<string, unknown>): SiteSearch => ({
|
|
34
41
|
q: typeof search.q === 'string' ? search.q : '',
|
|
35
|
-
status: isStatus(search.status) ? search.status : 'all',
|
|
36
|
-
sort: isSortKey(search.sort) ? search.sort : 'status',
|
|
37
|
-
dir: search.dir === 'asc' || search.dir === 'desc' ? search.dir : 'asc',
|
|
38
42
|
}),
|
|
39
|
-
component:
|
|
43
|
+
component: SiteView,
|
|
40
44
|
})
|
|
41
45
|
|
|
42
|
-
function
|
|
46
|
+
function SiteView() {
|
|
43
47
|
const search = Route.useSearch()
|
|
44
48
|
const navigate = useNavigate({ from: '/' })
|
|
45
|
-
const
|
|
46
|
-
const [graph, setGraph] = useState<StudioGraph | null>(null)
|
|
47
|
-
const [error, setError] = useState<string | null>(null)
|
|
48
|
-
const [refreshing, setRefreshing] = useState(false)
|
|
49
|
-
|
|
50
|
-
async function refresh() {
|
|
51
|
-
setRefreshing(true)
|
|
52
|
-
setError(null)
|
|
53
|
-
try {
|
|
54
|
-
const [project, graph] = await Promise.all([fetchProject(), fetchGraph()])
|
|
55
|
-
setProject(project)
|
|
56
|
-
setGraph(graph)
|
|
57
|
-
} catch (err) {
|
|
58
|
-
setError(err instanceof Error ? err.message : String(err))
|
|
59
|
-
} finally {
|
|
60
|
-
setRefreshing(false)
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
useEffect(() => {
|
|
65
|
-
void refresh()
|
|
66
|
-
}, [])
|
|
49
|
+
const { data: site, error, refreshing, refresh } = useSite()
|
|
67
50
|
|
|
68
|
-
const
|
|
69
|
-
if (
|
|
51
|
+
const pages = useMemo(() => {
|
|
52
|
+
if (site?.kind !== 'built') return []
|
|
70
53
|
const query = search.q.toLowerCase().trim()
|
|
71
|
-
return
|
|
72
|
-
.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
...(file.keywords?.secondary ?? []),
|
|
81
|
-
...(file.keywords?.lsi ?? []),
|
|
82
|
-
]
|
|
83
|
-
.filter(Boolean)
|
|
84
|
-
.join(' ')
|
|
85
|
-
.toLowerCase()
|
|
86
|
-
return (
|
|
87
|
-
(search.status === 'all' || file.status === search.status) && haystack.includes(query)
|
|
88
|
-
)
|
|
89
|
-
})
|
|
90
|
-
.sort((a, b) => compareFiles(a, b, search.sort, search.dir))
|
|
91
|
-
}, [project, search.dir, search.q, search.sort, search.status])
|
|
54
|
+
return site.context.pages.filter((page) =>
|
|
55
|
+
[page.path, page.title, page.source && relativeTo(site.root, page.source), page.type]
|
|
56
|
+
.concat(page.primaryKeyword)
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join(' ')
|
|
59
|
+
.toLowerCase()
|
|
60
|
+
.includes(query),
|
|
61
|
+
)
|
|
62
|
+
}, [site, search.q])
|
|
92
63
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function setSort(sort: SortKey) {
|
|
98
|
-
setSearch({ sort, dir: search.sort === sort && search.dir === 'asc' ? 'desc' : 'asc' })
|
|
99
|
-
}
|
|
64
|
+
const built = site?.kind === 'built' ? site : undefined
|
|
65
|
+
const attached = built?.context.pages.filter(({ source }) => source !== undefined).length ?? 0
|
|
100
66
|
|
|
101
67
|
return (
|
|
102
68
|
<main className="min-h-svh bg-background text-foreground">
|
|
103
69
|
<section className="border-b bg-muted/30">
|
|
104
70
|
<div className="mx-auto flex max-w-7xl flex-col gap-6 px-5 py-6">
|
|
71
|
+
<StudioNav />
|
|
105
72
|
<div className="flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
|
|
106
73
|
<div>
|
|
107
74
|
<p className="font-mono text-xs uppercase text-muted-foreground">contentbit studio</p>
|
|
108
|
-
<h1 className="mt-1 text-3xl font-semibold tracking-tight">
|
|
75
|
+
<h1 className="mt-1 text-3xl font-semibold tracking-tight">Built pages</h1>
|
|
109
76
|
<p className="mt-2 max-w-2xl text-sm text-muted-foreground">
|
|
110
|
-
|
|
77
|
+
The pages the build serves, as contentbit check and contentbit context read them.
|
|
111
78
|
</p>
|
|
112
79
|
</div>
|
|
113
80
|
<Button onClick={refresh} disabled={refreshing} className="w-fit gap-2">
|
|
@@ -116,370 +83,284 @@ function Dashboard() {
|
|
|
116
83
|
</Button>
|
|
117
84
|
</div>
|
|
118
85
|
|
|
119
|
-
{
|
|
120
|
-
|
|
121
|
-
<
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
86
|
+
{built && (
|
|
87
|
+
<>
|
|
88
|
+
<dl className="grid gap-x-6 gap-y-1 text-sm md:grid-cols-[auto_1fr]">
|
|
89
|
+
<dt className="text-muted-foreground">Build</dt>
|
|
90
|
+
<dd className="font-mono">
|
|
91
|
+
{relativeTo(built.root, built.context.build)},{' '}
|
|
92
|
+
{plural(built.context.pages.length, 'page')}
|
|
93
|
+
</dd>
|
|
94
|
+
<dt className="text-muted-foreground">Origin</dt>
|
|
95
|
+
<dd className="font-mono">
|
|
96
|
+
{built.context.origin
|
|
97
|
+
? `${built.context.origin.url} (${ORIGIN_SOURCES[built.context.origin.source]})`
|
|
98
|
+
: 'unknown'}
|
|
99
|
+
</dd>
|
|
100
|
+
<dt className="text-muted-foreground">Markdown</dt>
|
|
101
|
+
<dd>
|
|
102
|
+
{built.markdownFiles === 0
|
|
103
|
+
? 'none'
|
|
104
|
+
: `${plural(built.markdownFiles, 'file')}, ${attached} with a built page`}
|
|
105
|
+
</dd>
|
|
106
|
+
{built.summary.ignored > 0 && (
|
|
107
|
+
<>
|
|
108
|
+
<dt className="text-muted-foreground">Ignored</dt>
|
|
109
|
+
<dd>{`${plural(built.summary.ignored, 'finding')}, by check.severity and check.ignore`}</dd>
|
|
110
|
+
</>
|
|
111
|
+
)}
|
|
112
|
+
</dl>
|
|
113
|
+
<div className="grid gap-px overflow-hidden rounded-sm border bg-border md:grid-cols-4">
|
|
114
|
+
<Metric label="pages" value={built.summary.pages} />
|
|
115
|
+
<Metric
|
|
116
|
+
label="errors"
|
|
117
|
+
value={built.summary.errors}
|
|
118
|
+
tone={built.summary.errors > 0 ? 'bad' : 'ok'}
|
|
119
|
+
/>
|
|
120
|
+
<Metric
|
|
121
|
+
label="warnings"
|
|
122
|
+
value={built.summary.warnings}
|
|
123
|
+
tone={built.summary.warnings > 0 ? 'warn' : 'ok'}
|
|
124
|
+
/>
|
|
125
|
+
<Metric label="template findings" value={built.context.templateFindings.length} />
|
|
126
|
+
</div>
|
|
127
|
+
</>
|
|
151
128
|
)}
|
|
152
129
|
</div>
|
|
153
130
|
</section>
|
|
154
131
|
|
|
155
132
|
<section className="mx-auto grid max-w-7xl gap-5 px-5 py-5 lg:grid-cols-[minmax(0,1fr)_320px]">
|
|
156
|
-
<div className="min-w-0">
|
|
157
|
-
|
|
158
|
-
<
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
<
|
|
168
|
-
<
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
133
|
+
<div className="min-w-0 space-y-4">
|
|
134
|
+
{error && (
|
|
135
|
+
<Panel title="Error" icon={<AlertTriangle className="size-4" />}>
|
|
136
|
+
<p className="text-sm text-destructive">{error}</p>
|
|
137
|
+
</Panel>
|
|
138
|
+
)}
|
|
139
|
+
{!site && !error && (
|
|
140
|
+
<div className="border p-4 text-sm text-muted-foreground">Reading the site...</div>
|
|
141
|
+
)}
|
|
142
|
+
{site?.kind === 'unbuilt' && <NoBuild {...site} />}
|
|
143
|
+
{built && built.staleSources.length > 0 && (
|
|
144
|
+
<Panel title="Stale build" icon={<AlertTriangle className="size-4" />}>
|
|
145
|
+
<p className="text-sm">
|
|
146
|
+
{plural(built.staleSources.length, 'Markdown file')} changed after the build, so its
|
|
147
|
+
pages may not show them yet. Rebuild the site and press Refresh.
|
|
148
|
+
</p>
|
|
149
|
+
</Panel>
|
|
150
|
+
)}
|
|
151
|
+
{built && (
|
|
152
|
+
<>
|
|
153
|
+
<label className="relative flex min-w-0 items-center">
|
|
154
|
+
<Search className="pointer-events-none absolute left-3 size-4 text-muted-foreground" />
|
|
155
|
+
<input
|
|
156
|
+
value={search.q}
|
|
157
|
+
onChange={(event) =>
|
|
158
|
+
void navigate({ to: '/', search: { q: event.target.value } })
|
|
177
159
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
160
|
+
placeholder="Search path, title, source, type, keyword..."
|
|
161
|
+
className="h-10 w-full border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-foreground"
|
|
162
|
+
/>
|
|
163
|
+
</label>
|
|
164
|
+
<div className="overflow-hidden border">
|
|
165
|
+
<div className="grid grid-cols-[1.4fr_1fr_0.4fr_0.6fr_0.7fr_2rem] gap-px border-b bg-border text-xs font-medium uppercase text-muted-foreground">
|
|
166
|
+
{['Page', 'Source', 'Words', 'Links in', 'Findings', ''].map((label) => (
|
|
167
|
+
<div key={label} className="bg-muted/50 px-3 py-2">
|
|
168
|
+
{label}
|
|
169
|
+
</div>
|
|
170
|
+
))}
|
|
171
|
+
</div>
|
|
172
|
+
<div className="divide-y">
|
|
173
|
+
{pages.map((page) => (
|
|
174
|
+
<Link
|
|
175
|
+
key={page.path}
|
|
176
|
+
to="/page"
|
|
177
|
+
search={{ path: page.path }}
|
|
178
|
+
className="grid grid-cols-[1.4fr_1fr_0.4fr_0.6fr_0.7fr_2rem] gap-px bg-border text-sm transition-colors hover:bg-foreground/20"
|
|
179
|
+
>
|
|
180
|
+
<div className="min-w-0 bg-background px-3 py-3">
|
|
181
|
+
<p className="truncate font-mono text-xs">{page.path}</p>
|
|
182
|
+
<p className="truncate text-muted-foreground">{page.title ?? 'No title'}</p>
|
|
183
|
+
</div>
|
|
184
|
+
<div className="min-w-0 bg-background px-3 py-3 font-mono text-xs text-muted-foreground">
|
|
185
|
+
<p className="truncate">
|
|
186
|
+
{page.source ? relativeTo(built.root, page.source) : 'none'}
|
|
187
|
+
</p>
|
|
188
|
+
{page.type && <p className="truncate">{page.type}</p>}
|
|
189
|
+
</div>
|
|
190
|
+
<div className="bg-background px-3 py-3 font-mono text-xs">{page.words}</div>
|
|
191
|
+
<div className="bg-background px-3 py-3 text-xs">
|
|
192
|
+
{page.linksIn.content} content
|
|
193
|
+
<span className="block text-muted-foreground">
|
|
194
|
+
{page.linksIn.layout} layout
|
|
195
|
+
</span>
|
|
196
|
+
</div>
|
|
197
|
+
<div className="bg-background px-3 py-3 text-xs">
|
|
198
|
+
<FindingCount counts={built.findingCountsByPage[page.path]} />
|
|
199
|
+
</div>
|
|
200
|
+
<div className="flex items-center justify-center bg-background px-2 py-3">
|
|
201
|
+
<ArrowRight className="size-4 text-muted-foreground" />
|
|
202
|
+
</div>
|
|
203
|
+
</Link>
|
|
204
|
+
))}
|
|
205
|
+
{pages.length === 0 && (
|
|
206
|
+
<div className="p-4 text-sm text-muted-foreground">
|
|
207
|
+
No built page matches the search.
|
|
208
|
+
</div>
|
|
209
|
+
)}
|
|
210
|
+
</div>
|
|
221
211
|
</div>
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
)}
|
|
225
|
-
</div>
|
|
212
|
+
</>
|
|
213
|
+
)}
|
|
226
214
|
</div>
|
|
227
215
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
<Panel title="
|
|
231
|
-
|
|
232
|
-
<
|
|
233
|
-
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
216
|
+
{built && (
|
|
217
|
+
<aside className="flex flex-col gap-4">
|
|
218
|
+
<Panel title="Template findings" icon={<AlertTriangle className="size-4" />}>
|
|
219
|
+
{built.context.templateFindings.length === 0 ? (
|
|
220
|
+
<p className="text-sm text-muted-foreground">None.</p>
|
|
221
|
+
) : (
|
|
222
|
+
<ul className="space-y-2 text-sm">
|
|
223
|
+
{built.context.templateFindings.slice(0, 5).map((finding, index) => (
|
|
224
|
+
<li key={`${finding.code}-${index}`} className="border bg-muted/30 px-2 py-1.5">
|
|
225
|
+
<span className={`font-medium ${severityTone(finding.severity)}`}>
|
|
226
|
+
{finding.code}
|
|
227
|
+
</span>
|
|
228
|
+
<span className="block text-xs text-muted-foreground">
|
|
229
|
+
{finding.origin.kind === 'template' &&
|
|
230
|
+
`on ${plural(finding.origin.pages.length, 'page')}`}
|
|
231
|
+
</span>
|
|
232
|
+
</li>
|
|
233
|
+
))}
|
|
234
|
+
</ul>
|
|
235
|
+
)}
|
|
236
|
+
<Link
|
|
237
|
+
to="/templates"
|
|
238
|
+
className="mt-3 inline-block text-sm font-medium underline underline-offset-4"
|
|
239
|
+
>
|
|
240
|
+
All template findings
|
|
241
|
+
</Link>
|
|
240
242
|
</Panel>
|
|
241
|
-
)}
|
|
242
243
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
<
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
>
|
|
260
|
-
<span
|
|
261
|
-
className={
|
|
262
|
-
edge.status === 'unresolved' ? 'text-destructive' : 'text-muted-foreground'
|
|
263
|
-
}
|
|
264
|
-
>
|
|
265
|
-
{edge.status}
|
|
266
|
-
</span>
|
|
267
|
-
<span className="truncate">{edge.target}</span>
|
|
268
|
-
</li>
|
|
269
|
-
))}
|
|
270
|
-
</ul>
|
|
244
|
+
{built.unbuiltFindings.length > 0 && (
|
|
245
|
+
<Panel title="Not on a built page" icon={<AlertTriangle className="size-4" />}>
|
|
246
|
+
<p className="mb-2 text-xs text-muted-foreground">
|
|
247
|
+
Findings about a URL the build has no page for.
|
|
248
|
+
</p>
|
|
249
|
+
<ul className="space-y-2">
|
|
250
|
+
{built.unbuiltFindings.map((finding, index) => (
|
|
251
|
+
<SiteFindingItem
|
|
252
|
+
key={`${finding.code}-${index}`}
|
|
253
|
+
finding={finding}
|
|
254
|
+
root={built.root}
|
|
255
|
+
showPage
|
|
256
|
+
/>
|
|
257
|
+
))}
|
|
258
|
+
</ul>
|
|
259
|
+
</Panel>
|
|
271
260
|
)}
|
|
272
|
-
</Panel>
|
|
273
261
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
<span key={name} className="border bg-muted px-2 py-1 font-mono text-xs">
|
|
279
|
-
{name} x{count}
|
|
280
|
-
</span>
|
|
281
|
-
))}
|
|
282
|
-
</div>
|
|
283
|
-
) : (
|
|
284
|
-
<p className="text-sm text-muted-foreground">No blocks found yet.</p>
|
|
262
|
+
{built.configFindings.length > 0 && (
|
|
263
|
+
<Panel title="Check settings" icon={<SlidersHorizontal className="size-4" />}>
|
|
264
|
+
<FileFindings root={built.root} findings={built.configFindings} />
|
|
265
|
+
</Panel>
|
|
285
266
|
)}
|
|
286
|
-
</Panel>
|
|
287
267
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
label="primary"
|
|
293
|
-
value={project.keywordCoverage.withPrimary}
|
|
294
|
-
total={project.keywordCoverage.total}
|
|
295
|
-
/>
|
|
296
|
-
<Coverage
|
|
297
|
-
label="secondary"
|
|
298
|
-
value={project.keywordCoverage.withSecondary}
|
|
299
|
-
total={project.keywordCoverage.total}
|
|
300
|
-
/>
|
|
301
|
-
</div>
|
|
268
|
+
{built.agentGuidanceFindings.length > 0 && (
|
|
269
|
+
<Panel title="Agent guidance" icon={<Bot className="size-4" />}>
|
|
270
|
+
<FileFindings root={built.root} findings={built.agentGuidanceFindings} />
|
|
271
|
+
</Panel>
|
|
302
272
|
)}
|
|
303
|
-
</Panel>
|
|
304
|
-
</aside>
|
|
305
|
-
</section>
|
|
306
|
-
</main>
|
|
307
|
-
)
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function FileRow({ file }: { file: StudioFileSummary }) {
|
|
311
|
-
return (
|
|
312
|
-
<Link
|
|
313
|
-
to="/document"
|
|
314
|
-
search={{ path: file.path }}
|
|
315
|
-
className="grid grid-cols-[1.4fr_0.6fr_0.6fr_0.6fr_2rem] gap-px bg-border text-sm transition-colors hover:bg-foreground/20"
|
|
316
|
-
>
|
|
317
|
-
<div className="min-w-0 bg-background px-3 py-3">
|
|
318
|
-
<p className="truncate font-medium">{file.title}</p>
|
|
319
|
-
<p className="truncate font-mono text-xs text-muted-foreground">{file.relativePath}</p>
|
|
320
|
-
</div>
|
|
321
|
-
<div className="bg-background px-3 py-3">
|
|
322
|
-
<StatusBadge status={file.status} />
|
|
323
|
-
</div>
|
|
324
|
-
<div className="bg-background px-3 py-3 font-mono text-xs">{file.blocks}</div>
|
|
325
|
-
<div className="bg-background px-3 py-3 text-xs text-muted-foreground">
|
|
326
|
-
{file.keywords?.primary ? 'primary' : 'missing'}
|
|
327
|
-
</div>
|
|
328
|
-
<div className="flex items-center justify-center bg-background px-2 py-3">
|
|
329
|
-
<ArrowRight className="size-4 text-muted-foreground" />
|
|
330
|
-
</div>
|
|
331
|
-
</Link>
|
|
332
|
-
)
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
function Metric({
|
|
336
|
-
label,
|
|
337
|
-
value,
|
|
338
|
-
icon,
|
|
339
|
-
tone,
|
|
340
|
-
}: {
|
|
341
|
-
label: string
|
|
342
|
-
value: number | string
|
|
343
|
-
icon: ReactNode
|
|
344
|
-
tone?: 'bad' | 'warn' | 'ok'
|
|
345
|
-
}) {
|
|
346
|
-
const color =
|
|
347
|
-
tone === 'bad'
|
|
348
|
-
? 'text-destructive'
|
|
349
|
-
: tone === 'warn'
|
|
350
|
-
? 'text-amber-600'
|
|
351
|
-
: tone === 'ok'
|
|
352
|
-
? 'text-emerald-600'
|
|
353
|
-
: 'text-foreground'
|
|
354
|
-
return (
|
|
355
|
-
<div className="bg-background p-4">
|
|
356
|
-
<div className="mb-3 flex items-center justify-between text-muted-foreground">
|
|
357
|
-
<span className="text-xs uppercase">{label}</span>
|
|
358
|
-
{icon}
|
|
359
|
-
</div>
|
|
360
|
-
<div className={`font-mono text-3xl font-semibold ${color}`}>{value}</div>
|
|
361
|
-
</div>
|
|
362
|
-
)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function TinyMetric({ value, label }: { value: number | string; label: string }) {
|
|
366
|
-
return (
|
|
367
|
-
<div className="bg-background px-2 py-2">
|
|
368
|
-
<div className="font-mono text-lg font-semibold">{value}</div>
|
|
369
|
-
<div className="text-[0.65rem] uppercase text-muted-foreground">{label}</div>
|
|
370
|
-
</div>
|
|
371
|
-
)
|
|
372
|
-
}
|
|
373
273
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
274
|
+
<Panel title="Unlinked pages" icon={<Link2Off className="size-4" />}>
|
|
275
|
+
<p className="mb-2 text-xs text-muted-foreground">
|
|
276
|
+
Indexable pages, other than the home page, that no content link on another page
|
|
277
|
+
points to.
|
|
278
|
+
</p>
|
|
279
|
+
{built.context.unlinked.length === 0 ? (
|
|
280
|
+
<p className="text-sm text-muted-foreground">None.</p>
|
|
281
|
+
) : (
|
|
282
|
+
<ul className="max-h-64 space-y-1 overflow-auto text-sm">
|
|
283
|
+
{built.context.unlinked.map((path) => (
|
|
284
|
+
<li key={path}>
|
|
285
|
+
<Link
|
|
286
|
+
to="/page"
|
|
287
|
+
search={{ path }}
|
|
288
|
+
className="break-all font-mono text-xs hover:underline"
|
|
289
|
+
>
|
|
290
|
+
{path}
|
|
291
|
+
</Link>
|
|
292
|
+
</li>
|
|
293
|
+
))}
|
|
294
|
+
</ul>
|
|
295
|
+
)}
|
|
296
|
+
</Panel>
|
|
382
297
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
</div>
|
|
391
|
-
<div className="h-2 bg-muted">
|
|
392
|
-
<div className="h-full bg-foreground" style={{ width: `${pct}%` }} />
|
|
393
|
-
</div>
|
|
394
|
-
</div>
|
|
298
|
+
<Panel title="Primary keywords" icon={<KeyRound className="size-4" />}>
|
|
299
|
+
<CompetingKeywords keywords={built.context.keywords} />
|
|
300
|
+
</Panel>
|
|
301
|
+
</aside>
|
|
302
|
+
)}
|
|
303
|
+
</section>
|
|
304
|
+
</main>
|
|
395
305
|
)
|
|
396
306
|
}
|
|
397
307
|
|
|
398
|
-
function
|
|
399
|
-
|
|
400
|
-
status === 'error'
|
|
401
|
-
? 'border-destructive/40 bg-destructive/10 text-destructive'
|
|
402
|
-
: status === 'warning'
|
|
403
|
-
? 'border-amber-500/40 bg-amber-500/10 text-amber-700'
|
|
404
|
-
: status === 'suggestion'
|
|
405
|
-
? 'border-blue-500/40 bg-blue-500/10 text-blue-700'
|
|
406
|
-
: 'border-emerald-500/40 bg-emerald-500/10 text-emerald-700'
|
|
407
|
-
return <span className={`inline-flex border px-2 py-0.5 text-xs ${cls}`}>{status}</span>
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
function isStatus(value: unknown): value is StatusFilter {
|
|
308
|
+
function FindingCount({ counts }: { counts?: FindingCounts }) {
|
|
309
|
+
if (!counts) return <span className="text-emerald-700">none</span>
|
|
411
310
|
return (
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
311
|
+
<>
|
|
312
|
+
{counts.errors > 0 && (
|
|
313
|
+
<span className="block text-destructive">{plural(counts.errors, 'error')}</span>
|
|
314
|
+
)}
|
|
315
|
+
{counts.warnings > 0 && (
|
|
316
|
+
<span className="block text-amber-700">{plural(counts.warnings, 'warning')}</span>
|
|
317
|
+
)}
|
|
318
|
+
</>
|
|
417
319
|
)
|
|
418
320
|
}
|
|
419
321
|
|
|
420
|
-
function
|
|
421
|
-
|
|
422
|
-
active,
|
|
423
|
-
onClick,
|
|
322
|
+
function CompetingKeywords({
|
|
323
|
+
keywords,
|
|
424
324
|
}: {
|
|
425
|
-
|
|
426
|
-
active: boolean
|
|
427
|
-
onClick(): void
|
|
325
|
+
keywords: Extract<StudioSite, { kind: 'built' }>['context']['keywords']
|
|
428
326
|
}) {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
<ChevronsUpDown className="size-3" />
|
|
440
|
-
</button>
|
|
441
|
-
)
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
function compareFiles(a: StudioFileSummary, b: StudioFileSummary, sort: SortKey, dir: SortDir) {
|
|
445
|
-
const direction = dir === 'asc' ? 1 : -1
|
|
446
|
-
const statusOrder: Record<StudioStatus, number> = {
|
|
447
|
-
error: 0,
|
|
448
|
-
warning: 1,
|
|
449
|
-
suggestion: 2,
|
|
450
|
-
healthy: 3,
|
|
327
|
+
const competing = keywords.filter(({ pages }) => pages.length > 1)
|
|
328
|
+
if (keywords.length === 0) {
|
|
329
|
+
return <p className="text-sm text-muted-foreground">No page declares a primary keyword.</p>
|
|
330
|
+
}
|
|
331
|
+
if (competing.length === 0) {
|
|
332
|
+
return (
|
|
333
|
+
<p className="text-sm text-muted-foreground">
|
|
334
|
+
{plural(keywords.length, 'primary keyword')}, each declared by one page.
|
|
335
|
+
</p>
|
|
336
|
+
)
|
|
451
337
|
}
|
|
452
|
-
const result =
|
|
453
|
-
sort === 'status'
|
|
454
|
-
? statusOrder[a.status] - statusOrder[b.status]
|
|
455
|
-
: sort === 'blocks'
|
|
456
|
-
? a.blocks - b.blocks
|
|
457
|
-
: sort === 'keywords'
|
|
458
|
-
? keywordScore(a) - keywordScore(b)
|
|
459
|
-
: sort === 'findings'
|
|
460
|
-
? findingScore(a) - findingScore(b)
|
|
461
|
-
: a.relativePath.localeCompare(b.relativePath)
|
|
462
|
-
return (result || a.relativePath.localeCompare(b.relativePath)) * direction
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function keywordScore(file: StudioFileSummary): number {
|
|
466
|
-
return (
|
|
467
|
-
(file.keywords?.primary ? 1 : 0) +
|
|
468
|
-
(file.keywords?.secondary?.length ? 1 : 0) +
|
|
469
|
-
(file.keywords?.lsi?.length ? 1 : 0)
|
|
470
|
-
)
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
function findingScore(file: StudioFileSummary): number {
|
|
474
|
-
return file.findings.errors * 100 + file.findings.warnings * 10 + file.findings.suggestions
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
function isSortKey(value: unknown): value is SortKey {
|
|
478
338
|
return (
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
339
|
+
<div className="space-y-2 text-sm">
|
|
340
|
+
<p className="text-xs text-muted-foreground">
|
|
341
|
+
{plural(keywords.length, 'primary keyword')}, {competing.length} declared by more than one
|
|
342
|
+
page:
|
|
343
|
+
</p>
|
|
344
|
+
<ul className="max-h-64 space-y-2 overflow-auto">
|
|
345
|
+
{competing.map(({ keyword, locale, pages }) => (
|
|
346
|
+
<li key={`${locale ?? ''}-${keyword}`} className="border bg-muted/30 px-2 py-1.5">
|
|
347
|
+
<p className="font-medium">
|
|
348
|
+
{keyword}
|
|
349
|
+
{locale && <span className="ml-1 text-xs text-muted-foreground">({locale})</span>}
|
|
350
|
+
</p>
|
|
351
|
+
{pages.map((path) => (
|
|
352
|
+
<Link
|
|
353
|
+
key={path}
|
|
354
|
+
to="/page"
|
|
355
|
+
search={{ path }}
|
|
356
|
+
className="block break-all font-mono text-xs text-muted-foreground hover:underline"
|
|
357
|
+
>
|
|
358
|
+
{path}
|
|
359
|
+
</Link>
|
|
360
|
+
))}
|
|
361
|
+
</li>
|
|
362
|
+
))}
|
|
363
|
+
</ul>
|
|
364
|
+
</div>
|
|
484
365
|
)
|
|
485
366
|
}
|