@@ -9,38 +9,46 @@ const data = props.entry.data;
99
1010const html = await Astro .slots .render (" default" );
1111
12+ if (props .id === " 404" ) {
13+ props .toc = undefined ;
14+ }
15+
1216if (props .toc ) {
1317 props .toc .items = await generateTableOfContents (html );
1418}
1519
1620if (props .hasSidebar ) {
17- const group = await getSidebar (Astro );
18- props .sidebar = group .entries ;
21+ try {
22+ const group = await getSidebar (Astro );
23+ props .sidebar = group .entries ;
1924
20- if (props .pagination ) {
21- const flattened = flattenSidebar (props .sidebar );
25+ if (props .pagination ) {
26+ const flattened = flattenSidebar (props .sidebar );
2227
23- const idx = flattened .findIndex ((entry ) => entry .isCurrent );
28+ const idx = flattened .findIndex ((entry ) => entry .isCurrent );
2429
25- let prev = flattened [idx - 1 ];
26- let next = flattened [idx + 1 ];
30+ let prev = flattened [idx - 1 ];
31+ let next = flattened [idx + 1 ];
2732
28- if (prev ?.attrs [" data-group-label" ]) {
29- prev = {
30- ... prev ,
31- label: prev .attrs [" data-group-label" ],
32- };
33- }
33+ if (prev ?.attrs [" data-group-label" ]) {
34+ prev = {
35+ ... prev ,
36+ label: prev .attrs [" data-group-label" ],
37+ };
38+ }
3439
35- if (next ?.attrs [" data-group-label" ]) {
36- next = {
37- ... next ,
38- label: next .attrs [" data-group-label" ],
39- };
40- }
40+ if (next ?.attrs [" data-group-label" ]) {
41+ next = {
42+ ... next ,
43+ label: next .attrs [" data-group-label" ],
44+ };
45+ }
4146
42- props .pagination .prev = prev ;
43- props .pagination .next = next ;
47+ props .pagination .prev = prev ;
48+ props .pagination .next = next ;
49+ }
50+ } catch {
51+ props .hasSidebar = false ;
4452 }
4553}
4654
0 commit comments