@nuxtseo/pro-indexing 0.0.0-stage → 0.1.5

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,250 @@
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`, `shared/urls-query`.
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
+ cohortFilter?: true // the urls read honours params.cohort
82
+ }
83
+ ```
84
+
85
+ ```ts
86
+ // app/plugins/indexing-source.ts
87
+ import { PRO_INDEXING_SOURCE_KEY } from '../composables/useIndexingSource'
88
+
89
+ export default defineNuxtPlugin((nuxtApp) => {
90
+ nuxtApp.vueApp.provide(PRO_INDEXING_SOURCE_KEY, useMyIndexingSource())
91
+ })
92
+ ```
93
+
94
+ | Indexing capability | Section it turns on |
95
+ | --- | --- |
96
+ | `diagnose` | URLs table: the remediation for the filtered issue |
97
+ | `inspect` | URLs table: "Re-check with Google" on each row. Its tooltip reports the daily checks left from the last call's `rateLimit` |
98
+ | `canonicalMismatches` | URLs table: consolidation targets on the `canonical_mismatch` facet |
99
+ | `cohorts` | `IndexingCohortList` |
100
+ | `sitemapProblems` | Portfolio Overview: the Sitemap problems tile |
101
+ | `changesRollup` | `IndexingPortfolioChanges` |
102
+ | `indexNow`, `watchedUrls` | `IndexingCapabilityGate` around the site's own panel |
103
+ | `cohortFilter` | Index cohort rows link with `?cohort=` (`indexCohortFilterValue`), and the URLs table passes `cohort` in its `urls` params. Without it, a section row links by path prefix |
104
+
105
+ `hasIndexingCapability(source, name)` and `indexingCapabilities(source)` answer the same question in code, for example to hide a tab.
106
+
107
+ ### Portfolio sections
108
+
109
+ 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:
110
+
111
+ ```ts
112
+ const entries = computed<IndexingPortfolioEntry[]>(() => sites.value.map(site => ({
113
+ site: { id: site.id, ref: site.publicId, label: site.name, url: site.url, dataId: site.gscdumpSiteId },
114
+ read: read.loading ? { _tag: 'loading' } : read.failed ? { _tag: 'failed' } : read.done ? { _tag: 'settled' } : { _tag: 'idle' },
115
+ summary: read.data?.summary ?? null, // from readSiteIndexing()
116
+ trend: read.data?.trend ?? [],
117
+ })))
118
+ ```
119
+
120
+ ```vue
121
+ <IndexingPortfolioOverview :entries="entries" :window="window" @retry="retry" />
122
+
123
+ <IndexingPortfolioIssues :entries="entries" :window="window" @retry="retry" />
124
+
125
+ <IndexingPortfolioChanges :entries="entries" @retry="retry" />
126
+ ```
127
+
128
+ `@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.
129
+
130
+ ### Per-Site sections
131
+
132
+ ```vue
133
+ <IndexingDiagnosisPanel :state="model" :lead="cohortLead" :lead-to="leadRoute" :action-to="actionRoute" />
134
+
135
+ <IndexingCoverageTrend :state="coverageTrend" />
136
+
137
+ <IndexingCohortList :site="site" />
138
+
139
+ <IndexingUrlsTable :site="site" />
140
+ ```
141
+
142
+ The site builds `model` with `buildIndexingOverviewModel(input, diagnose)` from the SDK. `lead` takes any `{ _tag: 'lead', title, detail, actionLabel? }`: the SDK's cohort lead (`selectIndexCohortLead`) or regression lead (`selectIndexingRegressionLead`). The panel draws the title as the headline. With `lead-detail` it draws the detail, such as "That is 42% not indexed, against 10%", on the line below it. The waiting state words itself by `model.state`, and the `#waiting-actions="{ model }"` slot draws the site's own controls, such as a connect button or a Review sitemap link. A lead with no `actionLabel` reads `copy.diagnosis.leadAction` on its button. `IndexingCoverageTrend` draws its chart in the browser only; the server renders the heading, the legend and a block of the chart's height, so a page needs no `ClientOnly` around it. `IndexingUrlsTable` reads `diagnostics` and `urls`, and draws its table in the layer's default shell. The route query is its filter state: it reads `issue`, `facet`, `status`, `search`, `cohort` and `page`, writes them on each change, and follows them, so Back and Forward re-filter the rows. `parseIndexingUrlsQuery` (`shared/urls-query`) parses the same query, for a page that seeds the first read or keys the table. 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).
143
+
144
+ ### Route map
145
+
146
+ 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`.
147
+
148
+ | Route | Kind | Used by |
149
+ | --- | --- | --- |
150
+ | `connectSearchConsole` | App | A site's own "Connect Search Console" links |
151
+ | `siteIndexing` | Site | Portfolio Changes Site links, the "Open indexing report" link |
152
+ | `siteIndexingUrls` | Site | Every "Fix issues" link, with `?issue=` or `?facet=` |
153
+ | `siteIndexingSitemaps` | Site | Sitemap evidence links |
154
+
155
+ ```ts
156
+ // app/app.config.ts
157
+ import { defineProIndexingConfig } from '../shared/config'
158
+
159
+ export default {
160
+ proIndexing: defineProIndexingConfig({
161
+ routes: {
162
+ siteIndexing: '/app/sites/[site]/indexing',
163
+ siteIndexingUrls: '/app/sites/[site]/indexing/urls',
164
+ siteIndexingSitemaps: '/app/sites/[site]/indexing/sitemaps',
165
+ },
166
+ }),
167
+ }
168
+ ```
169
+
170
+ nuxtseo.com sets its map in `apps/pro/app/pro-indexing.ts` and its source in `layers/pro/gsc/app/composables/useNuxtSeoIndexingSource.ts`.
171
+
172
+ ### Copy
173
+
174
+ 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. The groups follow the sections: `common`, `overview`, `siteIssues`, `issues`, `changes`, `diagnosis`, `coverageTrend`, `cohorts`, `urls` (the URLs table, with Google's state labels), and `urlsShell` (the default table shell). `diagnosis.scope` is empty by default; a site that writes it, for example `'{indexed} URLs with recorded indexed results.'`, gets a scope line after the lead detail.
175
+
176
+ ### Indexed tile tone
177
+
178
+ The Portfolio Overview colours the Indexed share by health band: below 80% reads as a warning, below 50% as an error. Set `proIndexing.indexedShareTone` to change it:
179
+
180
+ ```ts
181
+ proIndexing: defineProIndexingConfig({
182
+ indexedShareTone: { _tag: 'neutral' }, // or { _tag: 'health', warningBelow: 70, errorBelow: 40 }
183
+ })
184
+ ```
185
+
186
+ ### Adopting on gscdump.com
187
+
188
+ 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.
189
+
190
+ ```ts
191
+ export function useAppIndexingSource(): IndexingSource {
192
+ const read = <T>(key: () => string, path: () => string | null) => {
193
+ const { data, status, error, refresh } = useAsyncData<T | null>(key, () => {
194
+ const url = path()
195
+ return url ? $fetch<T>(url) : Promise.resolve(null)
196
+ }, { server: false, watch: [path] })
197
+ return { data, status, error, refresh }
198
+ }
199
+ return {
200
+ diagnostics: site => read(() => `diag:${toValue(site)?.dataId}`, () => toValue(site)?.dataId ? `/api/sites/${toValue(site)!.dataId}/indexing/diagnostics` : null),
201
+ 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),
202
+ diagnose: input => diagnoseFromInspection(input), // its own, from inspected URLs
203
+ cohorts: site => cohortsFromUrls(site), // buildIndexCohortsFromIndexingUrls over a 500-row urls read
204
+ // No inspect (the 2,000 a day cap is a product call), no canonicalMismatches
205
+ // (it keeps its own page), no sitemapProblems (no live probe yet), no indexNow.
206
+ }
207
+ }
208
+ ```
209
+
210
+ | Section | gscdump.com |
211
+ | --- | --- |
212
+ | Portfolio Overview, Issues, Markdown export | yes |
213
+ | Portfolio Changes | after a `changesRollup` over per-Site transitions |
214
+ | Diagnosis panel, coverage trend | yes |
215
+ | Index cohorts | yes, built from inspected URLs |
216
+ | URLs table | yes, no re-inspect, no rich results facet |
217
+ | Sitemap problems tile, IndexNow | off (no probe; dropped in #345) |
218
+
219
+ ### Adopting on Request Indexing
220
+
221
+ 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.
222
+
223
+ ```ts
224
+ export function useRiIndexingSource(): IndexingSource {
225
+ const gscdump = useProGscdump()
226
+ return {
227
+ diagnostics: site => useRiRead(() => gscdump.getSiteIndexingDiagnostics({ params: { siteId: toValue(site)!.dataId! } }, true), site),
228
+ urls: (site, params) => useRiRead(() => gscdump.listSiteIndexingUrls({ params: { siteId: toValue(site)!.dataId! }, query: toValue(params) }, true), site, params),
229
+ diagnose: input => diagnoseIndexing(input),
230
+ inspect: () => (site, urls) => gscdump.inspectSiteIndexingUrls({ params: { siteId: site.dataId! }, body: { urls: [...urls] } }),
231
+ cohorts: site => useRiCohorts(site), // buildIndexCohortsFromIndexingUrls
232
+ sitemapProblems: () => useRiSitemapRollup(), // from its per-Site probe
233
+ changesRollup: () => useRiChangesFromTransitions(), // listSiteIndexingTransitions per Site
234
+ watchedUrls: true,
235
+ }
236
+ }
237
+ ```
238
+
239
+ | Section | Request Indexing |
240
+ | --- | --- |
241
+ | Portfolio Overview, Issues, Markdown export | yes (new: it has no Issues tab, stack chart, or export today) |
242
+ | Portfolio Changes | yes, from per-Site transitions |
243
+ | Diagnosis panel, coverage trend, Index cohorts | yes, replaces its copies |
244
+ | URLs table with re-inspect | yes |
245
+ | Sitemap problems tile | yes, from its probe |
246
+ | Watched URLs | its own panel inside `IndexingCapabilityGate capability="watchedUrls"` |
247
+
248
+ ## Releasing
249
+
250
+ `@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,14 @@
1
+ import type { IndexedShareTone } from '../shared/config'
2
+ import type { ProIndexingCopyOverrides } from '../shared/copy'
3
+ import type { ProIndexingRouteMap } from '../shared/routes'
4
+
5
+ // The site's seams for the indexing sections. The layer maps no route, so each
6
+ // link that needs a route hides until the site maps one (README, Route map).
7
+ // An unset `indexedShareTone` reads as the default health bands.
8
+ export default {
9
+ proIndexing: {
10
+ routes: {} as ProIndexingRouteMap,
11
+ copy: {} as ProIndexingCopyOverrides,
12
+ indexedShareTone: undefined as IndexedShareTone | undefined,
13
+ },
14
+ }
@@ -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,130 @@
1
+ <script lang="ts" setup>
2
+ import type { IndexCohortCell } from '@gscdump/sdk/indexing'
3
+ import type { IndexingSite } from '../../shared/source'
4
+ import { indexCohortFilterValue, sampledIndexStateMessage } from '@gscdump/sdk/indexing'
5
+ import { formatGroupedNumber } from '@nuxtseo/design-system/app/composables/formatting'
6
+ import { fillCopy } from '@nuxtseo/pro-shell/shared/copy'
7
+ import { computed } from 'vue'
8
+ import { NuxtLink, UiIcon } from '#components'
9
+ import { useIndexingSource } from '../composables/useIndexingSource'
10
+ import { useProIndexingCopy } from '../composables/useProIndexingCopy'
11
+ import { useProIndexingRoute } from '../composables/useProIndexingRoute'
12
+ // Which PART of the site does Google treat worse than the rest — the question
13
+ // GSC's own taxonomy ("37 crawled but not indexed") cannot answer because it
14
+ // names a symptom, not a place.
15
+ //
16
+ // Rows carry no severity dot on purpose: every cohort in this list already
17
+ // cleared a corrected significance test, so a dot on all of them encodes nothing
18
+ // and spends the status-colour budget on a non-signal (DESIGN, colour budget).
19
+
20
+ // Reads the `cohorts` capability. Without it, or before the read returns,
21
+ // the section renders nothing.
22
+ const { site } = defineProps<{
23
+ site: IndexingSite | null | undefined
24
+ }>()
25
+
26
+ const source = useIndexingSource()
27
+ const route = useProIndexingRoute()
28
+ const copy = useProIndexingCopy().cohorts
29
+ const n = formatGroupedNumber
30
+ const read = source?.cohorts?.(() => site) ?? null
31
+ const state = computed(() => read?.data.value ?? null)
32
+
33
+ const percent = (value: number) => `${Math.round(value * 100)}%`
34
+
35
+ const cells = computed(() => state.value?._tag === 'outliers' ? state.value.cells : [])
36
+
37
+ /** One honest verdict sentence, then the list (ADR-0105). */
38
+ const verdict = computed(() => {
39
+ const state = read?.data.value
40
+ if (!state)
41
+ return ''
42
+ if (state._tag === 'no-evidence') {
43
+ if (state.reason === 'sampled-index-state' && state.sample)
44
+ return sampledIndexStateMessage(state.sample.enumerated, state.sample.reported)
45
+ return state.reason === 'no-completed-crawl' ? copy.noCompletedCrawl : copy.noMatch
46
+ }
47
+ if (state._tag === 'uniform') {
48
+ const spread = fillCopy(copy.spread, { notIndexed: n(state.baseline.notIndexed), total: n(state.baseline.total) })
49
+ // `tested: 0` means no group was large enough to compare — a coverage fact,
50
+ // not a clean bill. Reporting it as "nothing indexes worse" would assert a
51
+ // comparison that never ran.
52
+ return fillCopy(state.tested === 0 ? copy.untested : copy.uniform, { spread })
53
+ }
54
+ // The hero already states the worst cohort as the page's primary diagnosis.
55
+ // Restating it here would tell the same story twice on one screen, so this
56
+ // line frames what the list IS. HOW it was ranked is method, and method rides
57
+ // the dimmed coverage line below rather than the verdict.
58
+ const count = state.cells.length
59
+ return count === 1 ? copy.outliersOne : fillCopy(copy.outliersMany, { count })
60
+ })
61
+
62
+ /**
63
+ * The join is never a census — pages Google knows but we never crawled carry no
64
+ * cohort attributes, so they sit outside every rate on screen.
65
+ */
66
+ const coverageNote = computed(() => {
67
+ const state = read?.data.value
68
+ if (!state || state._tag === 'no-evidence')
69
+ return null
70
+ const { analysed, notCrawled, excludedFragments } = state.coverage
71
+ const groups = state._tag === 'uniform' || state._tag === 'outliers' ? state.tested : 0
72
+ const parts = [
73
+ groups > 0
74
+ ? fillCopy(copy.comparedGroups, { count: n(analysed), groups: n(groups) })
75
+ : fillCopy(copy.compared, { count: n(analysed) }),
76
+ ]
77
+ if (notCrawled > 0)
78
+ parts.push(fillCopy(copy.notCrawled, { count: n(notCrawled) }))
79
+ if (excludedFragments > 0)
80
+ parts.push(fillCopy(copy.fragments, { count: n(excludedFragments) }))
81
+ return parts.join(' · ')
82
+ })
83
+
84
+ // With the `cohortFilter` capability a row links to its exact cohort. Without
85
+ // it, a section row links by its path prefix and a lifecycle row by status.
86
+ function cohortRoute(cell: IndexCohortCell): string | undefined {
87
+ if (!site)
88
+ return undefined
89
+ const query = source?.cohortFilter
90
+ ? { status: 'not_indexed', cohort: indexCohortFilterValue(cell) }
91
+ : cell.pathPrefix ? { status: 'not_indexed', search: cell.pathPrefix } : { status: 'not_indexed' }
92
+ return route.site('siteIndexingUrls', site.ref, query) ?? undefined
93
+ }
94
+ </script>
95
+
96
+ <template>
97
+ <div v-if="state" :key="state._tag" data-pro-indexing-section="cohorts">
98
+ <p class="text-sm text-default">
99
+ {{ verdict }}
100
+ </p>
101
+
102
+ <div v-if="cells.length" class="mt-3 divide-y divide-default">
103
+ <NuxtLink
104
+ v-for="cell in cells"
105
+ :key="`${cell.dimension}:${cell.key}`"
106
+ :to="cohortRoute(cell)"
107
+ 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"
108
+ >
109
+ <span class="min-w-0 flex-1">
110
+ <span class="block truncate text-sm text-default">{{ cell.label }}</span>
111
+ <span class="block text-mini text-muted">
112
+ {{ fillCopy(copy.cellDetail, { notIndexed: n(cell.notIndexed), total: n(cell.total), rest: percent(cell.complementRate) }) }}
113
+ <template v-if="cell.overlapNotIndexed > 0">
114
+ · {{ fillCopy(copy.cellOverlap, { count: n(cell.overlapNotIndexed) }) }}
115
+ </template>
116
+ </span>
117
+ </span>
118
+ <!-- The rate carries the meaning; the fraction is supporting detail. -->
119
+ <span class="shrink-0 text-sm numerals-display text-default">
120
+ {{ percent(cell.rate) }}
121
+ </span>
122
+ <UiIcon name="chevron-right" class="size-4 shrink-0 text-dimmed" aria-hidden="true" />
123
+ </NuxtLink>
124
+ </div>
125
+
126
+ <p v-if="coverageNote" class="mt-3 text-mini text-dimmed">
127
+ {{ coverageNote }}
128
+ </p>
129
+ </div>
130
+ </template>
@@ -0,0 +1,145 @@
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 { fillCopy } from '@nuxtseo/pro-shell/shared/copy'
5
+ import { computed } from 'vue'
6
+ import { ClientOnly, UiButton, UiEmptyState, UiLineChart, UiSkeleton } from '#components'
7
+ import { formatIndexingCoverageDate } from '../../shared/coverage-trend'
8
+ import { useProIndexingCopy } from '../composables/useProIndexingCopy'
9
+
10
+ // The chart draws in the browser only. The server renders the heading and the
11
+ // legend, and a block of the chart's height, so a page needs no wrapper.
12
+
13
+ const {
14
+ state,
15
+ actionTo,
16
+ } = defineProps<{
17
+ state: IndexingCoverageTrendViewState
18
+ actionTo: string
19
+ }>()
20
+
21
+ const emit = defineEmits<{
22
+ retry: []
23
+ }>()
24
+
25
+ const copy = useProIndexingCopy().coverageTrend
26
+ const CHART_HEIGHT = 180
27
+
28
+ const readyTrend = computed(() =>
29
+ state._tag === 'loaded' && state.trend._tag === 'ready'
30
+ ? state.trend
31
+ : null,
32
+ )
33
+ const insufficientTrend = computed(() =>
34
+ state._tag === 'loaded' && state.trend._tag === 'insufficient'
35
+ ? state.trend
36
+ : null,
37
+ )
38
+ const chartPoints = computed<Array<Record<string, unknown>>>(() =>
39
+ readyTrend.value?.points.map(point => ({ ...point })) ?? [],
40
+ )
41
+ const series = [
42
+ {
43
+ key: 'indexed',
44
+ label: copy.indexed,
45
+ color: 'var(--ui-color-primary-500)',
46
+ area: false,
47
+ },
48
+ ]
49
+
50
+ function formatCount(value: number): string {
51
+ return formatGroupedNumber(value)
52
+ }
53
+ </script>
54
+
55
+ <template>
56
+ <div class="mb-4 border-b border-default pb-4" data-pro-indexing-section="coverage-trend">
57
+ <template v-if="readyTrend">
58
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
59
+ <div class="min-w-0">
60
+ <h3 class="text-sm font-strong text-highlighted">
61
+ {{ copy.title }}
62
+ </h3>
63
+ <!-- The legend below prints the indexed count, so restating them in
64
+ prose said the same thing twice. What is left is the part the
65
+ numbers cannot say: what they are counted over, and as of when. -->
66
+ <p class="mt-1 text-mini text-dimmed">
67
+ {{ fillCopy(copy.scope, { date: formatIndexingCoverageDate(readyTrend.latest.date) }) }}
68
+ </p>
69
+ </div>
70
+ <UiButton
71
+ :to="actionTo"
72
+ purpose="link"
73
+ trailing-icon="next"
74
+ class="min-h-11 shrink-0 self-start"
75
+ >
76
+ {{ copy.viewUrls }}
77
+ </UiButton>
78
+ </div>
79
+
80
+ <dl class="mt-3 flex flex-wrap gap-x-5 gap-y-2 text-sm">
81
+ <div class="flex items-center gap-2">
82
+ <dt class="flex items-center gap-2 text-muted">
83
+ <span class="h-0.5 w-4 bg-primary-500" aria-hidden="true" />
84
+ {{ copy.indexed }}
85
+ </dt>
86
+ <dd class="numerals-display text-highlighted">
87
+ {{ formatGroupedNumber(readyTrend.latest.indexed) }}
88
+ </dd>
89
+ </div>
90
+ </dl>
91
+
92
+ <ClientOnly>
93
+ <UiLineChart
94
+ :data="chartPoints"
95
+ x-key="date"
96
+ :series="series"
97
+ :height="CHART_HEIGHT"
98
+ :x-format="formatIndexingCoverageDate"
99
+ :y-format="formatCount"
100
+ class="mt-2"
101
+ />
102
+ <template #fallback>
103
+ <div class="mt-2" :style="{ height: `${CHART_HEIGHT}px` }" aria-hidden="true" />
104
+ </template>
105
+ </ClientOnly>
106
+ </template>
107
+
108
+ <template v-else-if="state._tag === 'loading'">
109
+ <h3 class="text-sm font-strong text-highlighted">
110
+ {{ copy.title }}
111
+ </h3>
112
+ <div class="mt-3" :aria-label="copy.loadingLabel" aria-busy="true">
113
+ <UiSkeleton class="!h-[180px] w-full" />
114
+ </div>
115
+ </template>
116
+
117
+ <template v-else-if="state._tag === 'error'">
118
+ <h3 class="text-sm font-strong text-highlighted">
119
+ {{ copy.title }}
120
+ </h3>
121
+ <UiEmptyState
122
+ compact
123
+ icon="caution"
124
+ :title="copy.errorTitle"
125
+ :description="copy.errorBody"
126
+ >
127
+ <UiButton purpose="secondary" class="!min-h-11" @click="emit('retry')">
128
+ {{ copy.retry }}
129
+ </UiButton>
130
+ </UiEmptyState>
131
+ </template>
132
+
133
+ <template v-else-if="insufficientTrend">
134
+ <h3 class="text-sm font-strong text-highlighted">
135
+ {{ copy.title }}
136
+ </h3>
137
+ <UiEmptyState
138
+ compact
139
+ icon="compare"
140
+ :title="copy.insufficientTitle"
141
+ :description="insufficientTrend.validPoints === 1 ? copy.insufficientOne : copy.insufficientNone"
142
+ />
143
+ </template>
144
+ </div>
145
+ </template>