Skip to content

Commit 7e63888

Browse files
committed
junk: REVERT ME TOO - checking size
1 parent 2bb7904 commit 7e63888

File tree

15 files changed

+472
-155
lines changed

15 files changed

+472
-155
lines changed

jsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
"noEmit": true,
1010
"allowJs": true,
1111
"checkJs": true
12-
}
12+
},
13+
"exclude": ["node_modules", "build"]
1314
}

src/components/controllers/guide-page.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import cx from '../../lib/cx';
88
import { MarkdownRegion } from './markdown-region';
99
import Sidebar from '../sidebar';
1010
import Footer from '../footer/index';
11-
import { docRoutes } from '../../lib/route-utils';
11+
import { flatv10DocPages } from '../../config.js';
12+
//import { docRoutes } from '../../lib/route-utils';
1213
import { LATEST_MAJOR, PREVIEW_MAJOR } from '../doc-version';
1314
import style from './style.module.css';
1415

1516
export function GuidePage() {
1617
const { version, name } = useRoute().params;
17-
const isValidRoute = docRoutes[version]['/' + name];
18+
const isValidRoute = flatv10DocPages['/' + name];
1819

1920
return (
2021
<ErrorBoundary>

src/components/header/search.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,13 @@ const transformItems = items =>
6565
});
6666
});
6767

68+
const getLoadingBar = () =>
69+
typeof window !== 'undefined' ? document.querySelector('loading-bar') : null;
70+
6871
export default function Search() {
6972
const root = useRef(null);
7073
const rendered = useRef(false);
7174
const interactedWith = useRef(false);
72-
const loadingBar =
73-
typeof window !== 'undefined'
74-
? document.querySelector('loading-bar')
75-
: null;
7675

7776
const loadDocSearch = () => {
7877
if (!rendered.current) {
@@ -91,7 +90,8 @@ export default function Search() {
9190

9291
waitForDocsearch(root.current).then(docsearchButton => {
9392
rendered.current = true;
94-
loadingBar.removeAttribute('showing');
93+
const loadingBar = getLoadingBar();
94+
if (loadingBar) loadingBar.removeAttribute('showing');
9595
if (interactedWith.current) {
9696
docsearchButton.click();
9797
}
@@ -107,6 +107,7 @@ export default function Search() {
107107
// The <loading-bar> is sat alongside the router & has it's state controlled by it,
108108
// so while we could create a new context to be able to set it here, direct DOM
109109
// manipulation is a heck of a lot simpler.
110+
const loadingBar = getLoadingBar();
110111
loadingBar.setAttribute('showing', 'true');
111112
}
112113
};

src/components/sidebar/index.jsx

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,62 @@
11
import { useRoute } from 'preact-iso';
22
import DocVersion from '../doc-version';
33
import SidebarNav from './sidebar-nav';
4-
import config from '../../config.json';
54
import { useOverlayToggle } from '../../lib/toggle-overlay';
6-
import {
7-
useLanguage
8-
//getSidebarRouteName,
9-
//getHeaderRouteName
10-
} from '../../lib/i18n';
5+
import { useLanguageContext, translatePath, reeee } from '../../lib/i18n';
6+
import { docPages } from '../../config.js';
117
import style from './style.module.css';
128

139
export default function Sidebar() {
1410
const {
1511
version
1612
} = /** @type {{ version: 'v8' | 'v10' | 'v11' }} */ (useRoute().params);
17-
const [lang] = useLanguage();
1813
const [open, setOpen] = useOverlayToggle();
1914

15+
const { translations, fallback } = useLanguageContext();
16+
2017
const navItems = [];
21-
for (const item of config.docs[version]) {
22-
if ('routes' in item) {
23-
navItems.push({
24-
text: '',
25-
level: 2,
26-
href: null,
27-
routes: item.routes.map(nested => ({
28-
text: '',
18+
if (version == 'v8') {
19+
} else {
20+
for (const page of docPages[version]) {
21+
const routes = [];
22+
for (const route in page.routes) {
23+
routes.push({
24+
text: translatePath(route, translations, fallback),
2925
level: 3,
30-
href: `/guide/${version}${nested.path}`
31-
}))
32-
});
33-
} else {
26+
href: `/guide/${version}${route}`
27+
});
28+
}
29+
3430
navItems.push({
35-
text: '',
31+
text: reeee(page.label, translations, fallback),
3632
level: 2,
37-
href: `/guide/${version}${item.path}`
33+
href: null,
34+
routes
3835
});
3936
}
4037
}
4138

39+
//for (const item in docPages[version]) {
40+
// if ('routes' in item) {
41+
// navItems.push({
42+
// text: '',
43+
// level: 2,
44+
// href: null,
45+
// routes: item.routes.map(nested => ({
46+
// text: '',
47+
// level: 3,
48+
// href: `/guide/${version}${nested.path}`
49+
// }))
50+
// });
51+
// } else {
52+
// navItems.push({
53+
// text: '',
54+
// level: 2,
55+
// href: `/guide/${version}${item.path}`
56+
// });
57+
// }
58+
//}
59+
4260
// TODO: Is "Guide" really the best label for the button?
4361
const mobileButtonLabel = '';
4462

0 commit comments

Comments
 (0)