@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 +237 -2
- package/app/app.config.ts +11 -0
- package/app/components/IndexingCapabilityGate.vue +20 -0
- package/app/components/IndexingCohortList.vue +126 -0
- package/app/components/IndexingCoverageTrend.vue +134 -0
- package/app/components/IndexingCrawlPipeline.vue +208 -0
- package/app/components/IndexingDiagnosisPanel.vue +226 -0
- package/app/components/IndexingPortfolioChanges.vue +320 -0
- package/app/components/IndexingPortfolioIssues.vue +202 -0
- package/app/components/IndexingPortfolioOverview.vue +204 -0
- package/app/components/IndexingSiteIssues.vue +123 -0
- package/app/components/IndexingUrlsTable.vue +1096 -0
- package/app/components/IndexingUrlsTableShell.vue +231 -0
- package/app/composables/useIndexingSource.ts +27 -0
- package/app/composables/useProIndexingCopy.ts +10 -0
- package/app/composables/useProIndexingRoute.ts +23 -0
- package/nuxt.config.ts +33 -0
- package/package.json +67 -3
- package/shared/changes.ts +124 -0
- package/shared/config.ts +16 -0
- package/shared/copy.ts +169 -0
- package/shared/coverage-trend.ts +72 -0
- package/shared/issue-display.ts +77 -0
- package/shared/portfolio-overview.ts +120 -0
- package/shared/portfolio.ts +79 -0
- package/shared/routes.ts +63 -0
- package/shared/source.ts +138 -0
package/shared/copy.ts
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// The words the indexing sections render. COPY.md (Indexing section assets)
|
|
2
|
+
// owns each default; change it there first. A site rewords any key through
|
|
3
|
+
// app.config `proIndexing.copy`. Unset keys keep these defaults. Placeholders
|
|
4
|
+
// in braces, such as `{site}`, are filled by the component.
|
|
5
|
+
|
|
6
|
+
export interface ProIndexingCopy {
|
|
7
|
+
readonly common: {
|
|
8
|
+
readonly failedTitle: string
|
|
9
|
+
readonly failedOne: string
|
|
10
|
+
readonly failedMany: string
|
|
11
|
+
readonly excludesOne: string
|
|
12
|
+
readonly excludesMany: string
|
|
13
|
+
readonly retry: string
|
|
14
|
+
readonly collectingTitle: string
|
|
15
|
+
readonly collectingBody: string
|
|
16
|
+
readonly fixIssues: string
|
|
17
|
+
readonly fixIssuesLabel: string
|
|
18
|
+
}
|
|
19
|
+
readonly overview: {
|
|
20
|
+
readonly indexedTitle: string
|
|
21
|
+
readonly indexedTooltip: string
|
|
22
|
+
readonly notIndexedTitle: string
|
|
23
|
+
readonly notIndexedTooltip: string
|
|
24
|
+
readonly crawlErrorsTitle: string
|
|
25
|
+
readonly crawlErrorsTooltip: string
|
|
26
|
+
readonly sitemapProblemsTitle: string
|
|
27
|
+
readonly sitemapProblemsTooltip: string
|
|
28
|
+
readonly sitemapProblemsFailedTooltip: string
|
|
29
|
+
readonly sitemapProblemsFailed: string
|
|
30
|
+
readonly stackTitle: string
|
|
31
|
+
readonly trendSuffix: string
|
|
32
|
+
}
|
|
33
|
+
readonly siteIssues: {
|
|
34
|
+
readonly tableLabel: string
|
|
35
|
+
readonly issue: string
|
|
36
|
+
readonly count: string
|
|
37
|
+
readonly action: string
|
|
38
|
+
readonly failedBody: string
|
|
39
|
+
readonly openReport: string
|
|
40
|
+
readonly emptyNoObservation: string
|
|
41
|
+
readonly emptyAllIndexed: string
|
|
42
|
+
readonly emptyUnattributedOne: string
|
|
43
|
+
readonly emptyUnattributedMany: string
|
|
44
|
+
}
|
|
45
|
+
readonly issues: {
|
|
46
|
+
readonly stackTitle: string
|
|
47
|
+
readonly tableLabel: string
|
|
48
|
+
readonly issue: string
|
|
49
|
+
readonly urls: string
|
|
50
|
+
readonly sites: string
|
|
51
|
+
readonly mostAffected: string
|
|
52
|
+
readonly emptyTitle: string
|
|
53
|
+
readonly emptyBody: string
|
|
54
|
+
}
|
|
55
|
+
readonly changes: {
|
|
56
|
+
readonly window: string
|
|
57
|
+
readonly opened: string
|
|
58
|
+
readonly cleared: string
|
|
59
|
+
readonly legendLabel: string
|
|
60
|
+
readonly chartLabel: string
|
|
61
|
+
readonly chartCaption: string
|
|
62
|
+
readonly day: string
|
|
63
|
+
readonly tableLabel: string
|
|
64
|
+
readonly site: string
|
|
65
|
+
readonly notIndexed: string
|
|
66
|
+
readonly change: string
|
|
67
|
+
readonly since: string
|
|
68
|
+
readonly sampledCounts: string
|
|
69
|
+
readonly emptyTitle: string
|
|
70
|
+
readonly emptyBody: string
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const PRO_INDEXING_COPY: ProIndexingCopy = {
|
|
75
|
+
common: {
|
|
76
|
+
failedTitle: 'Indexing data failed to load',
|
|
77
|
+
failedOne: '{site} could not be loaded. Try the indexing request again.',
|
|
78
|
+
failedMany: '{count} Sites could not be loaded. Try the indexing requests again.',
|
|
79
|
+
excludesOne: 'Excludes 1 Site that failed to load',
|
|
80
|
+
excludesMany: 'Excludes {count} Sites that failed to load',
|
|
81
|
+
retry: 'Retry',
|
|
82
|
+
collectingTitle: 'Collecting indexing data',
|
|
83
|
+
collectingBody: 'Indexing coverage appears after Search Console reports the first URL.',
|
|
84
|
+
fixIssues: 'Fix issues',
|
|
85
|
+
fixIssuesLabel: 'Fix issues: {issue} on {site}',
|
|
86
|
+
},
|
|
87
|
+
overview: {
|
|
88
|
+
indexedTitle: 'Indexed',
|
|
89
|
+
indexedTooltip: 'Share of submitted URLs that Google has indexed.',
|
|
90
|
+
notIndexedTitle: 'Not indexed',
|
|
91
|
+
notIndexedTooltip: 'Submitted URLs Google has not indexed.',
|
|
92
|
+
crawlErrorsTitle: 'Crawl errors',
|
|
93
|
+
crawlErrorsTooltip: 'URLs Google reports as not found, soft 404, or server errors. Sitemap availability and sitemap-page conflicts are shown separately.',
|
|
94
|
+
sitemapProblemsTitle: 'Sitemap problems',
|
|
95
|
+
sitemapProblemsTooltip: 'Sites with a Sitemap that is unreachable or has errors.',
|
|
96
|
+
sitemapProblemsFailedTooltip: 'The Sitemap status could not be read.',
|
|
97
|
+
sitemapProblemsFailed: 'Failed to load',
|
|
98
|
+
stackTitle: 'Not indexed URLs by Site',
|
|
99
|
+
trendSuffix: ' points',
|
|
100
|
+
},
|
|
101
|
+
siteIssues: {
|
|
102
|
+
tableLabel: 'Indexing issues for {site}',
|
|
103
|
+
issue: 'Issue',
|
|
104
|
+
count: 'Count',
|
|
105
|
+
action: 'Action',
|
|
106
|
+
failedBody: 'Google indexing data could not be loaded for {site}.',
|
|
107
|
+
openReport: 'Open indexing report',
|
|
108
|
+
emptyNoObservation: 'Google hasn\'t reported coverage for this site yet. Breakdown appears after the first Search Console sync.',
|
|
109
|
+
emptyAllIndexed: 'Every submitted URL is indexed, so there is nothing to break down.',
|
|
110
|
+
emptyUnattributedOne: 'Google hasn\'t attributed a reason to the {count} URL it has not indexed.',
|
|
111
|
+
emptyUnattributedMany: 'Google hasn\'t attributed a reason to the {count} URLs it has not indexed.',
|
|
112
|
+
},
|
|
113
|
+
issues: {
|
|
114
|
+
stackTitle: 'Reported URLs by issue',
|
|
115
|
+
tableLabel: 'Indexing issues across Sites',
|
|
116
|
+
issue: 'Issue',
|
|
117
|
+
urls: 'URLs',
|
|
118
|
+
sites: 'Sites',
|
|
119
|
+
mostAffected: 'Most affected',
|
|
120
|
+
emptyTitle: 'No issues reported',
|
|
121
|
+
emptyBody: 'Google reports no issue counts for these Sites. Issue counts may not explain every URL that is not indexed.',
|
|
122
|
+
},
|
|
123
|
+
changes: {
|
|
124
|
+
window: 'Last {days} days',
|
|
125
|
+
opened: 'First recorded',
|
|
126
|
+
cleared: 'Cleared',
|
|
127
|
+
legendLabel: 'Chart legend',
|
|
128
|
+
chartLabel: 'First recorded issues above zero and cleared issues below zero, per day',
|
|
129
|
+
chartCaption: 'First recorded and cleared issues per day',
|
|
130
|
+
day: 'Day',
|
|
131
|
+
tableLabel: 'Indexing changes by Site',
|
|
132
|
+
site: 'Site',
|
|
133
|
+
notIndexed: 'Not indexed',
|
|
134
|
+
change: 'Change',
|
|
135
|
+
since: 'since {date}',
|
|
136
|
+
sampledCounts: 'Reads up to 100 URLs per reason on a large Site, so this count can be below the real total.',
|
|
137
|
+
emptyTitle: 'No indexing changes recorded',
|
|
138
|
+
emptyBody: 'Search Console reported no change in not indexed URLs, and no recorded or cleared issues, for these Sites in the last {days} days.',
|
|
139
|
+
},
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
type DeepPartial<T> = {
|
|
143
|
+
readonly [K in keyof T]?: T[K] extends string ? string : DeepPartial<T[K]>
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** `proIndexing.copy` in app.config: any subset of the defaults. */
|
|
147
|
+
export type ProIndexingCopyOverrides = DeepPartial<ProIndexingCopy>
|
|
148
|
+
|
|
149
|
+
function isRecord(value: unknown): value is Record<string, unknown> {
|
|
150
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function mergeCopy<T>(defaults: T, overrides: unknown): T {
|
|
154
|
+
if (!isRecord(defaults) || !isRecord(overrides))
|
|
155
|
+
return defaults
|
|
156
|
+
const merged: Record<string, unknown> = { ...defaults }
|
|
157
|
+
for (const [key, base] of Object.entries(defaults)) {
|
|
158
|
+
const next = overrides[key]
|
|
159
|
+
merged[key] = typeof base === 'string'
|
|
160
|
+
? (typeof next === 'string' ? next : base)
|
|
161
|
+
: mergeCopy(base, next)
|
|
162
|
+
}
|
|
163
|
+
return merged as T
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The copy with a site's overrides applied. Unknown keys and non-string values are ignored. */
|
|
167
|
+
export function resolveProIndexingCopy(overrides: ProIndexingCopyOverrides | undefined): ProIndexingCopy {
|
|
168
|
+
return mergeCopy(PRO_INDEXING_COPY, overrides)
|
|
169
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Historical indexed counts behind the coverage chart.
|
|
2
|
+
//
|
|
3
|
+
// Moved from nuxtseo.com `layers/pro/gsc/app/utils/indexing-coverage-trend.ts`.
|
|
4
|
+
//
|
|
5
|
+
// The read's totalUrls may count submitted sitemap URLs or inspection rows.
|
|
6
|
+
// It cannot establish an inspected denominator. Only indexedCount has a stable
|
|
7
|
+
// meaning. One valid point is not a trend, so the chart waits for two.
|
|
8
|
+
|
|
9
|
+
export interface IndexingCoverageTrendSourcePoint {
|
|
10
|
+
date: string
|
|
11
|
+
indexedCount: number | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IndexingCoverageTrendPoint extends Record<string, unknown> {
|
|
15
|
+
date: string
|
|
16
|
+
indexed: number
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type IndexingCoverageTrend
|
|
20
|
+
= | { _tag: 'insufficient', validPoints: number }
|
|
21
|
+
| { _tag: 'ready', points: IndexingCoverageTrendPoint[], latest: IndexingCoverageTrendPoint }
|
|
22
|
+
|
|
23
|
+
export type IndexingCoverageTrendViewState
|
|
24
|
+
= | { _tag: 'loading' }
|
|
25
|
+
| { _tag: 'error' }
|
|
26
|
+
| { _tag: 'loaded', trend: IndexingCoverageTrend }
|
|
27
|
+
|
|
28
|
+
const MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
|
|
29
|
+
|
|
30
|
+
export function formatIndexingCoverageDate(raw: unknown): string {
|
|
31
|
+
const date = new Date(String(raw))
|
|
32
|
+
if (Number.isNaN(date.getTime()))
|
|
33
|
+
return String(raw)
|
|
34
|
+
const month = MONTHS[date.getUTCMonth()]
|
|
35
|
+
if (!month)
|
|
36
|
+
return String(raw)
|
|
37
|
+
return `${date.getUTCDate()} ${month}`
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function parsePoint(source: IndexingCoverageTrendSourcePoint): IndexingCoverageTrendPoint | null {
|
|
41
|
+
const date = source.date.trim()
|
|
42
|
+
const indexed = source.indexedCount
|
|
43
|
+
if (
|
|
44
|
+
!date
|
|
45
|
+
|| indexed == null
|
|
46
|
+
|| !Number.isSafeInteger(indexed)
|
|
47
|
+
|| indexed < 0
|
|
48
|
+
) {
|
|
49
|
+
return null
|
|
50
|
+
}
|
|
51
|
+
return { date, indexed }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function buildIndexingCoverageTrend(
|
|
55
|
+
source: ReadonlyArray<IndexingCoverageTrendSourcePoint>,
|
|
56
|
+
): IndexingCoverageTrend {
|
|
57
|
+
const pointsByDate = new Map<string, IndexingCoverageTrendPoint>()
|
|
58
|
+
for (const row of source) {
|
|
59
|
+
const point = parsePoint(row)
|
|
60
|
+
if (point)
|
|
61
|
+
pointsByDate.set(point.date, point)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const points = [...pointsByDate.values()]
|
|
65
|
+
.sort((left, right) => left.date.localeCompare(right.date))
|
|
66
|
+
|
|
67
|
+
const latest = points.at(-1)
|
|
68
|
+
if (points.length < 2 || !latest)
|
|
69
|
+
return { _tag: 'insufficient', validPoints: points.length }
|
|
70
|
+
|
|
71
|
+
return { _tag: 'ready', points, latest }
|
|
72
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// How an indexing issue type and severity look: icon and tone per type, and
|
|
2
|
+
// the severity group styles. The issue catalog itself (`issueDetails`,
|
|
3
|
+
// `severityOrder`) is `@gscdump/sdk/indexing-issues`.
|
|
4
|
+
//
|
|
5
|
+
// Moved from nuxtseo.com `layers/pro/gsc/app/utils/indexing-issues.ts`.
|
|
6
|
+
|
|
7
|
+
import type { IssueSeverity } from '@gscdump/sdk/indexing-issues'
|
|
8
|
+
|
|
9
|
+
// Keyed by `@gscdump/sdk` issue type. A type with no entry falls back to the
|
|
10
|
+
// generic icon, so add an entry when the SDK adds a type.
|
|
11
|
+
export const issueIcons: Record<string, string> = {
|
|
12
|
+
canonical_mismatch: 'compare',
|
|
13
|
+
canonical_cross_domain: 'i-lucide-globe-2',
|
|
14
|
+
canonical_formatting: 'i-lucide-text-cursor-input',
|
|
15
|
+
stale_crawl: 'clock',
|
|
16
|
+
very_stale_crawl: 'clock',
|
|
17
|
+
unknown_to_google: 'help',
|
|
18
|
+
crawled_not_indexed: 'hide',
|
|
19
|
+
discovered_not_indexed: 'search',
|
|
20
|
+
not_found: 'file-x',
|
|
21
|
+
soft_404: 'warning',
|
|
22
|
+
server_error: 'i-lucide-server-crash',
|
|
23
|
+
access_forbidden: 'i-lucide-shield-x',
|
|
24
|
+
access_denied: 'i-lucide-lock',
|
|
25
|
+
blocked_4xx: 'i-lucide-ban',
|
|
26
|
+
redirect_error: 'i-lucide-repeat',
|
|
27
|
+
crawl_error: 'i-lucide-bug',
|
|
28
|
+
blocked_robots: 'shield',
|
|
29
|
+
noindex: 'hide',
|
|
30
|
+
redirect: 'next',
|
|
31
|
+
sitemap_redirect: 'i-lucide-corner-up-right',
|
|
32
|
+
alternate_canonical: 'i-lucide-copy',
|
|
33
|
+
duplicate_no_canonical: 'i-lucide-copy-slash',
|
|
34
|
+
indexed_consider_canonical: 'i-lucide-file-check-2',
|
|
35
|
+
page_removed: 'i-lucide-eraser',
|
|
36
|
+
fragment_url: 'hash',
|
|
37
|
+
not_indexed: 'error',
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const severityConfig: Record<IssueSeverity, { label: string, headerIcon: string, border: string, borderActive: string, bg: string, bgActive: string, ring: string, focusRing: string, text: string, iconBg: string }> = {
|
|
41
|
+
error: {
|
|
42
|
+
label: 'Errors',
|
|
43
|
+
headerIcon: 'warning',
|
|
44
|
+
border: 'border-default',
|
|
45
|
+
borderActive: 'border-error/50',
|
|
46
|
+
bg: 'bg-elevated hover:border-error/30',
|
|
47
|
+
bgActive: 'bg-error/10',
|
|
48
|
+
ring: 'ring-2 ring-error/20',
|
|
49
|
+
focusRing: 'focus-visible:ring-error/50',
|
|
50
|
+
text: 'text-error',
|
|
51
|
+
iconBg: 'bg-error/15',
|
|
52
|
+
},
|
|
53
|
+
warning: {
|
|
54
|
+
label: 'Warnings',
|
|
55
|
+
headerIcon: 'caution',
|
|
56
|
+
border: 'border-default',
|
|
57
|
+
borderActive: 'border-warning/50',
|
|
58
|
+
bg: 'bg-elevated hover:border-warning/30',
|
|
59
|
+
bgActive: 'bg-warning/10',
|
|
60
|
+
ring: 'ring-2 ring-warning/20',
|
|
61
|
+
focusRing: 'focus-visible:ring-warning/50',
|
|
62
|
+
text: 'text-warning',
|
|
63
|
+
iconBg: 'bg-warning/15',
|
|
64
|
+
},
|
|
65
|
+
info: {
|
|
66
|
+
label: 'Info',
|
|
67
|
+
headerIcon: 'note',
|
|
68
|
+
border: 'border-default',
|
|
69
|
+
borderActive: 'border-info/50',
|
|
70
|
+
bg: 'bg-elevated hover:border-info/30',
|
|
71
|
+
bgActive: 'bg-info/10',
|
|
72
|
+
ring: 'ring-2 ring-info/20',
|
|
73
|
+
focusRing: 'focus-visible:ring-info/50',
|
|
74
|
+
text: 'text-info',
|
|
75
|
+
iconBg: 'bg-info/15',
|
|
76
|
+
},
|
|
77
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// The Portfolio Overview figures: every value a Site and the Portfolio show on
|
|
2
|
+
// the Overview, from one reading per Site. Pure. The tiles, the stack chart,
|
|
3
|
+
// and a site's own per-Site rows all read this one model, so they agree.
|
|
4
|
+
//
|
|
5
|
+
// Moved from nuxtseo.com `layers/pro/gsc/app/components/pro/ProSiteGroupIndexing.vue`.
|
|
6
|
+
|
|
7
|
+
import type { IndexingMarkdownSite, IndexingReadingWindow, IndexingStack, IndexingTrendReading, IndexingWindowDays, IndexingWindowReading, PortfolioIndexingTrendPoint } from '@gscdump/sdk/indexing'
|
|
8
|
+
import type { IndexingPortfolioEntry } from './portfolio'
|
|
9
|
+
import { crawlErrorCount, indexedRateChange, notIndexedStack, portfolioIndexingTrend, portfolioRateChangeOver, siteIndexingReading } from '@gscdump/sdk/indexing'
|
|
10
|
+
|
|
11
|
+
export interface IndexingPortfolioOverviewModel {
|
|
12
|
+
/** Each Site's reading at the window end, by Site id. Null when the Site has none for the window. */
|
|
13
|
+
readonly readings: ReadonlyMap<string, IndexingWindowReading | null>
|
|
14
|
+
/** Summed over the Sites with a reading. Null when none has one. */
|
|
15
|
+
readonly indexed: { readonly indexed: number, readonly total: number, readonly percent: number } | null
|
|
16
|
+
/** Summed per Site, so a Site share column adds up. Null when no Site has a reading. */
|
|
17
|
+
readonly notIndexed: number | null
|
|
18
|
+
/** Crawl errors at the window end over the Sites with a trend reading. Null when none has one. */
|
|
19
|
+
readonly crawlErrors: number | null
|
|
20
|
+
/** The Portfolio trend over the Sites with a reading. */
|
|
21
|
+
readonly trend: PortfolioIndexingTrendPoint[]
|
|
22
|
+
/** The indexed rate change across the window, in points. */
|
|
23
|
+
readonly indexedChange: number | null
|
|
24
|
+
/** The indexed rate change over 7 days, in points. */
|
|
25
|
+
readonly change7d: number | null
|
|
26
|
+
readonly stack: IndexingStack
|
|
27
|
+
/** Number of Sites with a reading. */
|
|
28
|
+
readonly sitesWithReading: number
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function inWindow(point: { date: string }, window: IndexingWindowDays): boolean {
|
|
32
|
+
return point.date >= window.start && point.date <= window.end
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** URLs at stake for a Site: inspected minus indexed. Null without a reading. */
|
|
36
|
+
export function unindexedCount(reading: IndexingWindowReading | null | undefined): number | null {
|
|
37
|
+
return reading ? Math.max(0, reading.totalUrls - reading.indexed) : null
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Crawl errors on a Site's reading. A reading with no trend point counts 0. */
|
|
41
|
+
export function readingErrors(reading: IndexingWindowReading | null | undefined): number {
|
|
42
|
+
return reading?.point ? crawlErrorCount(reading.point) : 0
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function buildPortfolioOverview(entries: readonly IndexingPortfolioEntry[], window: IndexingReadingWindow): IndexingPortfolioOverviewModel {
|
|
46
|
+
const readings = new Map(entries.map(entry => [entry.site.id, siteIndexingReading(entry.summary, entry.trend, window)]))
|
|
47
|
+
const withReading = entries.filter(entry => readings.get(entry.site.id))
|
|
48
|
+
|
|
49
|
+
let indexed = 0
|
|
50
|
+
let total = 0
|
|
51
|
+
for (const entry of withReading) {
|
|
52
|
+
const reading = readings.get(entry.site.id)!
|
|
53
|
+
indexed += reading.indexed
|
|
54
|
+
total += reading.totalUrls
|
|
55
|
+
}
|
|
56
|
+
const notIndexedCounts = withReading.map(entry => unindexedCount(readings.get(entry.site.id))!)
|
|
57
|
+
const errorReadings = withReading.filter(entry => readings.get(entry.site.id)?.point)
|
|
58
|
+
const trend = portfolioIndexingTrend(withReading.map(entry => entry.trend), window)
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
readings,
|
|
62
|
+
indexed: withReading.length ? { indexed, total, percent: total > 0 ? (indexed / total) * 100 : 0 } : null,
|
|
63
|
+
notIndexed: notIndexedCounts.length ? notIndexedCounts.reduce((sum, count) => sum + count, 0) : null,
|
|
64
|
+
crawlErrors: errorReadings.length ? errorReadings.reduce((sum, entry) => sum + readingErrors(readings.get(entry.site.id)), 0) : null,
|
|
65
|
+
trend,
|
|
66
|
+
indexedChange: indexedRateChange(trend),
|
|
67
|
+
change7d: portfolioRateChangeOver(trend, 7),
|
|
68
|
+
stack: notIndexedStack(withReading.map(entry => ({ id: entry.site.id, label: entry.site.label, trend: entry.trend })), window),
|
|
69
|
+
sitesWithReading: withReading.length,
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A Site's share of the Portfolio not-indexed total, as display text. Null below two Sites with a reading or a zero total. */
|
|
74
|
+
export function notIndexedShare(model: IndexingPortfolioOverviewModel, siteId: string): string | null {
|
|
75
|
+
const count = unindexedCount(model.readings.get(siteId))
|
|
76
|
+
const total = model.notIndexed
|
|
77
|
+
if (count == null || !total || model.sitesWithReading < 2)
|
|
78
|
+
return null
|
|
79
|
+
const share = count / total * 100
|
|
80
|
+
return share > 0 && share < 1 ? '<1%' : `${Math.round(share)}%`
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** A Site's share of the Portfolio indexed total, in whole percent. Null without one. */
|
|
84
|
+
export function indexedShare(model: IndexingPortfolioOverviewModel, siteId: string): number | null {
|
|
85
|
+
const value = model.readings.get(siteId)?.indexed
|
|
86
|
+
if (!value || !model.indexed?.indexed)
|
|
87
|
+
return null
|
|
88
|
+
return Math.round((value / model.indexed.indexed) * 100)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** The days of a Site's trend inside the window. */
|
|
92
|
+
export function windowTrend(trend: readonly IndexingTrendReading[], window: IndexingWindowDays): IndexingTrendReading[] {
|
|
93
|
+
return trend.filter(point => inWindow(point, window))
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** One Site as the Markdown export takes it. */
|
|
97
|
+
export function portfolioMarkdownSite(entry: IndexingPortfolioEntry, model: IndexingPortfolioOverviewModel, window: IndexingWindowDays, hostname: string): IndexingMarkdownSite {
|
|
98
|
+
const reading = model.readings.get(entry.site.id) ?? null
|
|
99
|
+
const latest = reading?.point
|
|
100
|
+
return {
|
|
101
|
+
name: entry.site.label,
|
|
102
|
+
hostname,
|
|
103
|
+
hasGsc: entry.site.dataId !== null,
|
|
104
|
+
indexed: reading?.indexed ?? null,
|
|
105
|
+
totalUrls: reading?.totalUrls ?? null,
|
|
106
|
+
indexedPercent: reading?.indexedPercent ?? null,
|
|
107
|
+
change7d: reading?.change7d ?? null,
|
|
108
|
+
change28d: reading?.change28d ?? null,
|
|
109
|
+
trend: reading
|
|
110
|
+
? windowTrend(entry.trend, window).map(point => ({ date: point.date, indexedPercent: point.indexedPercent, errors: crawlErrorCount(point) }))
|
|
111
|
+
: [],
|
|
112
|
+
latestIssues: latest?.issues
|
|
113
|
+
? {
|
|
114
|
+
notFound: latest.issues.notFound ?? 0,
|
|
115
|
+
soft404: latest.issues.soft404 ?? 0,
|
|
116
|
+
serverError: latest.issues.serverError ?? 0,
|
|
117
|
+
}
|
|
118
|
+
: null,
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// The Portfolio as the indexing sections read it: one entry per Site, with the
|
|
2
|
+
// state of its indexing read. Pure. The site maps its own per-Site state onto
|
|
3
|
+
// entries once, and every Portfolio section agrees on what loading, failed,
|
|
4
|
+
// and covered mean.
|
|
5
|
+
//
|
|
6
|
+
// Moved from nuxtseo.com `layers/pro/gsc/app/composables/useIndexingGroupFetchState.ts`.
|
|
7
|
+
|
|
8
|
+
import type { IndexingPortfolioSite, IndexingSummaryReading, IndexingTrendReading } from '@gscdump/sdk/indexing'
|
|
9
|
+
import type { IndexingSite } from './source'
|
|
10
|
+
import { fillCopy } from '@nuxtseo/pro-shell/shared/copy'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The state of a Site's indexing read. `idle` has not started, which counts as
|
|
14
|
+
* pending: reads are staggered, and loading must never read as a result.
|
|
15
|
+
*/
|
|
16
|
+
export type IndexingReadState
|
|
17
|
+
= | { readonly _tag: 'idle' }
|
|
18
|
+
| { readonly _tag: 'loading' }
|
|
19
|
+
| { readonly _tag: 'failed' }
|
|
20
|
+
| { readonly _tag: 'settled' }
|
|
21
|
+
|
|
22
|
+
export interface IndexingPortfolioEntry {
|
|
23
|
+
readonly site: IndexingSite
|
|
24
|
+
readonly read: IndexingReadState
|
|
25
|
+
/** The last summary the read returned. Kept while a refresh runs. */
|
|
26
|
+
readonly summary: IndexingSummaryReading | null
|
|
27
|
+
/** Oldest first. Empty until the read returns one. */
|
|
28
|
+
readonly trend: readonly IndexingTrendReading[]
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** True when the entry has a coverage observation. A zero denominator has none yet. */
|
|
32
|
+
export function hasCoverageObservation(summary: Pick<IndexingSummaryReading, 'totalUrls'> | null | undefined): boolean {
|
|
33
|
+
return !!summary && summary.totalUrls > 0
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** A linked Site that has not failed is pending until its read settles. */
|
|
37
|
+
export function isEntryPending(entry: IndexingPortfolioEntry): boolean {
|
|
38
|
+
return entry.site.dataId !== null && (entry.read._tag === 'loading' || entry.read._tag === 'idle')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IndexingPortfolioFetchCopy {
|
|
42
|
+
readonly failedOne: string
|
|
43
|
+
readonly failedMany: string
|
|
44
|
+
readonly excludesOne: string
|
|
45
|
+
readonly excludesMany: string
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IndexingPortfolioFetchState {
|
|
49
|
+
readonly isPending: boolean
|
|
50
|
+
readonly failed: readonly IndexingPortfolioEntry[]
|
|
51
|
+
/** Null when no Site failed. */
|
|
52
|
+
readonly errorDescription: string | null
|
|
53
|
+
/** Totals sum only the Sites that loaded, so they say which Sites they leave out. Null when none failed. */
|
|
54
|
+
readonly partialTotalsNote: string | null
|
|
55
|
+
readonly hasCoverage: boolean
|
|
56
|
+
/** Entries with a coverage observation and a trend, as the stack and issue maths take them. */
|
|
57
|
+
readonly coverageSites: IndexingPortfolioSite[]
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function portfolioFetchState(entries: readonly IndexingPortfolioEntry[], copy: IndexingPortfolioFetchCopy): IndexingPortfolioFetchState {
|
|
61
|
+
const failed = entries.filter(entry => entry.read._tag === 'failed')
|
|
62
|
+
const count = failed.length
|
|
63
|
+
return {
|
|
64
|
+
isPending: entries.some(isEntryPending),
|
|
65
|
+
failed,
|
|
66
|
+
errorDescription: count === 0
|
|
67
|
+
? null
|
|
68
|
+
: count === 1
|
|
69
|
+
? fillCopy(copy.failedOne, { site: failed[0]!.site.label })
|
|
70
|
+
: fillCopy(copy.failedMany, { count }),
|
|
71
|
+
partialTotalsNote: count === 0
|
|
72
|
+
? null
|
|
73
|
+
: count === 1 ? copy.excludesOne : fillCopy(copy.excludesMany, { count }),
|
|
74
|
+
hasCoverage: entries.some(entry => hasCoverageObservation(entry.summary)),
|
|
75
|
+
coverageSites: entries.flatMap(entry => hasCoverageObservation(entry.summary) && entry.trend.length
|
|
76
|
+
? [{ id: entry.site.id, label: entry.site.label, trend: entry.trend }]
|
|
77
|
+
: []),
|
|
78
|
+
}
|
|
79
|
+
}
|
package/shared/routes.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// The indexing route map: each site maps the sections' logical routes to its
|
|
2
|
+
// own paths in app.config `proIndexing.routes`. A Site route holds the `[site]`
|
|
3
|
+
// token of the shell's route map, filled with `IndexingSite.ref`. A route the
|
|
4
|
+
// site leaves out resolves to null, and the link that needs it hides.
|
|
5
|
+
|
|
6
|
+
import { SITE_ROUTE_TOKEN } from '@nuxtseo/pro-shell/shared/routes'
|
|
7
|
+
|
|
8
|
+
/** Logical routes with no Site in the path. */
|
|
9
|
+
export const PRO_INDEXING_APP_ROUTES = [
|
|
10
|
+
'connectSearchConsole',
|
|
11
|
+
] as const
|
|
12
|
+
|
|
13
|
+
/** Logical routes inside one Site. Each template holds the `[site]` token. */
|
|
14
|
+
export const PRO_INDEXING_SITE_ROUTES = [
|
|
15
|
+
'siteIndexing',
|
|
16
|
+
'siteIndexingUrls',
|
|
17
|
+
'siteIndexingSitemaps',
|
|
18
|
+
] as const
|
|
19
|
+
|
|
20
|
+
export type ProIndexingAppRoute = typeof PRO_INDEXING_APP_ROUTES[number]
|
|
21
|
+
export type ProIndexingSiteRoute = typeof PRO_INDEXING_SITE_ROUTES[number]
|
|
22
|
+
|
|
23
|
+
/** `proIndexing.routes` in app.config. Every key is optional. */
|
|
24
|
+
export type ProIndexingRouteMap = {
|
|
25
|
+
readonly [K in ProIndexingAppRoute]?: string
|
|
26
|
+
} & {
|
|
27
|
+
readonly [K in ProIndexingSiteRoute]?: `${string}[site]${string}`
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type ProIndexingQuery = Readonly<Record<string, string | undefined>>
|
|
31
|
+
|
|
32
|
+
function withQuery(path: string, query: ProIndexingQuery | undefined): string {
|
|
33
|
+
const entries = Object.entries(query ?? {}).filter((entry): entry is [string, string] => typeof entry[1] === 'string' && entry[1].length > 0)
|
|
34
|
+
if (entries.length === 0)
|
|
35
|
+
return path
|
|
36
|
+
const hashAt = path.indexOf('#')
|
|
37
|
+
const base = hashAt === -1 ? path : path.slice(0, hashAt)
|
|
38
|
+
const hash = hashAt === -1 ? '' : path.slice(hashAt)
|
|
39
|
+
return `${base}${base.includes('?') ? '&' : '?'}${new URLSearchParams(entries).toString()}${hash}`
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** The site's path for an app route, or null when the site maps none. */
|
|
43
|
+
export function resolveIndexingAppRoute(routes: ProIndexingRouteMap, name: ProIndexingAppRoute, query?: ProIndexingQuery): string | null {
|
|
44
|
+
const template = routes[name]
|
|
45
|
+
return typeof template === 'string' && template.length > 0 ? withQuery(template, query) : null
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* The site's path for a Site route, or null when the site maps none. A template
|
|
50
|
+
* without the `[site]` token also resolves to null: it would link every Site
|
|
51
|
+
* to the same page.
|
|
52
|
+
*/
|
|
53
|
+
export function resolveIndexingSiteRoute(routes: ProIndexingRouteMap, name: ProIndexingSiteRoute, site: string, query?: ProIndexingQuery): string | null {
|
|
54
|
+
const template = routes[name]
|
|
55
|
+
if (typeof template !== 'string' || !site || !template.includes(SITE_ROUTE_TOKEN))
|
|
56
|
+
return null
|
|
57
|
+
return withQuery(template.split(SITE_ROUTE_TOKEN).join(encodeURIComponent(site)), query)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The URLs list filter an issue row links to, as `?issue=` or `?facet=`. */
|
|
61
|
+
export function indexingIssueQuery(filter: { readonly key: 'issue' | 'facet', readonly value: string }): ProIndexingQuery {
|
|
62
|
+
return { [filter.key]: filter.value }
|
|
63
|
+
}
|