@pagebridge/sanity 0.1.2 → 0.1.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"SearchPerformancePane.d.ts","sourceRoot":"","sources":["../../src/components/SearchPerformancePane.tsx"],"names":[],"mappings":"AAsBA,UAAU,0BAA0B;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,GACX,EAAE,0BAA0B,2CAgH5B"}
1
+ {"version":3,"file":"SearchPerformancePane.d.ts","sourceRoot":"","sources":["../../src/components/SearchPerformancePane.tsx"],"names":[],"mappings":"AAgDA,UAAU,0BAA0B;IAClC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,UAAU,GACX,EAAE,0BAA0B,2CAuG5B"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
3
  import { useClient } from "sanity";
4
- import { Card, Stack, Text, Badge, Flex, Box, Spinner, Tooltip } from "@sanity/ui";
5
- import { ArrowUpIcon, ArrowDownIcon, ArrowRightIcon, CheckmarkCircleIcon, CloseCircleIcon, WarningOutlineIcon } from "@sanity/icons";
4
+ import { Card, Stack, Text, Badge, Flex, Box, Spinner, Tooltip, } from "@sanity/ui";
5
+ import { ArrowUpIcon, ArrowDownIcon, ArrowRightIcon, CheckmarkCircleIcon, CloseCircleIcon, WarningOutlineIcon, BoltIcon, } from "@sanity/icons";
6
6
  export function SearchPerformancePane({ documentId, }) {
7
7
  const client = useClient({ apiVersion: "2024-01-01" });
8
8
  const [data, setData] = useState(undefined);
@@ -15,6 +15,7 @@ export function SearchPerformancePane({ documentId, }) {
15
15
  ctr,
16
16
  position,
17
17
  topQueries,
18
+ quickWinQueries,
18
19
  fetchedAt,
19
20
  indexStatus
20
21
  }`, { id: documentId });
@@ -27,6 +28,8 @@ export function SearchPerformancePane({ documentId, }) {
27
28
  positionDelta: previousSnapshot
28
29
  ? snapshot.position - previousSnapshot.position
29
30
  : 0,
31
+ topQueries: snapshot.topQueries ?? [],
32
+ quickWinQueries: snapshot.quickWinQueries ?? [],
30
33
  lastUpdated: snapshot.fetchedAt,
31
34
  indexStatus: snapshot.indexStatus,
32
35
  });
@@ -41,7 +44,58 @@ export function SearchPerformancePane({ documentId, }) {
41
44
  if (!data) {
42
45
  return (_jsx(Card, { padding: 4, tone: "caution", children: _jsx(Text, { children: "No search data available for this document." }) }));
43
46
  }
44
- return (_jsx(Card, { padding: 4, children: _jsxs(Stack, { space: 4, children: [_jsxs(Flex, { justify: "space-between", align: "center", children: [_jsx(Text, { weight: "semibold", size: 2, children: "Search Performance (Last 28 Days)" }), data.indexStatus && _jsx(IndexStatusBadge, { status: data.indexStatus })] }), _jsxs(Flex, { gap: 3, wrap: "wrap", children: [_jsx(MetricCard, { label: "Clicks", value: data.clicks.toLocaleString() }), _jsx(MetricCard, { label: "Impressions", value: data.impressions.toLocaleString() }), _jsx(MetricCard, { label: "CTR", value: `${(data.ctr * 100).toFixed(1)}%` }), _jsx(MetricCard, { label: "Avg. Position", value: data.position.toFixed(1), trend: data.positionDelta, invertTrend: true })] }), data.topQueries?.length > 0 && (_jsxs(Box, { children: [_jsx(Text, { size: 1, weight: "semibold", muted: true, style: { marginBottom: 8 }, children: "Top Queries" }), _jsx(Stack, { space: 2, children: data.topQueries.slice(0, 5).map((q, i) => (_jsxs(Flex, { justify: "space-between", align: "center", children: [_jsx(Text, { size: 1, style: { flex: 1 }, children: q.query }), _jsxs(Text, { size: 1, muted: true, children: [q.clicks, " clicks \u00B7 pos ", q.position.toFixed(1)] })] }, i))) })] })), _jsxs(Text, { size: 0, muted: true, children: ["Last updated: ", new Date(data.lastUpdated).toLocaleDateString()] })] }) }));
47
+ return (_jsx(Card, { padding: 4, children: _jsxs(Stack, { space: 4, children: [_jsxs(Flex, { justify: "space-between", align: "center", children: [_jsx(Text, { weight: "semibold", size: 2, children: "Search Performance (Last 28 Days)" }), data.indexStatus && _jsx(IndexStatusBadge, { status: data.indexStatus })] }), _jsxs(Flex, { gap: 3, wrap: "wrap", children: [_jsx(MetricCard, { label: "Clicks", value: data.clicks.toLocaleString() }), _jsx(MetricCard, { label: "Impressions", value: data.impressions.toLocaleString() }), _jsx(MetricCard, { label: "CTR", value: `${(data.ctr * 100).toFixed(1)}%` }), _jsx(MetricCard, { label: "Avg. Position", value: data.position.toFixed(1), trend: data.positionDelta, invertTrend: true })] }), data.quickWinQueries.length > 0 && (_jsx(QuickWinsSection, { queries: data.quickWinQueries })), data.topQueries.length > 0 && (_jsx(TopQueriesTable, { queries: data.topQueries })), _jsxs(Text, { size: 0, muted: true, children: ["Last updated: ", new Date(data.lastUpdated).toLocaleDateString()] })] }) }));
48
+ }
49
+ // --- Quick Wins Section ---
50
+ function QuickWinsSection({ queries }) {
51
+ return (_jsx(Card, { padding: 3, radius: 2, tone: "positive", border: true, children: _jsxs(Stack, { space: 3, children: [_jsxs(Flex, { align: "center", gap: 2, children: [_jsx(BoltIcon, {}), _jsx(Text, { size: 1, weight: "semibold", children: "Quick Wins \u2014 Page 1 Opportunities" })] }), _jsx(Text, { size: 0, muted: true, children: "These queries rank at positions 8-20 with strong impressions. Small content improvements could push them to page 1." }), _jsx(Stack, { space: 2, children: queries.map((q, i) => (_jsx(Card, { padding: 2, radius: 2, shadow: 1, children: _jsxs(Flex, { justify: "space-between", align: "center", gap: 2, children: [_jsx(Box, { style: { flex: 1, minWidth: 0 }, children: _jsx(Text, { size: 1, style: {
52
+ overflow: "hidden",
53
+ textOverflow: "ellipsis",
54
+ whiteSpace: "nowrap",
55
+ }, children: q.query }) }), _jsxs(Flex, { align: "center", gap: 2, style: { flexShrink: 0 }, children: [_jsxs(Badge, { tone: "primary", fontSize: 0, children: ["pos ", q.position.toFixed(1)] }), _jsxs(Text, { size: 0, muted: true, children: [q.impressions.toLocaleString(), " imp"] })] })] }) }, i))) })] }) }));
56
+ }
57
+ // --- Top Queries Table ---
58
+ function TopQueriesTable({ queries }) {
59
+ return (_jsxs(Box, { children: [_jsx(Text, { size: 1, weight: "semibold", muted: true, style: { marginBottom: 8 }, children: "Top Queries" }), _jsxs("table", { style: {
60
+ width: "100%",
61
+ borderCollapse: "collapse",
62
+ fontSize: "var(--font-size-1)",
63
+ }, children: [_jsx("thead", { children: _jsxs("tr", { style: {
64
+ borderBottom: "1px solid var(--card-border-color)",
65
+ }, children: [_jsx("th", { style: {
66
+ textAlign: "left",
67
+ padding: "4px 0",
68
+ fontWeight: 600,
69
+ fontSize: "var(--font-size-0)",
70
+ color: "var(--card-muted-fg-color)",
71
+ }, children: "Query" }), ["Clicks", "Impr.", "CTR", "Pos."].map((h) => (_jsx("th", { style: {
72
+ textAlign: "right",
73
+ padding: "4px 0 4px 8px",
74
+ fontWeight: 600,
75
+ fontSize: "var(--font-size-0)",
76
+ color: "var(--card-muted-fg-color)",
77
+ whiteSpace: "nowrap",
78
+ }, children: h }, h)))] }) }), _jsx("tbody", { children: queries.slice(0, 10).map((q, i) => (_jsxs("tr", { children: [_jsx("td", { style: {
79
+ padding: "6px 8px 6px 0",
80
+ maxWidth: 0,
81
+ overflow: "hidden",
82
+ textOverflow: "ellipsis",
83
+ whiteSpace: "nowrap",
84
+ }, children: q.query }), _jsx("td", { style: { textAlign: "right", padding: "6px 0 6px 8px" }, children: q.clicks.toLocaleString() }), _jsx("td", { style: {
85
+ textAlign: "right",
86
+ padding: "6px 0 6px 8px",
87
+ color: "var(--card-muted-fg-color)",
88
+ }, children: q.impressions.toLocaleString() }), _jsx("td", { style: {
89
+ textAlign: "right",
90
+ padding: "6px 0 6px 8px",
91
+ color: "var(--card-muted-fg-color)",
92
+ }, children: q.impressions > 0
93
+ ? `${((q.clicks / q.impressions) * 100).toFixed(1)}%`
94
+ : "-" }), _jsx("td", { style: { textAlign: "right", padding: "6px 0 6px 8px" }, children: _jsx(PositionText, { position: q.position }) })] }, i))) })] })] }));
95
+ }
96
+ function PositionText({ position }) {
97
+ const tone = position <= 3 ? "positive" : position <= 10 ? "caution" : "critical";
98
+ return (_jsx(Badge, { tone: tone, fontSize: 0, children: position.toFixed(1) }));
45
99
  }
46
100
  function MetricCard({ label, value, trend, invertTrend }) {
47
101
  const TrendIcon = trend === undefined || trend === 0
@@ -76,5 +130,5 @@ function IndexStatusBadge({ status }) {
76
130
  };
77
131
  const { tone, icon: Icon, label } = config[status.verdict];
78
132
  const tooltipContent = status.coverageState || label;
79
- return (_jsx(Tooltip, { content: _jsx(Box, { padding: 2, children: _jsxs(Stack, { space: 2, children: [_jsx(Text, { size: 1, children: tooltipContent }), status.lastCrawlTime && (_jsxs(Text, { size: 0, muted: true, children: ["Last crawled: ", new Date(status.lastCrawlTime).toLocaleDateString()] }))] }) }), placement: "top", children: _jsx(Badge, { tone: tone, fontSize: 1, style: { cursor: "help" }, children: _jsxs(Flex, { align: "center", gap: 1, children: [_jsx(Icon, {}), label] }) }) }));
133
+ return (_jsx(Tooltip, { content: _jsx(Box, { padding: 2, children: _jsxs(Stack, { space: 2, children: [_jsx(Text, { size: 1, children: tooltipContent }), status.lastCrawlTime && (_jsxs(Text, { size: 0, muted: true, children: ["Last crawled:", " ", new Date(status.lastCrawlTime).toLocaleDateString()] }))] }) }), placement: "top", children: _jsx(Badge, { tone: tone, fontSize: 1, style: { cursor: "help" }, children: _jsxs(Flex, { align: "center", gap: 1, children: [_jsx(Icon, {}), label] }) }) }));
80
134
  }
@@ -1 +1 @@
1
- {"version":3,"file":"gscSnapshot.d.ts","sourceRoot":"","sources":["../../src/schemas/gscSnapshot.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,iBAAiB,GAAI,UAAS,kBAAuB;;;;;;;;CAyHjE,CAAC;AAGF,eAAO,MAAM,WAAW;;;;;;;;CAAsB,CAAC"}
1
+ {"version":3,"file":"gscSnapshot.d.ts","sourceRoot":"","sources":["../../src/schemas/gscSnapshot.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,eAAO,MAAM,iBAAiB,GAAI,UAAS,kBAAuB;;;;;;;;CA4IjE,CAAC;AAGF,eAAO,MAAM,WAAW;;;;;;;;CAAsB,CAAC"}
@@ -73,6 +73,24 @@ export const createGscSnapshot = (options = {}) => {
73
73
  },
74
74
  ],
75
75
  }),
76
+ defineField({
77
+ name: "quickWinQueries",
78
+ title: "Quick Win Queries",
79
+ type: "array",
80
+ description: "Queries at position 8-20 with high impressions — page 1 opportunities",
81
+ of: [
82
+ {
83
+ type: "object",
84
+ fields: [
85
+ defineField({ name: "query", type: "string" }),
86
+ defineField({ name: "clicks", type: "number" }),
87
+ defineField({ name: "impressions", type: "number" }),
88
+ defineField({ name: "ctr", type: "number" }),
89
+ defineField({ name: "position", type: "number" }),
90
+ ],
91
+ },
92
+ ],
93
+ }),
76
94
  defineField({
77
95
  name: "fetchedAt",
78
96
  title: "Fetched At",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pagebridge/sanity",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Sanity Studio plugin for PageBridge — performance pane, decay alerts, and refresh queue powered by Google Search Console data",
5
5
  "license": "MIT",
6
6
  "private": false,