Skip to content

Commit 5719b8b

Browse files
dimaMachinasaihaj
andauthored
[website] make version switch show Docs by default (#1885)
* [website] make version switch show `Docs` by default * should be Docs again, when you navigate to homepage after docs * Update website/src/pages/_meta.json Co-authored-by: Saihajpreet Singh <[email protected]> Co-authored-by: Saihajpreet Singh <[email protected]>
1 parent 4539d4e commit 5719b8b

File tree

5 files changed

+84
-60
lines changed

5 files changed

+84
-60
lines changed

patches/nextra-theme-docs+2.0.0-beta.29.patch

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
diff --git a/node_modules/nextra-theme-docs/dist/index.js b/node_modules/nextra-theme-docs/dist/index.js
2-
index 55d4d18..3153398 100644
2+
index 55d4d18..b637a04 100644
33
--- a/node_modules/nextra-theme-docs/dist/index.js
44
+++ b/node_modules/nextra-theme-docs/dist/index.js
55
@@ -51,8 +51,8 @@ var __async = (__this, __arguments, generator) => {
@@ -8,7 +8,7 @@ index 55d4d18..3153398 100644
88
// src/index.tsx
99
-import React41, { useEffect as useEffect8, useMemo as useMemo5, useRef as useRef7 } from "react";
1010
-import { useRouter as useRouter9 } from "next/router";
11-
+import React44, { useEffect as useEffect8, useMemo as useMemo5, useRef as useRef7 } from "react";
11+
+import React44, { useEffect as useEffect9, useMemo as useMemo5, useRef as useRef7 } from "react";
1212
+import { useRouter as useRouter10 } from "next/router";
1313
import "focus-visible";
1414
import scrollIntoView3 from "scroll-into-view-if-needed";
@@ -608,18 +608,18 @@ index 55d4d18..3153398 100644
608608
import { Menu, Transition as Transition3 } from "@headlessui/react";
609609
+
610610
+// src/components/version-switch.tsx
611-
+import React30, { useState as useState6 } from "react";
611+
+import React30, { useEffect as useEffect4, useState as useState6 } from "react";
612612
+import { useRouter as useRouter4 } from "next/router";
613613
+function VersionSwitch({
614614
+ options
615615
+}) {
616616
+ const router = useRouter4();
617-
+ const [route, setRoute] = useState6(
618-
+ () => {
619-
+ var _a;
620-
+ return ((_a = options.find((opt) => router.route.startsWith(opt.route))) == null ? void 0 : _a.route) || "";
621-
+ }
622-
+ );
617+
+ const [route, setRoute] = useState6("");
618+
+ useEffect4(() => {
619+
+ var _a;
620+
+ const newRoute = ((_a = options.find((opt) => router.route.startsWith(opt.route))) == null ? void 0 : _a.route) || "";
621+
+ setRoute(newRoute);
622+
+ }, [router.route]);
623623
+ const selected = route ? options.find((opt) => opt.route === route) : options[0];
624624
+ return /* @__PURE__ */ React30.createElement(Select, {
625625
+ className: "flex gap-1 items-center",
@@ -629,7 +629,7 @@ index 55d4d18..3153398 100644
629629
+ },
630630
+ selected: {
631631
+ key: route,
632-
+ name: /* @__PURE__ */ React30.createElement(React30.Fragment, null, selected == null ? void 0 : selected.title, /* @__PURE__ */ React30.createElement(ArrowRightIcon, {
632+
+ name: /* @__PURE__ */ React30.createElement(React30.Fragment, null, route ? selected == null ? void 0 : selected.title : "Docs", /* @__PURE__ */ React30.createElement(ArrowRightIcon, {
633633
+ className: "shrink-0 h-3.5 w-3.5",
634634
+ pathClassName: "[[aria-expanded='true']>svg>&]:rotate-[270deg] origin-center transition-transform rotate-90"
635635
+ }))
@@ -841,18 +841,19 @@ index 55d4d18..3153398 100644
841841
href: getGitIssueUrl({
842842
repository: config.docsRepositoryBase,
843843
title: `Got server-side error in \`${mounted ? asPath : ""}\` url. Please fix!`,
844-
@@ -1733,8 +1921,8 @@ function ServerSideErrorPage() {
844+
@@ -1733,31 +1921,46 @@ function ServerSideErrorPage() {
845845
}
846846

847847
// src/components/sidebar.tsx
848848
-import React34, {
849849
- useState as useState6,
850+
- useEffect as useEffect4,
850851
+import React35, {
851852
+ useState as useState7,
852-
useEffect as useEffect4,
853+
+ useEffect as useEffect5,
853854
useMemo as useMemo2,
854855
memo as memo2,
855-
@@ -1742,22 +1930,37 @@ import React34, {
856+
useRef as useRef4
856857
} from "react";
857858
import cn13 from "clsx";
858859
import Slugger from "github-slugger";
@@ -896,16 +897,17 @@ index 55d4d18..3153398 100644
896897
const routeOriginal = getFSRoute(asPath, locale);
897898
const [route] = routeOriginal.split("#");
898899
const active = [route, route + "/"].includes(item.route + "/");
899-
@@ -1765,7 +1968,7 @@ function FolderImpl({
900+
@@ -1765,15 +1968,17 @@ function FolderImpl({
900901
const { setMenu } = useMenu();
901902
const config = useConfig();
902903
const open = TreeState[item.route] !== void 0 ? TreeState[item.route] : active || activeRouteInside || !config.sidebar.defaultMenuCollapsed;
903904
- const rerender = useState6({})[1];
905+
- useEffect4(() => {
904906
+ const rerender = useState7({})[1];
905-
useEffect4(() => {
907+
+ useEffect5(() => {
906908
if (activeRouteInside) {
907909
TreeState[item.route] = true;
908-
@@ -1773,7 +1976,9 @@ function FolderImpl({
910+
}
909911
}, [activeRouteInside]);
910912
if (item.type === "menu") {
911913
const menu = item;
@@ -1061,7 +1063,7 @@ index 55d4d18..3153398 100644
10611063
}
10621064
var emptyHeading = [];
10631065
function Sidebar({
1064-
@@ -1903,7 +2126,10 @@ function Sidebar({
1066+
@@ -1903,17 +2126,20 @@ function Sidebar({
10651067
}) {
10661068
const config = useConfig();
10671069
const { menu, setMenu } = useMenu();
@@ -1072,7 +1074,19 @@ index 55d4d18..3153398 100644
10721074
+ );
10731075
const sidebarRef = useRef4(null);
10741076
const containerRef = useRef4(null);
1075-
useEffect4(() => {
1077+
- useEffect4(() => {
1078+
+ useEffect5(() => {
1079+
if (menu) {
1080+
document.body.classList.add("overflow-hidden", "md:overflow-auto");
1081+
} else {
1082+
document.body.classList.remove("overflow-hidden", "md:overflow-auto");
1083+
}
1084+
}, [menu]);
1085+
- useEffect4(() => {
1086+
+ useEffect5(() => {
1087+
var _a;
1088+
const activeElement = (_a = sidebarRef.current) == null ? void 0 : _a.querySelector("li.active");
1089+
if (activeElement && (window.innerWidth > 767 || menu)) {
10761090
@@ -1933,41 +2159,63 @@ function Sidebar({
10771091
}
10781092
}, [menu]);
@@ -1200,11 +1214,11 @@ index 55d4d18..3153398 100644
12001214

12011215
// src/components/toc.tsx
12021216
-import React36, { useEffect as useEffect5, useRef as useRef5, useMemo as useMemo3 } from "react";
1203-
+import React37, { useEffect as useEffect5, useRef as useRef5, useMemo as useMemo3 } from "react";
1217+
+import React37, { useEffect as useEffect6, useRef as useRef5, useMemo as useMemo3 } from "react";
12041218
import cn15 from "clsx";
12051219
import Slugger2 from "github-slugger";
12061220
import scrollIntoView2 from "scroll-into-view-if-needed";
1207-
@@ -2027,17 +2281,24 @@ function TOC({ headings, filePath }) {
1221+
@@ -2027,18 +2281,25 @@ function TOC({ headings, filePath }) {
12081222
const activeAnchor = useActiveAnchor();
12091223
const config = useConfig();
12101224
const tocRef = useRef5(null);
@@ -1230,15 +1244,17 @@ index 55d4d18..3153398 100644
12301244
const hasHeadings = items.length > 0;
12311245
- const hasMetaInfo = Boolean(config.feedback.content || config.editLink.component || config.toc.extraContent);
12321246
- const activeSlug = (_a = Object.entries(activeAnchor).find(([, { isActive }]) => isActive)) == null ? void 0 : _a[0];
1247+
- useEffect5(() => {
12331248
+ const hasMetaInfo = Boolean(
12341249
+ config.feedback.content || config.editLink.component || config.toc.extraContent
12351250
+ );
12361251
+ const activeSlug = (_a = Object.entries(activeAnchor).find(
12371252
+ ([, { isActive }]) => isActive
12381253
+ )) == null ? void 0 : _a[0];
1239-
useEffect5(() => {
1254+
+ useEffect6(() => {
12401255
var _a2;
12411256
if (!activeSlug)
1257+
return;
12421258
@@ -2053,30 +2314,44 @@ function TOC({ headings, filePath }) {
12431259
});
12441260
}
@@ -1459,8 +1475,9 @@ index 55d4d18..3153398 100644
14591475

14601476
// src/mdx-components.tsx
14611477
-import React40, {
1478+
- useEffect as useEffect7,
14621479
+import React41, {
1463-
useEffect as useEffect7,
1480+
+ useEffect as useEffect8,
14641481
useRef as useRef6,
14651482
- useState as useState9,
14661483
+ useState as useState10,
@@ -1475,8 +1492,9 @@ index 55d4d18..3153398 100644
14751492
+import React40 from "react";
14761493
import React210, {
14771494
useCallback as useCallback4,
1478-
useEffect as useEffect6,
1495+
- useEffect as useEffect6,
14791496
- useState as useState8
1497+
+ useEffect as useEffect7,
14801498
+ useState as useState9
14811499
} from "react";
14821500
import React310 from "react";
@@ -1490,15 +1508,17 @@ index 55d4d18..3153398 100644
14901508
className: [
14911509
"nextra-button transition-colors",
14921510
"bg-primary-700/5 border border-black/5 text-gray-600 hover:text-gray-900 rounded-md p-2",
1493-
@@ -2362,7 +2642,7 @@ var CopyToClipboard = (_a) => {
1511+
@@ -2362,8 +2642,8 @@ var CopyToClipboard = (_a) => {
14941512
} = _b, props = __objRest2(_b, [
14951513
"value"
14961514
]);
14971515
- const [isCopied, setCopied] = useState8(false);
1516+
- useEffect6(() => {
14981517
+ const [isCopied, setCopied] = useState9(false);
1499-
useEffect6(() => {
1518+
+ useEffect7(() => {
15001519
if (!isCopied)
15011520
return;
1521+
const timerId = setTimeout(() => {
15021522
@@ -2484,43 +2764,46 @@ var observer;
15031523
var setActiveAnchor;
15041524
var slugs = /* @__PURE__ */ new WeakMap();
@@ -1581,6 +1601,15 @@ index 55d4d18..3153398 100644
15811601
}
15821602
var createHeaderLink = (Tag, context) => function HeaderLink(_a) {
15831603
var _b = _a, {
1604+
@@ -2532,7 +2815,7 @@ var createHeaderLink = (Tag, context) => function HeaderLink(_a) {
1605+
]);
1606+
setActiveAnchor != null ? setActiveAnchor : setActiveAnchor = useSetActiveAnchor();
1607+
const obRef = useRef6(null);
1608+
- useEffect7(() => {
1609+
+ useEffect8(() => {
1610+
const heading = obRef.current;
1611+
if (!heading)
1612+
return;
15841613
@@ -2548,19 +2831,22 @@ var createHeaderLink = (Tag, context) => function HeaderLink(_a) {
15851614
});
15861615
};
@@ -1614,18 +1643,20 @@ index 55d4d18..3153398 100644
16141643
href: `#${id}`
16151644
}, children));
16161645
};
1617-
@@ -2594,9 +2880,9 @@ var Details = (_a) => {
1646+
@@ -2594,10 +2880,10 @@ var Details = (_a) => {
16181647
"children",
16191648
"open"
16201649
]);
16211650
- const [openState, setOpen] = useState9(!!open);
16221651
+ const [openState, setOpen] = useState10(!!open);
16231652
const [summary, restChildren] = findSummary(children);
16241653
- const [delayedOpenState, setDelayedOpenState] = useState9(openState);
1654+
- useEffect7(() => {
16251655
+ const [delayedOpenState, setDelayedOpenState] = useState10(openState);
1626-
useEffect7(() => {
1656+
+ useEffect8(() => {
16271657
if (openState) {
16281658
setDelayedOpenState(true);
1659+
} else {
16291660
@@ -2605,20 +2891,24 @@ var Details = (_a) => {
16301661
return () => clearTimeout(timeout);
16311662
}
@@ -1724,6 +1755,15 @@ index 55d4d18..3153398 100644
17241755
return useMemo5(() => {
17251756
const fsPath = getFSRoute(route, locale);
17261757
return normalizePages({
1758+
@@ -2719,7 +3012,7 @@ var Body = ({
1759+
}) => {
1760+
const mainElement = useRef7(null);
1761+
const config = useConfig();
1762+
- useEffect8(() => {
1763+
+ useEffect9(() => {
1764+
if (mainElement.current) {
1765+
resizeObserver.observe(mainElement.current);
1766+
}
17271767
@@ -2728,25 +3021,28 @@ var Body = ({
17281768
};
17291769
}, []);

website/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"check": "exit 0"
1414
},
1515
"devDependencies": {
16-
"@next/bundle-analyzer": "^12.2.5",
1716
"@theguild/algolia": "1.0.1",
1817
"@theguild/tailwind-config": "0.1.1",
1918
"@types/node": "18.7.23",

website/src/pages/_meta.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
"index": {
33
"title": "Home",
44
"type": "page",
5+
"hidden": true,
56
"theme": {
67
"layout": "raw"
78
}
89
},
9-
"docs": {
10-
"title": "v2",
10+
"v3": {
11+
"title": "v3 (beta)",
1112
"type": "page",
1213
"versioned": true
1314
},
14-
"v3": {
15-
"title": "v3",
15+
"docs": {
16+
"title": "v2",
1617
"type": "page",
1718
"versioned": true
1819
},

website/src/pages/v3/integrations/integration-with-cloudflare-workers.mdx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,18 @@ You will want to use the package `graphql-yoga` which has an agnostic HTTP handl
1010

1111
> Watch [Episode #48 of `graphql.wtf`](https://graphql.wtf/episodes/48-graphql-yoga-cloudflare-workers-kv) for a quick introduction to using GraphQL Yoga with Cloudflare Workers, and KV:
1212
13-
<br />
14-
1513
<iframe
16-
width="100%"
17-
height="400"
1814
src="https://www.youtube.com/embed/xibiwSXMLsc"
1915
title="Using GraphQL Yoga with Cloudflare Workers, and KV"
20-
frameBorder="0"
21-
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
22-
allowFullScreen
23-
></iframe>
16+
/>
2417

2518
## Installation
2619

2720
<PackageCmd packages={['graphql', 'graphql-yoga@three']} />
2821

2922
## Example with regular `fetch` event listener
3023

31-
`listener.mjs`
32-
33-
```ts
24+
```ts filename="listener.mjs"
3425
import { createYoga } from 'graphql-yoga'
3526

3627
const yoga = createYoga()
@@ -42,9 +33,7 @@ self.addEventListener('fetch', yoga)
4233
4334
## Example with Modules Approach
4435

45-
`modules.mjs`
46-
47-
```ts
36+
```ts filename="modules.mjs"
4837
import { createYoga } from 'graphql-yoga'
4938

5039
export default createYoga()

yarn.lock

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,7 +2337,7 @@
23372337
"@envelop/types" "2.4.0"
23382338
tslib "2.4.0"
23392339

2340-
"@envelop/disable-introspection@3.6.0", "@envelop/disable-introspection@^3.5.0":
2340+
"@envelop/disable-introspection@^3.5.0":
23412341
version "3.6.0"
23422342
resolved "https://registry.yarnpkg.com/@envelop/disable-introspection/-/disable-introspection-3.6.0.tgz#04b033389a83b9831442caabcbae30bde89857b9"
23432343
integrity sha512-Zf505LqWo2efM0EtTBvXyYPynSTSL2+Ps0X+dCH33vQ3wF6gxMui9g1pGa4MDcGjaXWG67qZcT4eojpGlmmavA==
@@ -4195,7 +4195,7 @@
41954195
unixify "^1.0.0"
41964196
yargs "^17.0.0"
41974197

4198-
"@next/bundle-analyzer@^12.2.5", "@next/bundle-analyzer@^12.3.1":
4198+
"@next/bundle-analyzer@^12.3.1":
41994199
version "12.3.1"
42004200
resolved "https://registry.yarnpkg.com/@next/bundle-analyzer/-/bundle-analyzer-12.3.1.tgz#df168652c43ed0dc3e91a5108e34cdcc8fc7f05a"
42014201
integrity sha512-2f/eei0YqZZBMTs4g1+HbgHyAFH5MbI/w9wLXmE8ly9SFze2D40sRH46JcC//EFVM/TIynVBh5sxn9CVO/vtxg==
@@ -5683,11 +5683,6 @@
56835683
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.46.tgz#0fb6bfbbeabd7a30880504993369c4bf1deab1fe"
56845684
integrity sha512-laIjwTQaD+5DukBZaygQ79K1Z0jb1bPEMRrkXSLjtCcZm+abyp5YbrqpSLzD42FwWW6gK/aS4NYpJ804nG2brg==
56855685

5686-
5687-
version "1.1.9"
5688-
resolved "https://registry.yarnpkg.com/@types/eventsource/-/eventsource-1.1.9.tgz#ec35903741773c12b78a1859c82d2778b5eafcf9"
5689-
integrity sha512-F3K4oyM12o8W9jxuJmW+1sc8kdw0Hj0t+26urwkcolPJTgkfppEfIdftdcXmUU2QPBIwcrYO6diqgIqgCDf1FA==
5690-
56915686
"@types/express-serve-static-core@^4.17.18":
56925687
version "4.17.28"
56935688
resolved "https://registry.yarnpkg.com/@types/express-serve-static-core/-/express-serve-static-core-4.17.28.tgz#c47def9f34ec81dc6328d0b1b5303d1ec98d86b8"
@@ -6155,13 +6150,6 @@
61556150
resolved "https://registry.yarnpkg.com/@types/yargs-parser/-/yargs-parser-21.0.0.tgz#0c60e537fa790f5f9472ed2776c2b71ec117351b"
61566151
integrity sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==
61576152

6158-
"@types/[email protected]", "@types/yargs@^17.0.8":
6159-
version "17.0.13"
6160-
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.13.tgz#34cced675ca1b1d51fcf4d34c3c6f0fa142a5c76"
6161-
integrity sha512-9sWaruZk2JGxIQU+IhI1fhPYRcQ0UuTNuKuCW9bR5fp7qi2Llf7WDzNa17Cy7TKnh3cdxDOiyTu6gaLS0eDatg==
6162-
dependencies:
6163-
"@types/yargs-parser" "*"
6164-
61656153
"@types/yargs@^15.0.0":
61666154
version "15.0.14"
61676155
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-15.0.14.tgz#26d821ddb89e70492160b66d10a0eb6df8f6fb06"
@@ -6176,6 +6164,13 @@
61766164
dependencies:
61776165
"@types/yargs-parser" "*"
61786166

6167+
"@types/yargs@^17.0.8":
6168+
version "17.0.13"
6169+
resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-17.0.13.tgz#34cced675ca1b1d51fcf4d34c3c6f0fa142a5c76"
6170+
integrity sha512-9sWaruZk2JGxIQU+IhI1fhPYRcQ0UuTNuKuCW9bR5fp7qi2Llf7WDzNa17Cy7TKnh3cdxDOiyTu6gaLS0eDatg==
6171+
dependencies:
6172+
"@types/yargs-parser" "*"
6173+
61796174
"@types/yauzl@^2.9.1":
61806175
version "2.10.0"
61816176
resolved "https://registry.yarnpkg.com/@types/yauzl/-/yauzl-2.10.0.tgz#b3248295276cf8c6f153ebe6a9aba0c988cb2599"

0 commit comments

Comments
 (0)