@nuxtseo/pro-search 0.1.10 → 0.1.12

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.
@@ -6,13 +6,14 @@ import { computed, ref, watch } from 'vue'
6
6
  import { UiAlert, UiDataTableSection, UiEmptyState, UiIcon, UiLineChart, UiMetricStat, UiMetricToggle, UiRelativeTime, UiSectionHeader, UiTableMetricCell, UiTablePathCell, UiTableShell, UiTableTd, UiTableTh, UiTogglePill } from '#components'
7
7
  import { BING_PERFORMANCE_PAGE_SIZE, bingTrafficTotals, formatBingCtr, formatBingNumber, formatBingReportingDay } from '../../shared/bing-performance'
8
8
 
9
- const { data, startDate, endDate, entities, pending, error } = defineProps<{
10
- data: Extract<BingDataV1, { dataset: 'traffic' }>
9
+ const { data, startDate, endDate, entities, pending, error, view } = defineProps<{
10
+ data: Extract<BingDataV1, { dataset: 'traffic' }> | null
11
11
  startDate: string
12
12
  endDate: string
13
13
  entities: BingDataV1 | null
14
14
  pending: boolean
15
15
  error: boolean
16
+ view?: 'overview' | 'queries' | 'pages'
16
17
  }>()
17
18
  const emit = defineEmits<{ retry: [] }>()
18
19
  const entityKind = defineModel<BingEntityKind>('entityKind', { required: true })
@@ -27,9 +28,17 @@ const metricOptions = [
27
28
  const chartSeries = computed(() => metricOptions
28
29
  .filter(option => metrics.value.includes(option.key))
29
30
  .map(option => ({ key: option.key, label: option.label, color: gscMetricColors[option.key].color })))
30
- const totals = computed(() => bingTrafficTotals(data.rows))
31
- const lastCollection = computed(() => data.sync._tag === 'missing' ? null : data.sync.observedAt)
32
- const unavailable = computed(() => data.sync._tag === 'unavailable' || entities?.sync._tag === 'unavailable')
31
+ const totals = computed(() => bingTrafficTotals(data?.rows ?? []))
32
+ const lastCollection = computed(() => {
33
+ const sync = (view === 'pages' || view === 'queries' ? entities : data)?.sync
34
+ return sync && sync._tag !== 'missing' ? sync.observedAt : null
35
+ })
36
+ const unavailable = computed(() => data?.sync._tag === 'unavailable' || entities?.sync._tag === 'unavailable')
37
+ const entityTitle = computed(() => {
38
+ if (entityKind.value === 'pages')
39
+ return 'Top Pages'
40
+ return view === 'queries' ? 'Top Queries' : 'Top Keywords'
41
+ })
33
42
 
34
43
  interface EntityRow extends Record<string, unknown> {
35
44
  key: string
@@ -76,110 +85,117 @@ function rowCtr(row: EntityRow): string {
76
85
  description="The last successful collection stays visible while the next daily sync retries."
77
86
  />
78
87
 
79
- <div role="group" aria-label="Bing Search Performance filters" class="flex min-w-0 flex-col gap-2">
80
- <span class="inline-flex items-center gap-1.5 text-xs text-muted">
81
- <UiIcon name="calendar" class="size-3.5 shrink-0 text-dimmed" aria-hidden="true" />
82
- {{ startDate }} to {{ endDate }}
83
- </span>
84
- <UiMetricToggle v-if="data.rows.length" v-model="metrics" :options="[...metricOptions]" chip :colors="gscMetricColors" />
85
- </div>
88
+ <template v-if="data && (!view || view === 'overview')">
89
+ <div role="group" aria-label="Bing Search Performance filters" class="flex min-w-0 flex-col gap-2">
90
+ <span class="inline-flex items-center gap-1.5 text-xs text-muted">
91
+ <UiIcon name="calendar" class="size-3.5 shrink-0 text-dimmed" aria-hidden="true" />
92
+ {{ startDate }} to {{ endDate }}
93
+ </span>
94
+ <UiMetricToggle v-if="data.rows.length" v-model="metrics" :options="[...metricOptions]" chip :colors="gscMetricColors" />
95
+ </div>
86
96
 
87
- <div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
88
- <UiSectionHeader
89
- title="Bing Search Performance"
90
- tooltip="Bing reports total traffic across its search surfaces. It does not provide a separate Chat source."
91
- />
92
- <div v-if="lastCollection" class="text-xs text-muted">
93
- Collected <UiRelativeTime :date="lastCollection" />
97
+ <div class="flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between">
98
+ <UiSectionHeader
99
+ title="Bing Search Performance"
100
+ tooltip="Bing reports total traffic across its search surfaces. It does not provide a separate Chat source."
101
+ />
102
+ <div v-if="lastCollection" class="text-xs text-muted">
103
+ Collected <UiRelativeTime :date="lastCollection" />
104
+ </div>
94
105
  </div>
95
- </div>
96
106
 
97
- <UiEmptyState v-if="!data.rows.length" icon="search" title="No Bing traffic in this date range" description="Pages and Keywords can still have data below." />
107
+ <UiEmptyState v-if="!data.rows.length && !unavailable" icon="search" title="No Bing traffic in this date range" :description="view ? undefined : 'Pages and Keywords can still have data below.'" />
98
108
 
99
- <div v-if="data.rows.length" class="flex flex-wrap gap-x-6 gap-y-3 rounded-xl border border-default bg-elevated/30 px-4 py-3">
100
- <UiMetricStat :value="formatBingNumber(totals.clicks)" label="clicks" />
101
- <UiMetricStat :value="formatBingNumber(totals.impressions)" label="impressions" />
102
- <UiMetricStat :value="formatBingCtr(totals.ctr)" label="CTR" />
103
- </div>
109
+ <div v-if="data.rows.length" class="flex flex-wrap gap-x-6 gap-y-3 rounded-xl border border-default bg-elevated/30 px-4 py-3">
110
+ <UiMetricStat :value="formatBingNumber(totals.clicks)" label="clicks" />
111
+ <UiMetricStat :value="formatBingNumber(totals.impressions)" label="impressions" />
112
+ <UiMetricStat :value="formatBingCtr(totals.ctr)" label="CTR" />
113
+ </div>
104
114
 
105
- <div v-if="data.rows.length" class="rounded-xl border border-default bg-default p-4">
106
- <h3 class="mb-3 text-sm font-strong text-highlighted">
107
- Traffic over time
108
- </h3>
109
- <UiLineChart
110
- :data="data.rows"
111
- x-key="date"
112
- :series="chartSeries"
113
- :height="220"
114
- :x-format="value => formatBingReportingDay(String(value))"
115
- :y-format="value => formatBingNumber(value)"
116
- />
117
- </div>
115
+ <div v-if="data.rows.length" class="rounded-xl border border-default bg-default p-4">
116
+ <h3 class="mb-3 text-sm font-strong text-highlighted">
117
+ Traffic over time
118
+ </h3>
119
+ <UiLineChart
120
+ :data="data.rows"
121
+ x-key="date"
122
+ :series="chartSeries"
123
+ :height="220"
124
+ :x-format="value => formatBingReportingDay(String(value))"
125
+ :y-format="value => formatBingNumber(value)"
126
+ />
127
+ </div>
128
+ </template>
118
129
 
119
- <div class="flex items-center justify-between gap-3">
120
- <UiSectionHeader
121
- :title="entityKind === 'pages' ? 'Top Pages' : 'Top Keywords'"
122
- tooltip="Bing updates its top Pages and Keywords data weekly."
123
- />
124
- <UiTogglePill v-model="entityKind" :options="entityOptions" label="Bing breakdown" />
125
- </div>
130
+ <template v-if="view !== 'overview'">
131
+ <div class="flex items-center justify-between gap-3">
132
+ <UiSectionHeader
133
+ :title="entityTitle"
134
+ tooltip="Bing updates its top Pages and Keywords data weekly."
135
+ />
136
+ <UiTogglePill v-if="!view" v-model="entityKind" :options="entityOptions" label="Bing breakdown" />
137
+ <div v-else-if="lastCollection" class="text-xs text-muted">
138
+ Collected <UiRelativeTime :date="lastCollection" />
139
+ </div>
140
+ </div>
126
141
 
127
- <UiDataTableSection
128
- v-model:page="page"
129
- :rows="visibleRows"
130
- :total="totalRows"
131
- :pending="pending"
132
- :error="error ? 'Bing data could not be loaded. Retry the request.' : undefined"
133
- :searchable="false"
134
- :columns="[]"
135
- :page-size="BING_PERFORMANCE_PAGE_SIZE"
136
- item-label="rows"
137
- :label="entityKind === 'pages' ? 'Top Bing Pages' : 'Top Bing Keywords'"
138
- @retry="emit('retry')"
139
- >
140
- <template #body>
141
- <UiTableShell bordered row-hover size="xs" :label="entityKind === 'pages' ? 'Top Bing Pages' : 'Top Bing Keywords'">
142
- <template #head>
143
- <UiTableTh>
144
- {{ entityKind === 'pages' ? 'Page' : 'Keyword' }}
145
- </UiTableTh>
146
- <UiTableTh>Date</UiTableTh>
147
- <UiTableTh numeric>
148
- Clicks
149
- </UiTableTh>
150
- <UiTableTh numeric>
151
- Impressions
152
- </UiTableTh>
153
- <UiTableTh numeric visible-from="md">
154
- CTR
155
- </UiTableTh>
156
- <UiTableTh numeric visible-from="lg">
157
- Avg position
158
- </UiTableTh>
159
- </template>
160
- <tr v-for="row in visibleRows" :key="row.key">
161
- <UiTableTd row-header class="max-w-0 w-full">
162
- <UiTablePathCell v-if="row.url" :url="row.url" />
163
- <span v-else class="block truncate font-sans text-xs text-default" :title="row.label">{{ row.label }}</span>
164
- </UiTableTd>
165
- <UiTableTd class="whitespace-nowrap">
166
- {{ row.date }}
167
- </UiTableTd>
168
- <UiTableTd numeric>
169
- <UiTableMetricCell :value="row.clicks" :display="formatBingNumber(row.clicks)" />
170
- </UiTableTd>
171
- <UiTableTd numeric>
172
- <UiTableMetricCell :value="row.impressions" :display="formatBingNumber(row.impressions)" muted />
173
- </UiTableTd>
174
- <UiTableTd numeric visible-from="md">
175
- <UiTableMetricCell :value="row.impressions ? row.clicks / row.impressions : 0" :display="rowCtr(row)" muted />
176
- </UiTableTd>
177
- <UiTableTd numeric visible-from="lg">
178
- <UiTableMetricCell :value="row.averagePosition" :display="row.averagePosition == null ? null : row.averagePosition.toFixed(1)" muted />
179
- </UiTableTd>
180
- </tr>
181
- </UiTableShell>
182
- </template>
183
- </UiDataTableSection>
142
+ <UiDataTableSection
143
+ v-model:page="page"
144
+ :rows="visibleRows"
145
+ :total="totalRows"
146
+ :pending="pending"
147
+ :error="error ? 'Bing data could not be loaded. Retry the request.' : undefined"
148
+ :searchable="false"
149
+ :columns="[]"
150
+ :page-size="BING_PERFORMANCE_PAGE_SIZE"
151
+ item-label="rows"
152
+ :label="entityTitle"
153
+ @retry="emit('retry')"
154
+ >
155
+ <template #body>
156
+ <UiTableShell bordered row-hover size="xs" :label="entityTitle">
157
+ <template #head>
158
+ <UiTableTh>
159
+ {{ entityKind === 'pages' ? 'Page' : view === 'queries' ? 'Query' : 'Keyword' }}
160
+ </UiTableTh>
161
+ <UiTableTh>Date</UiTableTh>
162
+ <UiTableTh numeric>
163
+ Clicks
164
+ </UiTableTh>
165
+ <UiTableTh numeric>
166
+ Impressions
167
+ </UiTableTh>
168
+ <UiTableTh numeric visible-from="md">
169
+ CTR
170
+ </UiTableTh>
171
+ <UiTableTh numeric visible-from="lg">
172
+ Avg position
173
+ </UiTableTh>
174
+ </template>
175
+ <tr v-for="row in visibleRows" :key="row.key">
176
+ <UiTableTd row-header class="max-w-0 w-full">
177
+ <UiTablePathCell v-if="row.url" :url="row.url" />
178
+ <span v-else class="block truncate font-sans text-xs text-default" :title="row.label">{{ row.label }}</span>
179
+ </UiTableTd>
180
+ <UiTableTd class="whitespace-nowrap">
181
+ {{ row.date }}
182
+ </UiTableTd>
183
+ <UiTableTd numeric>
184
+ <UiTableMetricCell :value="row.clicks" :display="formatBingNumber(row.clicks)" />
185
+ </UiTableTd>
186
+ <UiTableTd numeric>
187
+ <UiTableMetricCell :value="row.impressions" :display="formatBingNumber(row.impressions)" muted />
188
+ </UiTableTd>
189
+ <UiTableTd numeric visible-from="md">
190
+ <UiTableMetricCell :value="row.impressions ? row.clicks / row.impressions : 0" :display="rowCtr(row)" muted />
191
+ </UiTableTd>
192
+ <UiTableTd numeric visible-from="lg">
193
+ <UiTableMetricCell :value="row.averagePosition" :display="row.averagePosition == null ? null : row.averagePosition.toFixed(1)" muted />
194
+ </UiTableTd>
195
+ </tr>
196
+ </UiTableShell>
197
+ </template>
198
+ </UiDataTableSection>
199
+ </template>
184
200
  </div>
185
201
  </template>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxtseo/pro-search",
3
3
  "type": "module",
4
- "version": "0.1.10",
4
+ "version": "0.1.12",
5
5
  "description": "Shared Search Console and Webmaster Tools views for Nuxt dashboards.",
6
6
  "license": "MIT",
7
7
  "exports": {
@@ -20,7 +20,7 @@
20
20
  "peerDependencies": {
21
21
  "@gscdump/contracts": "^7.16.0",
22
22
  "@gscdump/sdk": "^7.16.0",
23
- "@nuxtseo/design-system": "^0.1.10",
23
+ "@nuxtseo/design-system": "^0.1.12",
24
24
  "@vueuse/core": "^14.0.0 || ^15.0.0",
25
25
  "nuxt": "^4.6.0",
26
26
  "vue": "^3.5.0"
@@ -33,9 +33,9 @@
33
33
  "@unovis/vue": "^1.6.7"
34
34
  },
35
35
  "devDependencies": {
36
- "@gscdump/contracts": "7.17.0",
37
- "@gscdump/sdk": "7.17.0",
38
- "@nuxtseo/design-system": "0.1.10",
36
+ "@gscdump/contracts": "7.18.0",
37
+ "@gscdump/sdk": "7.18.0",
38
+ "@nuxtseo/design-system": "0.1.12",
39
39
  "@vueuse/core": "^14.4.0",
40
40
  "nuxt": "4.6.1",
41
41
  "site-typecheck": "0.0.0",