-
-
Notifications
You must be signed in to change notification settings - Fork 248
/
Copy pathSidebar.tsx
937 lines (914 loc) · 30 KB
/
Sidebar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
import { getLayout as getSiteLayout } from './SiteLayout';
import React, { useEffect, useState } from 'react';
import { useRouter } from 'next/router';
import Link from 'next/link';
import { HOST } from '~/lib/config';
import classnames from 'classnames';
import { SegmentHeadline } from './Layout';
import extractPathWithoutFragment from '~/lib/extractPathWithoutFragment';
import CarbonAds from './CarbonsAds';
import { useTheme } from 'next-themes';
import ExternalLinkIcon from '../public/icons/external-link-black.svg';
import Image from 'next/image';
import TOC from './TOC';
const DocLink = ({
uri,
label,
onClick,
setOpen,
}: {
uri: string;
label: string | React.ReactNode;
onClick?: () => void;
setOpen: (open: boolean) => void;
}) => {
const router = useRouter();
const url = new URL(`${router.asPath}`, HOST);
url.search = '';
url.hash = '';
const stringUrl = url.toString().substr(HOST.length, Infinity);
const isActive = uri === extractPathWithoutFragment(stringUrl);
return (
<Link
href={uri}
className={classnames('text-sm block py-1 pl-2', {
' font-medium': !isActive,
'text-primary dark:text-[#007bff] text-bold border-l-2 border-l-primary font-semibold':
isActive,
})}
onClick={() => {
if (onClick) onClick();
setOpen(false);
}}
>
{label}
</Link>
);
};
const DocLinkBlank = ({
uri,
label,
onClick,
setOpen,
}: {
uri: string;
label: string | React.ReactNode;
onClick?: () => void;
setOpen: (open: boolean) => void;
}) => {
const router = useRouter();
const url = new URL(`${router.asPath}`, HOST);
url.search = '';
url.hash = '';
const stringUrl = url.toString().substr(HOST.length, Infinity);
const isActive = uri === extractPathWithoutFragment(stringUrl);
return (
<Link
href={uri}
className={classnames('flex text-sm block py-1 pl-2', {
'font-medium': !isActive,
'text-primary text-bold border-l-2 border-l-primary font-semibold':
isActive,
})}
target='_blank'
rel='noopener noreferrer'
onClick={() => {
if (onClick) onClick();
setOpen(false);
}}
style={{
position: 'relative',
paddingRight: '1.25em',
}}
>
{label}
<span className='dark:invert flex justify-center items-center'>
<ExternalLinkIcon
style={{
marginLeft: '0.25em',
width: '1em',
height: '1em',
}}
/>
</span>
</Link>
);
};
const SegmentSubtitle = ({ label }: { label: string }) => {
return (
<div className='text-sm italic text-slate-900 dark:text-slate-400 mt-2 mb-2'>
{label}
</div>
);
};
const getDocsPath = [
'/docs',
'/overview/what-is-jsonschema',
'/overview/sponsors',
'/overview/case-studies',
'/overview/similar-technologies',
'/overview/use-cases',
'/overview/code-of-conduct',
'/overview/faq',
'/overview/roadmap',
];
const getStartedPath = [
'/learn',
'/learn/json-schema-examples',
'/learn/file-system',
'/learn/miscellaneous-examples',
'/learn/getting-started-step-by-step',
'/understanding-json-schema/about',
'/understanding-json-schema/basics',
'/learn/glossary',
];
const getGuidesPath = [
'/learn/guides',
'/implementers',
'/implementers/interfaces',
];
const getReferencePath = [
'/understanding-json-schema',
'/understanding-json-schema/keywords',
'/understanding-json-schema/conventions',
'/understanding-json-schema/credits',
'/understanding-json-schema/structuring',
'/understanding-json-schema/reference/annotations',
'/understanding-json-schema/reference/array',
'/understanding-json-schema/reference/boolean',
'/understanding-json-schema/reference/combining',
'/understanding-json-schema/reference/comments',
'/understanding-json-schema/reference/conditionals',
'/understanding-json-schema/reference/const',
'/understanding-json-schema/reference/enum',
'/understanding-json-schema/reference/composition',
'/understanding-json-schema/reference/metadata',
'/understanding-json-schema/reference/non_json_data',
'/understanding-json-schema/reference/null',
'/understanding-json-schema/reference/numeric',
'/understanding-json-schema/reference/object',
'/understanding-json-schema/reference/regular_expressions',
'/understanding-json-schema/reference/schema',
'/understanding-json-schema/reference/string',
'/understanding-json-schema/reference/type',
'/understanding-json-schema/reference/generic',
'/understanding-json-schema/reference',
];
const getSpecificationPath = [
'/draft/2020-12',
'/draft/2019-09',
'/draft-07',
'/draft-06',
'/draft-05',
'/specification-links',
'/specification/migration',
'/specification/release-notes',
'/specification/json-hyper-schema',
'/specification',
'/specification-links',
];
export const SidebarLayout = ({ children }: { children: React.ReactNode }) => {
const router = useRouter();
const [open, setOpen] = useState(false);
const [rotateChevron, setRotateChevron] = useState(false);
const handleRotate = () => setRotateChevron(!rotateChevron);
const rotate = rotateChevron ? 'rotate(180deg)' : 'rotate(0)';
const pathWtihoutFragment = extractPathWithoutFragment(router.asPath);
useEffect(() => {
if (window) {
window.addEventListener('resize', () => {
if (window.innerWidth > 1024) {
setOpen(false);
}
});
}
}, [typeof window !== 'undefined']);
return (
<div className='max-w-[1400px] mx-auto flex flex-col items-center'>
<section>
<div className='bg-primary dark:bg-slate-900 w-full h-12 mt-[4.5rem] z-150 flex relative flex-col justify-center items-center lg:hidden '>
<div
className='z-[150] flex w-full bg-primary dark:bg-slate-900 justify-between items-center'
onMouseDown={(e) => e.stopPropagation()}
onClick={(e) => {
e.stopPropagation();
handleRotate();
setOpen(!open);
}}
>
{getDocsPath.includes(pathWtihoutFragment) && (
<h3 className='text-white ml-12'>Introduction</h3>
)}
{getStartedPath.includes(pathWtihoutFragment) && (
<h3 className='text-white ml-12'>Get started</h3>
)}
{getGuidesPath.includes(pathWtihoutFragment) && (
<h3 className='text-white ml-12'>Guides</h3>
)}
{getReferencePath.includes(pathWtihoutFragment) && (
<h3 className='text-white ml-12'>Reference</h3>
)}
{getSpecificationPath.includes(pathWtihoutFragment) && (
<h3 className='text-white ml-12'>Specification</h3>
)}
{router.pathname === null && (
<h3 className='text-white ml-12'>Docs</h3>
)}
<svg
style={{
marginRight: '50px',
color: 'white',
transform: rotate,
transition: 'all 0.2s linear',
}}
xmlns='http://www.w3.org/2000/svg'
height='24'
viewBox='0 0 256 512'
>
<path
d='M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z'
id='mainIconPathAttribute'
fill='#ffffff'
></path>
</svg>
</div>
</div>
<div
className={`z-[150] absolute top-10 mt-24 left-0 h-full w-screen bg-white dark:bg-slate-900 dark:shadow-lg transform ${open ? '-translate-x-0' : '-translate-x-full'} transition-transform duration-300 ease-in-out filter drop-shadow-md `}
>
<div className='flex flex-col dark:bg-slate-900'>
<DocsNav open={open} setOpen={setOpen} />
</div>
</div>
<div className='dark:bg-slate-800 max-w-[1400px] grid grid-cols-1 lg:grid-cols-4 mx-4 md:mx-12'>
{/* Sidebar */}
<div className='hidden lg:block mt-24 sticky top-24 h-[calc(100vh-6rem)] overflow-hidden'>
<div className='h-full overflow-y-auto scrollbar-hidden'>
<DocsNav open={open} setOpen={setOpen} />
<CarbonAds
className='lg:mt-8 w-4/5 mx-auto lg:ml-4'
variant='sidebar'
/>
</div>
</div>
{/* Main Content (Children) */}
<div
id='main-content'
className='col-span-4 md:col-span-2 lg:col-span-2 lg:mt-20 lg:w-5/6 mx-4 md:mx-0'
>
{children}
</div>
{/* TOC */}
<div className='sticky top-16 hidden lg:block'>
<TOC />
</div>
</div>
</section>
</div>
);
};
export const DocsNav = ({
setOpen,
}: {
open: boolean;
setOpen: (open: boolean) => void;
}) => {
const router = useRouter();
/* eslint-disable no-constant-condition */
const [active, setActive] = useState({
getDocs: false,
getStarted: false,
getGuides: false,
getReference: false,
getSpecification: false,
});
useEffect(() => {
const pathWtihoutFragment = extractPathWithoutFragment(router.asPath);
const newActive = {
getDocs: false,
getStarted: false,
getGuides: false,
getReference: false,
getSpecification: false,
};
if (getDocsPath.includes(pathWtihoutFragment)) {
newActive.getDocs = true;
} else if (getStartedPath.includes(pathWtihoutFragment)) {
newActive.getStarted = true;
setActive({ ...active, getStarted: true });
} else if (getReferencePath.includes(pathWtihoutFragment)) {
newActive.getReference = true;
} else if (getSpecificationPath.includes(pathWtihoutFragment)) {
newActive.getSpecification = true;
} else if (getGuidesPath.includes(pathWtihoutFragment)) {
newActive.getGuides = true;
}
setActive(newActive);
}, [router.asPath]);
const handleClickDoc = () => {
setActive({
getDocs: !active.getDocs,
getStarted: false,
getReference: false,
getSpecification: false,
getGuides: false,
});
};
const handleClickGet = () => {
setActive({
getDocs: false,
getStarted: !active.getStarted,
getReference: false,
getSpecification: false,
getGuides: false,
});
};
const handleClickReference = () => {
setActive({
getDocs: false,
getStarted: false,
getReference: !active.getReference,
getSpecification: false,
getGuides: false,
});
};
const handleClickGuides = () => {
setActive({
getDocs: false,
getStarted: false,
getGuides: !active.getGuides,
getReference: false,
getSpecification: false,
});
};
const handleClickSpec = () => {
setActive({
getDocs: false,
getStarted: false,
getGuides: false,
getReference: false,
getSpecification: !active.getSpecification,
});
};
const rotate = active.getDocs ? 'rotate(180deg)' : 'rotate(0)';
const rotateG = active.getStarted ? 'rotate(180deg)' : 'rotate(0)';
const rotateR = active.getReference ? 'rotate(180deg)' : 'rotate(0)';
const rotateSpec = active.getSpecification ? 'rotate(180deg)' : 'rotate(0)';
const { resolvedTheme } = useTheme();
const [learn_icon, setLearn_icon] = useState('');
const [reference_icon, setReference_icon] = useState('');
const [spec_icon, setSpec_icon] = useState('');
const [overview_icon, setOverview_icon] = useState('');
const [guides_icon, setGuides_icon] = useState('');
useEffect(() => {
if (resolvedTheme === 'dark') {
setOverview_icon('/icons/eye-dark.svg');
setLearn_icon('/icons/compass-dark.svg');
setReference_icon('/icons/book-dark.svg');
setSpec_icon('/icons/clipboard-dark.svg');
setGuides_icon('/icons/grad-cap-dark.svg');
} else {
setOverview_icon('/icons/eye.svg');
setLearn_icon('/icons/compass.svg');
setReference_icon('/icons/book.svg');
setSpec_icon('/icons/clipboard.svg');
setGuides_icon('/icons/grad-cap.svg');
}
}, [resolvedTheme]);
return (
<div id='sidebar' className='lg:mt-8 w-4/5 mx-auto lg:ml-4'>
{/* Introduction */}
<div className='my-2 bg-slate-200 dark:bg-slate-900 border-white border lg:border-hidden p-2 rounded'>
<div
className='flex justify-between w-full items-center'
onClick={handleClickDoc}
>
<div className='flex items-center align-middle'>
<Image
src={`${overview_icon}`}
alt='eye icon'
height={20}
width={22}
className='mr-2'
/>
<SegmentHeadline label='Introduction' />
</div>
<svg
style={{
transform: rotate,
transition: 'all 0.2s linear',
cursor: 'pointer',
}}
id='arrow'
xmlns='http://www.w3.org/2000/svg'
fill='none'
height='32'
viewBox='0 0 24 24'
width='24'
>
<path
clipRule='evenodd'
d='m16.5303 8.96967c.2929.29289.2929.76777 0 1.06063l-4 4c-.2929.2929-.7677.2929-1.0606 0l-4.00003-4c-.29289-.29286-.29289-.76774 0-1.06063s.76777-.29289 1.06066 0l3.46967 3.46963 3.4697-3.46963c.2929-.29289.7677-.29289 1.0606 0z'
fill='#707070'
fillRule='evenodd'
/>
</svg>
</div>
<div
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getDocs,
'max-h-80 opacity-100': active.getDocs,
},
)}
id='overview'
>
<DocLink uri='/docs' label='Overview' setOpen={setOpen} />
<DocLink
uri='/overview/what-is-jsonschema'
label='What is JSON Schema?'
setOpen={setOpen}
/>
<DocLink uri='/overview/roadmap' label='Roadmap' setOpen={setOpen} />
<DocLink
uri='/overview/sponsors'
label='Sponsors'
setOpen={setOpen}
/>
<DocLink
uri='/overview/use-cases'
label='Use cases'
setOpen={setOpen}
/>
<DocLink
uri='/overview/case-studies'
label='Case studies'
setOpen={setOpen}
/>
<DocLink uri='/overview/faq' label='FAQ' setOpen={setOpen} />
<DocLink
uri='/overview/pro-help'
label='Pro Help'
setOpen={setOpen}
/>
<DocLink
uri='/overview/similar-technologies'
label='Similar technologies'
setOpen={setOpen}
/>
<DocLinkBlank
uri='https://landscape.json-schema.org'
label='Landscape'
setOpen={setOpen}
/>
<DocLink
uri='/overview/code-of-conduct'
label='Code of conduct'
setOpen={setOpen}
/>
</div>
</div>{' '}
{/*Closing div: Introduction*/}
{/* Get started */}
<div className='mb-2 bg-slate-200 dark:bg-slate-900 p-2 rounded border border-white lg:border-hidden '>
<div
className='flex justify-between w-full items-center'
onClick={handleClickGet}
>
<div className='flex items-center align-middle'>
<Image
src={`${learn_icon}`}
alt='compass icon'
height={20}
width={20}
className='mr-2'
/>
<SegmentHeadline label='Get Started' />
</div>
<svg
style={{
transform: rotateG,
transition: 'all 0.2s linear',
cursor: 'pointer',
}}
id='arrow'
xmlns='http://www.w3.org/2000/svg'
fill='none'
height='32'
viewBox='0 0 24 24'
width='24'
>
<path
clipRule='evenodd'
d='m16.5303 8.96967c.2929.29289.2929.76777 0 1.06063l-4 4c-.2929.2929-.7677.2929-1.0606 0l-4.00003-4c-.29289-.29286-.29289-.76774 0-1.06063s.76777-.29289 1.06066 0l3.46967 3.46963 3.4697-3.46963c.2929-.29289.7677-.29289 1.0606 0z'
fill='#707070'
fillRule='evenodd'
/>
</svg>
</div>
<div
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getStarted,
'max-h-80 opacity-100': active.getStarted,
},
)}
id='getStarted'
>
<DocLink uri='/learn' label='Overview' setOpen={setOpen} />
<DocLink
uri='/understanding-json-schema/about'
label='What is a schema?'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/basics'
label='The basics'
setOpen={setOpen}
/>
<DocLink
uri='/learn/getting-started-step-by-step'
label='Create your first schema'
setOpen={setOpen}
/>
<DocLinkBlank
uri='https://tour.json-schema.org/'
label='Tour of JSON Schema'
setOpen={setOpen}
/>
<DocLink
uri='/learn/glossary'
label='JSON Schema glossary'
setOpen={setOpen}
/>
<SegmentSubtitle label='Examples' />
<div className='pl-4 pb-1 pt-1'>
<DocLink
uri='/learn/miscellaneous-examples'
label='Miscellaneous examples'
setOpen={setOpen}
/>
<DocLink
uri='/learn/file-system'
label='Modelling a file system'
setOpen={setOpen}
/>
<DocLink
uri='/learn/json-schema-examples'
label='Other examples'
setOpen={setOpen}
/>
</div>
</div>
</div>{' '}
{/* Closing div: Get started */}
{/* Guides */}
<div className='mb-2 bg-slate-200 dark:bg-slate-900 p-2 rounded border border-white lg:border-hidden '>
<div
className='flex justify-between w-full items-center'
onClick={handleClickGuides}
>
<div className='flex items-center align-middle'>
<Image
src={`${guides_icon}`}
alt='grad cap icon'
height={20}
width={20}
className='mr-2'
/>
<SegmentHeadline label='Guides' />
</div>
<svg
style={{
transform: rotateG,
transition: 'all 0.2s linear',
cursor: 'pointer',
}}
id='arrow'
xmlns='http://www.w3.org/2000/svg'
fill='none'
height='32'
viewBox='0 0 24 24'
width='24'
>
<path
clipRule='evenodd'
d='m16.5303 8.96967c.2929.29289.2929.76777 0 1.06063l-4 4c-.2929.2929-.7677.2929-1.0606 0l-4.00003-4c-.29289-.29286-.29289-.76774 0-1.06063s.76777-.29289 1.06066 0l3.46967 3.46963 3.4697-3.46963c.2929-.29289.7677-.29289 1.0606 0z'
fill='#707070'
fillRule='evenodd'
/>
</svg>
</div>
<div
className={classnames('ml-6', { hidden: !active.getGuides })}
id='Guides'
>
<DocLink uri='/learn/guides' label='Overview' setOpen={setOpen} />
<DocLink
uri='/implementers'
label='For implementers'
setOpen={setOpen}
/>
<div className='pl-4 pb-1 pt-1'>
<DocLink
uri='/implementers/interfaces'
label='Common interfaces across implementations'
setOpen={setOpen}
/>
</div>
{/*Closing div tag: for implementers*/}
</div>
</div>{' '}
{/* Closing div: Guides */}
{/* Reference */}
<div className='mb-2 bg-slate-200 dark:bg-slate-900 p-2 rounded border border-white lg:border-hidden '>
<div
className='flex justify-between w-full items-center'
onClick={handleClickReference}
>
<div className='flex items-center align-middle'>
<Image
src={`${reference_icon}`}
alt='book icon'
height={20}
width={20}
className='mr-2'
/>
<SegmentHeadline label='Reference' />
</div>
<svg
style={{
transform: rotateR,
transition: 'all 0.2s linear',
cursor: 'pointer',
}}
id='arrow'
xmlns='http://www.w3.org/2000/svg'
fill='none'
height='32'
viewBox='0 0 24 24'
width='24'
>
<path
clipRule='evenodd'
d='m16.5303 8.96967c.2929.29289.2929.76777 0 1.06063l-4 4c-.2929.2929-.7677.2929-1.0606 0l-4.00003-4c-.29289-.29286-.29289-.76774 0-1.06063s.76777-.29289 1.06066 0l3.46967 3.46963 3.4697-3.46963c.2929-.29289.7677-.29289 1.0606 0z'
fill='#707070'
fillRule='evenodd'
/>
</svg>
</div>
{/*Opening div: inner reference div */}
<div
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getReference,
'max-h-80 overflow-y-auto opacity-100': active.getReference,
},
)}
id='reference'
>
<DocLink
uri='/understanding-json-schema/reference'
label='Overview'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/keywords'
label='JSON Schema keywords'
setOpen={setOpen}
/>
{/*<DocLink
uri='/understanding-json-schema'
label='Understanding JSON Schema'
setOpen={setOpen}
/>*/}
{/*<div className='pl-4 pb-1 pt-1'>*/}
{/*<DocLink
uri='/understanding-json-schema/conventions'
label='Conventions used'
setOpen={setOpen}
/>*/}
{/*<DocLink
uri='/understanding-json-schema/reference'
label='JSON Schema Reference'
setOpen={setOpen}
/>
<div className='pl-4 pb-1 pt-1'> Opening div tag: understanding JSON*/}
<DocLink
uri='/understanding-json-schema/reference/type'
label='JSON data types'
setOpen={setOpen}
/>
<div className='pl-4 pb-1 pt-1'>
{' '}
{/*Opening div: JSON data types*/}
<DocLink
uri='/understanding-json-schema/reference/array'
label='array'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/boolean'
label='boolean'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/null'
label='null'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/numeric'
label='numeric types'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/object'
label='object'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/regular_expressions'
label='regular expressions'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/string'
label='string'
setOpen={setOpen}
/>
</div>{' '}
{/*Closing div: JSON data types*/}
<DocLink
uri='/understanding-json-schema/reference/schema'
label='Dialect and vocabulary declaration'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/generic'
label='Enumerated and constant values'
setOpen={setOpen}
/>
<div className='pl-4 pb-1 pt-1'>
{' '}
{/*Opening div: Schema constraints*/}
<DocLink
uri='/understanding-json-schema/reference/enum'
label='Enumerated values'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/const'
label='Constant values'
setOpen={setOpen}
/>
</div>{' '}
{/*Closing div: Schema constraints*/}
<DocLink
uri='/understanding-json-schema/reference/metadata'
label='Schema annotations and comments'
setOpen={setOpen}
/>
<div className='pl-4 pb-1 pt-1'>
{/*Opening div: Schema metadata*/}
<DocLink
uri='/understanding-json-schema/reference/annotations'
label='Annotations'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/comments'
label='Comments'
setOpen={setOpen}
/>
</div>{' '}
{/*Closing div: Schema metadata*/}
<DocLink
uri='/understanding-json-schema/reference/conditionals'
label='Conditional schema validation'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/reference/composition'
label='Schema composition'
setOpen={setOpen}
/>
<div className='pl-4 pb-1 pt-1'>
{' '}
{/*Opening div: Schema composition*/}
<DocLink
uri='/understanding-json-schema/reference/combining'
label='Boolean JSON Schema combination'
setOpen={setOpen}
/>
<DocLink
uri='/understanding-json-schema/structuring'
label='Modular JSON Schema combination'
setOpen={setOpen}
/>
</div>{' '}
{/*Closing div: Schema composition*/}
<DocLink
uri='/understanding-json-schema/reference/non_json_data'
label='Media: string-encoding non-JSON data'
setOpen={setOpen}
/>
<DocLinkBlank
uri='https://www.learnjsonschema.com/'
label='Learn JSON Schema'
setOpen={setOpen}
/>
</div>
</div>{' '}
{/*Closing div: inner reference div */}
{/* Specification */}
<div className='mb-2 bg-slate-200 dark:bg-slate-900 p-2 rounded border border-white lg:border-hidden '>
<div
className='flex justify-between w-full items-center'
onClick={handleClickSpec}
>
<div className='flex items-center align-middle'>
<Image
src={`${spec_icon}`}
alt='clipboard icon'
height={20}
width={20}
className='mr-2'
/>
<SegmentHeadline label='Specification' />
</div>
<svg
id='arrow'
className='arrow'
style={{
transform: rotateSpec,
transition: 'all 0.2s linear',
cursor: 'pointer',
}}
xmlns='http://www.w3.org/2000/svg'
fill='none'
height='32'
viewBox='0 0 24 24'
width='24'
>
<path
clipRule='evenodd'
d='m16.5303 8.96967c.2929.29289.2929.76777 0 1.06063l-4 4c-.2929.2929-.7677.2929-1.0606 0l-4.00003-4c-.29289-.29286-.29289-.76774 0-1.06063s.76777-.29289 1.06066 0l3.46967 3.46963 3.4697-3.46963c.2929-.29289.7677-.29289 1.0606 0z'
fill='#707070'
fillRule='evenodd'
/>
</svg>
</div>
<div
className={classnames(
'ml-6',
'transition-all duration-500 ease-in-out',
{
'max-h-0 opacity-0 overflow-hidden': !active.getSpecification,
'max-h-80 opacity-100 overflow-hidden': active.getSpecification,
},
)}
id='specification'
>
<DocLink uri='/specification' label='Overview' setOpen={setOpen} />
<SegmentSubtitle label='Versions' />
<div className='pl-4 pb-1 pt-1'>
<DocLink uri='/draft/2020-12' label='2020-12' setOpen={setOpen} />
<DocLink uri='/draft/2019-09' label='2019-09' setOpen={setOpen} />
<DocLink uri='/draft-07' label='draft-07' setOpen={setOpen} />
<DocLink uri='/draft-06' label='draft-06' setOpen={setOpen} />
<DocLink uri='/draft-05' label='draft-05' setOpen={setOpen} />
</div>
<DocLink
uri='/specification-links'
label='Specification links'
setOpen={setOpen}
/>
<DocLink
uri='/specification/migration'
label='Migration'
setOpen={setOpen}
/>
<DocLink
uri='/specification/release-notes'
label='Release notes'
setOpen={setOpen}
/>
<DocLink
uri='/specification/json-hyper-schema'
label='JSON Hyper-Schema'
setOpen={setOpen}
/>
</div>
</div>
</div>
);
};
export const getLayout = (page: React.ReactNode) =>
getSiteLayout(<SidebarLayout>{page}</SidebarLayout>);