@nuxtseo/pro-indexing 0.0.0-stage → 0.1.4

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 CHANGED
@@ -1,3 +1,238 @@
1
- # Temporary Holding Version
1
+ # Pro Indexing
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The dashboard indexing sections that nuxtseo.com, gscdump.com and Request Indexing share, published as the Nuxt layer `@nuxtseo/pro-indexing`. It extends [`@nuxtseo/pro-shell`](../pro-shell/README.md), which extends [`@nuxtseo/design-system`](../design-system/README.md). The maths is [`@gscdump/sdk/indexing`](https://www.npmjs.com/package/@gscdump/sdk). Decision: [ADR-0167](../../docs/adr/0167-pro-indexing-is-a-published-layer-over-one-source.md).
4
+
5
+ ## Scope
6
+
7
+ **Owns:**
8
+ - Portfolio Overview: the tiles and the not-indexed stack chart (`IndexingPortfolioOverview`), one Site's issue breakdown (`IndexingSiteIssues`), and the figures every Overview value reads (`buildPortfolioOverview`, `portfolioMarkdownSite` for the Markdown export).
9
+ - Portfolio Issues (`IndexingPortfolioIssues`) and Portfolio Changes (`IndexingPortfolioChanges`).
10
+ - The per-Site indexing overview parts: the diagnosis panel (`IndexingDiagnosisPanel`), the coverage trend (`IndexingCoverageTrend`), and Index cohorts (`IndexingCohortList`).
11
+ - The indexing URLs table (`IndexingUrlsTable`) and its crawl stages strip (`IndexingCrawlPipeline`).
12
+ - The capability gate for features a site draws itself (`IndexingCapabilityGate`).
13
+ - The `IndexingSource` contract, the route map (`proIndexing.routes`), and the copy (`proIndexing.copy`).
14
+
15
+ **Leaves to the site:**
16
+ - Data. Every read goes through the site's `IndexingSource`. Portfolio sections take the scope's Sites as props.
17
+ - The diagnosis. `diagnoseIndexing` reads Crawl evidence, so the site passes it as the `diagnose` capability.
18
+ - Its Site list. The per-Site rows of the Portfolio Overview stay in the site's own list; they read `buildPortfolioOverview`.
19
+ - Page files, tabs, date pickers, eject and MCP chrome, IndexNow and Watched URLs panels, and any server code (ADR-0042, ADR-0167).
20
+
21
+ ## Rules
22
+
23
+ - No runtime services: no `useFetch`, `$fetch`, [Drizzle](https://orm.drizzle.team), Caller, billing, auth, or `useRuntimeConfig`.
24
+ - No hardcoded path. Every link resolves through the route map; a missing route hides the link.
25
+ - A missing Indexing capability hides its section. A site never fakes one.
26
+ - Components carry the `Indexing` prefix, composables the `Indexing` or `ProIndexing` prefix.
27
+ - Every default string in `PRO_INDEXING_COPY` has a row in [`COPY.md`](../../COPY.md) (Indexing section assets).
28
+
29
+ ## Consuming pro-indexing
30
+
31
+ Install the three UI packages at one version, and the gscdump packages the layer peers on.
32
+
33
+ ```bash
34
+ pnpm add @nuxtseo/pro-indexing @nuxtseo/pro-shell @nuxtseo/design-system @gscdump/sdk@^7.13.0 @gscdump/contracts@^7.13.0
35
+ pnpm add -D typescript@^6
36
+ ```
37
+
38
+ ```ts
39
+ // nuxt.config.ts
40
+ export default defineNuxtConfig({
41
+ // pro-indexing extends the shell, which extends the design system.
42
+ extends: ['@nuxtseo/pro-indexing'],
43
+ })
44
+ ```
45
+
46
+ - Import components from `#components`. The layer's auto-imports are off.
47
+ - Import the pure modules by path: `@nuxtseo/pro-indexing/shared/source`, `shared/portfolio`, `shared/portfolio-overview`, `shared/changes`, `shared/routes`, `shared/copy`, `shared/config`.
48
+
49
+ ### IndexingSource
50
+
51
+ One adapter feeds every section. The site builds it once and provides it above the sections, in a plugin or a layout. A section calls a read in its setup, so a read may call the site's own query composable.
52
+
53
+ ```ts
54
+ interface IndexingRead<T> {
55
+ data: Ref<T | null | undefined>
56
+ status: Ref<'idle' | 'pending' | 'success' | 'error'>
57
+ error: Ref<unknown>
58
+ refresh: () => Promise<void>
59
+ }
60
+
61
+ interface IndexingSite {
62
+ id: string // the site's own Site id
63
+ ref: string // what the route map's [site] token takes
64
+ label: string
65
+ url: string | null
66
+ dataId: string | null // the id the source reads with; null when Search Console is not linked
67
+ }
68
+
69
+ interface IndexingSource {
70
+ diagnostics: (site) => IndexingRead<GscdumpIndexingDiagnosticsResponse>
71
+ urls: (site, params: MaybeRefOrGetter<IndexingUrlsParams>) => IndexingRead<GscdumpIndexingUrlsResponse>
72
+ // Capabilities. A section that needs a missing one does not render.
73
+ diagnose?: (input: IndexingDiagnoseInput<GscdumpIndexingUrl>) => IndexingSiteDiagnosis
74
+ inspect?: () => (site: IndexingSite, urls: readonly string[]) => Promise<IndexingInspectResponse | IndexingInspectRateLimited>
75
+ canonicalMismatches?: (site, enabled: MaybeRefOrGetter<boolean>) => IndexingRead<GscdumpCanonicalMismatchesResponse>
76
+ cohorts?: (site) => IndexingRead<IndexCohortsResponse>
77
+ sitemapProblems?: () => IndexingRead<{ unreachable: readonly string[], errors: readonly string[] }>
78
+ changesRollup?: () => IndexingRead<IndexingChangesRollup>
79
+ indexNow?: true
80
+ watchedUrls?: true
81
+ }
82
+ ```
83
+
84
+ ```ts
85
+ // app/plugins/indexing-source.ts
86
+ import { PRO_INDEXING_SOURCE_KEY } from '../composables/useIndexingSource'
87
+
88
+ export default defineNuxtPlugin((nuxtApp) => {
89
+ nuxtApp.vueApp.provide(PRO_INDEXING_SOURCE_KEY, useMyIndexingSource())
90
+ })
91
+ ```
92
+
93
+ | Indexing capability | Section it turns on |
94
+ | --- | --- |
95
+ | `diagnose` | URLs table: the remediation for the filtered issue |
96
+ | `inspect` | URLs table: "Re-check with Google" on each row |
97
+ | `canonicalMismatches` | URLs table: consolidation targets on the `canonical_mismatch` facet |
98
+ | `cohorts` | `IndexingCohortList` |
99
+ | `sitemapProblems` | Portfolio Overview: the Sitemap problems tile |
100
+ | `changesRollup` | `IndexingPortfolioChanges` |
101
+ | `indexNow`, `watchedUrls` | `IndexingCapabilityGate` around the site's own panel |
102
+
103
+ `hasIndexingCapability(source, name)` and `indexingCapabilities(source)` answer the same question in code, for example to hide a tab.
104
+
105
+ ### Portfolio sections
106
+
107
+ A Portfolio section takes the scope's Sites as `IndexingPortfolioEntry` values and the `IndexingWindow` from `indexingWindow()` in `@gscdump/sdk/indexing`. Map each Site's read once:
108
+
109
+ ```ts
110
+ const entries = computed<IndexingPortfolioEntry[]>(() => sites.value.map(site => ({
111
+ site: { id: site.id, ref: site.publicId, label: site.name, url: site.url, dataId: site.gscdumpSiteId },
112
+ read: read.loading ? { _tag: 'loading' } : read.failed ? { _tag: 'failed' } : read.done ? { _tag: 'settled' } : { _tag: 'idle' },
113
+ summary: read.data?.summary ?? null, // from readSiteIndexing()
114
+ trend: read.data?.trend ?? [],
115
+ })))
116
+ ```
117
+
118
+ ```vue
119
+ <IndexingPortfolioOverview :entries="entries" :window="window" @retry="retry" />
120
+
121
+ <IndexingPortfolioIssues :entries="entries" :window="window" @retry="retry" />
122
+
123
+ <IndexingPortfolioChanges :entries="entries" @retry="retry" />
124
+ ```
125
+
126
+ `@retry` carries the Site ids whose read failed. For the Markdown export, map each entry with `portfolioMarkdownSite(entry, buildPortfolioOverview(entries, window), window, hostname)` and pass the list to `buildIndexingPortfolioMarkdown` from the SDK.
127
+
128
+ ### Per-Site sections
129
+
130
+ ```vue
131
+ <IndexingDiagnosisPanel :state="model" :lead="cohortLead" :lead-to="leadRoute" :action-to="actionRoute" />
132
+
133
+ <IndexingCoverageTrend :state="coverageTrend" />
134
+
135
+ <IndexingCohortList :site="site" />
136
+
137
+ <IndexingUrlsTable :site="site" :initial-issue="route.query.issue" />
138
+ ```
139
+
140
+ The site builds `model` with `buildIndexingOverviewModel(input, diagnose)` from the SDK. `IndexingUrlsTable` reads `diagnostics` and `urls`, and draws its table in the layer's default shell. A site with its own table shell passes it as the `shell` prop; it receives the same props, events, and slots (`IndexingUrlsTableShellProps` in the component).
141
+
142
+ ### Route map
143
+
144
+ Each site maps the sections' logical routes under `proIndexing.routes` in `app.config.ts`. A Site route holds the shell's `[site]` token, filled with `IndexingSite.ref`.
145
+
146
+ | Route | Kind | Used by |
147
+ | --- | --- | --- |
148
+ | `connectSearchConsole` | App | A site's own "Connect Search Console" links |
149
+ | `siteIndexing` | Site | Portfolio Changes Site links, the "Open indexing report" link |
150
+ | `siteIndexingUrls` | Site | Every "Fix issues" link, with `?issue=` or `?facet=` |
151
+ | `siteIndexingSitemaps` | Site | Sitemap evidence links |
152
+
153
+ ```ts
154
+ // app/app.config.ts
155
+ import { defineProIndexingConfig } from '../shared/config'
156
+
157
+ export default {
158
+ proIndexing: defineProIndexingConfig({
159
+ routes: {
160
+ siteIndexing: '/app/sites/[site]/indexing',
161
+ siteIndexingUrls: '/app/sites/[site]/indexing/urls',
162
+ siteIndexingSitemaps: '/app/sites/[site]/indexing/sitemaps',
163
+ },
164
+ }),
165
+ }
166
+ ```
167
+
168
+ nuxtseo.com sets its map in `apps/pro/app/pro-indexing.ts` and its source in `layers/pro/gsc/app/composables/useNuxtSeoIndexingSource.ts`.
169
+
170
+ ### Copy
171
+
172
+ Every string has a default in `PRO_INDEXING_COPY` (`shared/copy.ts`), and COPY.md owns each one. Reword any key under `proIndexing.copy`; unset keys keep the defaults. Placeholders in braces are filled by the component.
173
+
174
+ ### Adopting on gscdump.com
175
+
176
+ gscdump.com reads its own `/api/sites/[siteId]/*` routes. It dropped submit sitemap, rich results, and IndexNow on purpose (#345), so its source leaves those capabilities out and the sections stay off.
177
+
178
+ ```ts
179
+ export function useAppIndexingSource(): IndexingSource {
180
+ const read = <T>(key: () => string, path: () => string | null) => {
181
+ const { data, status, error, refresh } = useAsyncData<T | null>(key, () => {
182
+ const url = path()
183
+ return url ? $fetch<T>(url) : Promise.resolve(null)
184
+ }, { server: false, watch: [path] })
185
+ return { data, status, error, refresh }
186
+ }
187
+ return {
188
+ diagnostics: site => read(() => `diag:${toValue(site)?.dataId}`, () => toValue(site)?.dataId ? `/api/sites/${toValue(site)!.dataId}/indexing/diagnostics` : null),
189
+ urls: (site, params) => read(() => `urls:${toValue(site)?.dataId}:${JSON.stringify(toValue(params))}`, () => toValue(site)?.dataId ? withQuery(`/api/sites/${toValue(site)!.dataId}/indexing/urls`, toValue(params)) : null),
190
+ diagnose: input => diagnoseFromInspection(input), // its own, from inspected URLs
191
+ cohorts: site => cohortsFromUrls(site), // buildIndexCohortsFromIndexingUrls over a 500-row urls read
192
+ // No inspect (the 2,000 a day cap is a product call), no canonicalMismatches
193
+ // (it keeps its own page), no sitemapProblems (no live probe yet), no indexNow.
194
+ }
195
+ }
196
+ ```
197
+
198
+ | Section | gscdump.com |
199
+ | --- | --- |
200
+ | Portfolio Overview, Issues, Markdown export | yes |
201
+ | Portfolio Changes | after a `changesRollup` over per-Site transitions |
202
+ | Diagnosis panel, coverage trend | yes |
203
+ | Index cohorts | yes, built from inspected URLs |
204
+ | URLs table | yes, no re-inspect, no rich results facet |
205
+ | Sitemap problems tile, IndexNow | off (no probe; dropped in #345) |
206
+
207
+ ### Adopting on Request Indexing
208
+
209
+ Request Indexing reads through its `useProGscdump` proxy and has its own live sitemap probe and Watched URLs. Its local `layers/pro-indexing` and `layers/pro-shell` collide in name with the packages: rename both (for example `layers/ri-indexing`) in the same pull request that adds the dependency.
210
+
211
+ ```ts
212
+ export function useRiIndexingSource(): IndexingSource {
213
+ const gscdump = useProGscdump()
214
+ return {
215
+ diagnostics: site => useRiRead(() => gscdump.getSiteIndexingDiagnostics({ params: { siteId: toValue(site)!.dataId! } }, true), site),
216
+ urls: (site, params) => useRiRead(() => gscdump.listSiteIndexingUrls({ params: { siteId: toValue(site)!.dataId! }, query: toValue(params) }, true), site, params),
217
+ diagnose: input => diagnoseIndexing(input),
218
+ inspect: () => (site, urls) => gscdump.inspectSiteIndexingUrls({ params: { siteId: site.dataId! }, body: { urls: [...urls] } }),
219
+ cohorts: site => useRiCohorts(site), // buildIndexCohortsFromIndexingUrls
220
+ sitemapProblems: () => useRiSitemapRollup(), // from its per-Site probe
221
+ changesRollup: () => useRiChangesFromTransitions(), // listSiteIndexingTransitions per Site
222
+ watchedUrls: true,
223
+ }
224
+ }
225
+ ```
226
+
227
+ | Section | Request Indexing |
228
+ | --- | --- |
229
+ | Portfolio Overview, Issues, Markdown export | yes (new: it has no Issues tab, stack chart, or export today) |
230
+ | Portfolio Changes | yes, from per-Site transitions |
231
+ | Diagnosis panel, coverage trend, Index cohorts | yes, replaces its copies |
232
+ | URLs table with re-inspect | yes |
233
+ | Sitemap problems tile | yes, from its probe |
234
+ | Watched URLs | its own panel inside `IndexingCapabilityGate capability="watchedUrls"` |
235
+
236
+ ## Releasing
237
+
238
+ `@nuxtseo/pro-indexing` releases with `@nuxtseo/pro-shell` and `@nuxtseo/design-system` on the `ui-v*` tag, at one version. Its peer ranges on both are `^<version>`, and `pnpm release:ui:check` refuses anything else. The steps are in the design system README (Releasing): set the three versions, check, pack all three, smoke, tag.
@@ -0,0 +1,11 @@
1
+ import type { ProIndexingCopyOverrides } from '../shared/copy'
2
+ import type { ProIndexingRouteMap } from '../shared/routes'
3
+
4
+ // The site's seams for the indexing sections. The layer maps no route, so each
5
+ // link that needs a route hides until the site maps one (README, Route map).
6
+ export default {
7
+ proIndexing: {
8
+ routes: {} as ProIndexingRouteMap,
9
+ copy: {} as ProIndexingCopyOverrides,
10
+ },
11
+ }
@@ -0,0 +1,20 @@
1
+ <script setup lang="ts">
2
+ import type { IndexingCapability } from '../../shared/source'
3
+ import { computed } from 'vue'
4
+ import { hasIndexingCapability } from '../../shared/source'
5
+ import { useIndexingSource } from '../composables/useIndexingSource'
6
+
7
+ // Renders its slot only when the provided IndexingSource has the capability.
8
+ // Use it for a feature the site draws itself, such as its IndexNow or Watched
9
+ // URLs panel, so the same page hides the feature on a site without it.
10
+
11
+ const { capability } = defineProps<{ capability: IndexingCapability }>()
12
+
13
+ const source = useIndexingSource()
14
+ const allowed = computed(() => hasIndexingCapability(source, capability))
15
+ </script>
16
+
17
+ <template>
18
+ <slot v-if="allowed" />
19
+ <slot v-else name="fallback" />
20
+ </template>
@@ -0,0 +1,126 @@
1
+ <script lang="ts" setup>
2
+ import type { IndexingSite } from '../../shared/source'
3
+ import { sampledIndexStateMessage } from '@gscdump/sdk/indexing'
4
+ import { formatGroupedNumber } from '@nuxtseo/design-system/app/composables/formatting'
5
+ import { computed } from 'vue'
6
+ import { NuxtLink, UiIcon } from '#components'
7
+ import { useIndexingSource } from '../composables/useIndexingSource'
8
+ import { useProIndexingRoute } from '../composables/useProIndexingRoute'
9
+ // Which PART of the site does Google treat worse than the rest — the question
10
+ // GSC's own taxonomy ("37 crawled but not indexed") cannot answer because it
11
+ // names a symptom, not a place.
12
+ //
13
+ // Rows carry no severity dot on purpose: every cohort in this list already
14
+ // cleared a corrected significance test, so a dot on all of them encodes nothing
15
+ // and spends the status-colour budget on a non-signal (DESIGN, colour budget).
16
+
17
+ // Reads the `cohorts` capability. Without it, or before the read returns,
18
+ // the section renders nothing.
19
+ const { site } = defineProps<{
20
+ site: IndexingSite | null | undefined
21
+ }>()
22
+
23
+ const source = useIndexingSource()
24
+ const route = useProIndexingRoute()
25
+ const read = source?.cohorts?.(() => site) ?? null
26
+ const state = computed(() => read?.data.value ?? null)
27
+
28
+ const percent = (value: number) => `${Math.round(value * 100)}%`
29
+
30
+ const cells = computed(() => state.value?._tag === 'outliers' ? state.value.cells : [])
31
+
32
+ /** One honest verdict sentence, then the list (ADR-0105). */
33
+ const verdict = computed(() => {
34
+ const state = read?.data.value
35
+ if (!state)
36
+ return ''
37
+ if (state._tag === 'no-evidence') {
38
+ if (state.reason === 'sampled-index-state' && state.sample)
39
+ return sampledIndexStateMessage(state.sample.enumerated, state.sample.reported)
40
+ return state.reason === 'no-completed-crawl'
41
+ ? 'No completed crawl yet, so pages cannot be grouped.'
42
+ : 'No inspected URL matched a crawled page.'
43
+ }
44
+ if (state._tag === 'uniform') {
45
+ const spread = `${formatGroupedNumber(state.baseline.notIndexed)} of ${formatGroupedNumber(state.baseline.total)} pages are not indexed`
46
+ // `tested: 0` means no group was large enough to compare — a coverage fact,
47
+ // not a clean bill. Reporting it as "nothing indexes worse" would assert a
48
+ // comparison that never ran.
49
+ return state.tested === 0
50
+ ? `${spread}, and no group of pages is large enough to compare.`
51
+ : `No part of this site indexes worse than the rest. ${spread}, spread evenly.`
52
+ }
53
+ // The hero already states the worst cohort as the page's primary diagnosis.
54
+ // Restating it here would tell the same story twice on one screen, so this
55
+ // line frames what the list IS. HOW it was ranked is method, and method rides
56
+ // the dimmed coverage line below rather than the verdict.
57
+ const count = state.cells.length
58
+ return `${count === 1 ? 'One part' : `${count} parts`} of this site index worse than the rest.`
59
+ })
60
+
61
+ /**
62
+ * The join is never a census — pages Google knows but we never crawled carry no
63
+ * cohort attributes, so they sit outside every rate on screen.
64
+ */
65
+ const coverageNote = computed(() => {
66
+ const state = read?.data.value
67
+ if (!state || state._tag === 'no-evidence')
68
+ return null
69
+ const { analysed, notCrawled, excludedFragments } = state.coverage
70
+ const groups = state._tag === 'uniform' || state._tag === 'outliers' ? state.tested : 0
71
+ const parts = [
72
+ groups > 0
73
+ ? `${formatGroupedNumber(analysed)} crawled pages compared across ${formatGroupedNumber(groups)} groups`
74
+ : `${formatGroupedNumber(analysed)} crawled pages compared`,
75
+ ]
76
+ if (notCrawled > 0)
77
+ parts.push(`${formatGroupedNumber(notCrawled)} not-indexed URLs are outside this crawl`)
78
+ if (excludedFragments > 0)
79
+ parts.push(`${formatGroupedNumber(excludedFragments)} fragment URLs excluded`)
80
+ return parts.join(' · ')
81
+ })
82
+
83
+ function cohortRoute(pathPrefix: string | null): string | undefined {
84
+ if (!site)
85
+ return undefined
86
+ return route.site('siteIndexingUrls', site.ref, pathPrefix
87
+ ? { status: 'not_indexed', search: pathPrefix }
88
+ : { status: 'not_indexed' }) ?? undefined
89
+ }
90
+ </script>
91
+
92
+ <template>
93
+ <div v-if="state" :key="state._tag" data-pro-indexing-section="cohorts">
94
+ <p class="text-sm text-default">
95
+ {{ verdict }}
96
+ </p>
97
+
98
+ <div v-if="cells.length" class="mt-3 divide-y divide-default">
99
+ <NuxtLink
100
+ v-for="cell in cells"
101
+ :key="`${cell.dimension}:${cell.key}`"
102
+ :to="cohortRoute(cell.pathPrefix)"
103
+ class="flex min-h-11 items-center gap-3 rounded-md px-1 py-2 hover:bg-accented focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"
104
+ >
105
+ <span class="min-w-0 flex-1">
106
+ <span class="block truncate text-sm text-default">{{ cell.label }}</span>
107
+ <span class="block text-mini text-muted">
108
+ {{ formatGroupedNumber(cell.notIndexed) }} of {{ formatGroupedNumber(cell.total) }} pages · {{ percent(cell.complementRate) }} across the rest
109
+ <template v-if="cell.overlapNotIndexed > 0">
110
+ · {{ formatGroupedNumber(cell.overlapNotIndexed) }} also counted above
111
+ </template>
112
+ </span>
113
+ </span>
114
+ <!-- The rate carries the meaning; the fraction is supporting detail. -->
115
+ <span class="shrink-0 text-sm numerals-display text-default">
116
+ {{ percent(cell.rate) }}
117
+ </span>
118
+ <UiIcon name="chevron-right" class="size-4 shrink-0 text-dimmed" aria-hidden="true" />
119
+ </NuxtLink>
120
+ </div>
121
+
122
+ <p v-if="coverageNote" class="mt-3 text-mini text-dimmed">
123
+ {{ coverageNote }}
124
+ </p>
125
+ </div>
126
+ </template>
@@ -0,0 +1,134 @@
1
+ <script lang="ts" setup>
2
+ import type { IndexingCoverageTrendViewState } from '../../shared/coverage-trend'
3
+ import { formatGroupedNumber } from '@nuxtseo/design-system/app/composables/formatting'
4
+ import { computed } from 'vue'
5
+ import { UiButton, UiEmptyState, UiLineChart, UiSkeleton } from '#components'
6
+ import { formatIndexingCoverageDate } from '../../shared/coverage-trend'
7
+
8
+ const {
9
+ state,
10
+ actionTo,
11
+ } = defineProps<{
12
+ state: IndexingCoverageTrendViewState
13
+ actionTo: string
14
+ }>()
15
+
16
+ const emit = defineEmits<{
17
+ retry: []
18
+ }>()
19
+
20
+ const readyTrend = computed(() =>
21
+ state._tag === 'loaded' && state.trend._tag === 'ready'
22
+ ? state.trend
23
+ : null,
24
+ )
25
+ const insufficientTrend = computed(() =>
26
+ state._tag === 'loaded' && state.trend._tag === 'insufficient'
27
+ ? state.trend
28
+ : null,
29
+ )
30
+ const chartPoints = computed<Array<Record<string, unknown>>>(() =>
31
+ readyTrend.value?.points.map(point => ({ ...point })) ?? [],
32
+ )
33
+ const series = [
34
+ {
35
+ key: 'indexed',
36
+ label: 'Indexed',
37
+ color: 'var(--ui-color-primary-500)',
38
+ area: false,
39
+ },
40
+ ]
41
+
42
+ function formatCount(value: number): string {
43
+ return formatGroupedNumber(value)
44
+ }
45
+ </script>
46
+
47
+ <template>
48
+ <div class="mb-4 border-b border-default pb-4" data-pro-indexing-section="coverage-trend">
49
+ <template v-if="readyTrend">
50
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
51
+ <div class="min-w-0">
52
+ <h3 class="text-sm font-strong text-highlighted">
53
+ Indexed URLs over time
54
+ </h3>
55
+ <!-- The legend below prints the indexed count, so restating them in
56
+ prose said the same thing twice. What is left is the part the
57
+ numbers cannot say: what they are counted over, and as of when. -->
58
+ <p class="mt-1 text-mini text-dimmed">
59
+ Inspected sample, not whole-site coverage · {{ formatIndexingCoverageDate(readyTrend.latest.date) }}
60
+ </p>
61
+ </div>
62
+ <UiButton
63
+ :to="actionTo"
64
+ purpose="link"
65
+ trailing-icon="next"
66
+ class="min-h-11 shrink-0 self-start"
67
+ >
68
+ View inspected URLs
69
+ </UiButton>
70
+ </div>
71
+
72
+ <dl class="mt-3 flex flex-wrap gap-x-5 gap-y-2 text-sm">
73
+ <div class="flex items-center gap-2">
74
+ <dt class="flex items-center gap-2 text-muted">
75
+ <span class="h-0.5 w-4 bg-primary-500" aria-hidden="true" />
76
+ Indexed
77
+ </dt>
78
+ <dd class="numerals-display text-highlighted">
79
+ {{ formatGroupedNumber(readyTrend.latest.indexed) }}
80
+ </dd>
81
+ </div>
82
+ </dl>
83
+
84
+ <UiLineChart
85
+ :data="chartPoints"
86
+ x-key="date"
87
+ :series="series"
88
+ :height="180"
89
+ :x-format="formatIndexingCoverageDate"
90
+ :y-format="formatCount"
91
+ class="mt-2"
92
+ />
93
+ </template>
94
+
95
+ <template v-else-if="state._tag === 'loading'">
96
+ <h3 class="text-sm font-strong text-highlighted">
97
+ Indexed URLs over time
98
+ </h3>
99
+ <div class="mt-3" aria-label="Loading indexing coverage trend" aria-busy="true">
100
+ <UiSkeleton class="!h-[180px] w-full" />
101
+ </div>
102
+ </template>
103
+
104
+ <template v-else-if="state._tag === 'error'">
105
+ <h3 class="text-sm font-strong text-highlighted">
106
+ Indexed URLs over time
107
+ </h3>
108
+ <UiEmptyState
109
+ compact
110
+ icon="caution"
111
+ title="Coverage trend unavailable"
112
+ description="Retry to load the saved coverage snapshots."
113
+ >
114
+ <UiButton purpose="secondary" class="!min-h-11" @click="emit('retry')">
115
+ Retry coverage trend
116
+ </UiButton>
117
+ </UiEmptyState>
118
+ </template>
119
+
120
+ <template v-else-if="insufficientTrend">
121
+ <h3 class="text-sm font-strong text-highlighted">
122
+ Indexed URLs over time
123
+ </h3>
124
+ <UiEmptyState
125
+ compact
126
+ icon="compare"
127
+ title="Two snapshots needed"
128
+ :description="insufficientTrend.validPoints === 1
129
+ ? 'The first valid inspection snapshot is ready. The next snapshot will show the trajectory.'
130
+ : 'Coverage history starts after the first two valid inspection snapshots.'"
131
+ />
132
+ </template>
133
+ </div>
134
+ </template>