32
32
hljs .registerLanguage (' diff' , diff)
33
33
` )
34
34
35
+ module EnableCollapsibleNavbar = {
36
+ @react.component
37
+ let make = (~children ) => {
38
+ let scrollDir = Hooks .useScrollDirection ()
39
+
40
+ <div
41
+ className = {switch scrollDir {
42
+ | Up (_ ) => "group nav-appear"
43
+ | Down (_ ) => "group nav-disappear"
44
+ }}>
45
+ children
46
+ </div >
47
+ }
48
+ }
49
+
35
50
type pageComponent = React .component <{.}>
36
51
type pageProps = {.}
37
52
@@ -55,99 +70,112 @@ let make = (props: props): React.element => {
55
70
| {base : [], pagepath : []} => <LandingPageLayout > content </LandingPageLayout >
56
71
// docs routes
57
72
| {base : ["docs" , "manual" ], pagepath } =>
58
- // check if it's an api route
59
- switch pagepath [0 ] {
60
- | Some ("api" ) =>
61
- switch url -> Url .getVersionString {
62
- | ("v11.0.0" | "v12.0.0" ) as version =>
63
- switch (Array .length (pagepath ), pagepath [1 ]) {
64
- | (1 , _ ) => <ApiOverviewLayout .Docs version > content </ApiOverviewLayout .Docs >
73
+ <EnableCollapsibleNavbar >
74
+ // check if it's an api route
75
+ {switch pagepath [0 ] {
76
+ | Some ("api" ) =>
77
+ switch url -> Url .getVersionString {
78
+ | ("v11.0.0" | "v12.0.0" ) as version =>
79
+ switch (Array .length (pagepath ), pagepath [1 ]) {
80
+ | (1 , _ ) => <ApiOverviewLayout .Docs version > content </ApiOverviewLayout .Docs >
81
+ | _ => content
82
+ }
83
+ | "v8.0.0" =>
84
+ switch (Array .length (pagepath ), pagepath [1 ]) {
85
+ | (1 , _ ) => <ApiOverviewLayout8_0_0 .Docs > content </ApiOverviewLayout8_0_0 .Docs >
86
+ | (2 , Some ("js" )) => <JsDocsLayout8_0_0 .Prose > content </JsDocsLayout8_0_0 .Prose >
87
+ | (2 , Some ("belt" )) => <BeltDocsLayout8_0_0 .Prose > content </BeltDocsLayout8_0_0 .Prose >
88
+ | (_ , Some ("js" )) => <JsDocsLayout8_0_0 .Docs > content </JsDocsLayout8_0_0 .Docs >
89
+ | (_ , Some ("belt" )) => <BeltDocsLayout8_0_0 .Docs > content </BeltDocsLayout8_0_0 .Docs >
90
+ | (_ , Some ("dom" )) => <DomDocsLayout8_0_0 .Docs > content </DomDocsLayout8_0_0 .Docs >
91
+ | _ => React .null
92
+ }
93
+ | "v9.0.0" =>
94
+ switch (Array .length (pagepath ), pagepath [1 ]) {
95
+ | (1 , _ ) => <ApiOverviewLayout9_0_0 .Docs > content </ApiOverviewLayout9_0_0 .Docs >
96
+ | (2 , Some ("js" )) => <JsDocsLayout9_0_0 .Prose > content </JsDocsLayout9_0_0 .Prose >
97
+ | (2 , Some ("belt" )) => <BeltDocsLayout9_0_0 .Prose > content </BeltDocsLayout9_0_0 .Prose >
98
+ | (_ , Some ("js" )) => <JsDocsLayout9_0_0 .Docs > content </JsDocsLayout9_0_0 .Docs >
99
+ | (_ , Some ("belt" )) => <BeltDocsLayout9_0_0 .Docs > content </BeltDocsLayout9_0_0 .Docs >
100
+ | (_ , Some ("dom" )) => <DomDocsLayout9_0_0 .Docs > content </DomDocsLayout9_0_0 .Docs >
101
+ | _ => React .null
102
+ }
103
+ | "v10.0.0" =>
104
+ switch (Array .length (pagepath ), pagepath [1 ]) {
105
+ | (1 , _ ) => <ApiOverviewLayout10_0_0 .Docs > content </ApiOverviewLayout10_0_0 .Docs >
106
+ | (2 , Some ("js" )) => <JsDocsLayout10_0_0 .Prose > content </JsDocsLayout10_0_0 .Prose >
107
+ | (2 , Some ("belt" )) => <BeltDocsLayout10_0_0 .Prose > content </BeltDocsLayout10_0_0 .Prose >
108
+ | (_ , Some ("js" )) => <JsDocsLayout10_0_0 .Docs > content </JsDocsLayout10_0_0 .Docs >
109
+ | (_ , Some ("belt" )) => <BeltDocsLayout10_0_0 .Docs > content </BeltDocsLayout10_0_0 .Docs >
110
+ | (_ , Some ("dom" )) => <DomDocsLayout10_0_0 .Docs > content </DomDocsLayout10_0_0 .Docs >
111
+ | _ => React .null
112
+ }
65
113
| _ => content
66
114
}
67
- | "v8.0.0" =>
68
- switch (Array .length (pagepath ), pagepath [1 ]) {
69
- | (1 , _ ) => <ApiOverviewLayout8_0_0 .Docs > content </ApiOverviewLayout8_0_0 .Docs >
70
- | (2 , Some ("js" )) => <JsDocsLayout8_0_0 .Prose > content </JsDocsLayout8_0_0 .Prose >
71
- | (2 , Some ("belt" )) => <BeltDocsLayout8_0_0 .Prose > content </BeltDocsLayout8_0_0 .Prose >
72
- | (_ , Some ("js" )) => <JsDocsLayout8_0_0 .Docs > content </JsDocsLayout8_0_0 .Docs >
73
- | (_ , Some ("belt" )) => <BeltDocsLayout8_0_0 .Docs > content </BeltDocsLayout8_0_0 .Docs >
74
- | (_ , Some ("dom" )) => <DomDocsLayout8_0_0 .Docs > content </DomDocsLayout8_0_0 .Docs >
75
- | _ => React .null
76
- }
77
- | "v9.0.0" =>
78
- switch (Array .length (pagepath ), pagepath [1 ]) {
79
- | (1 , _ ) => <ApiOverviewLayout9_0_0 .Docs > content </ApiOverviewLayout9_0_0 .Docs >
80
- | (2 , Some ("js" )) => <JsDocsLayout9_0_0 .Prose > content </JsDocsLayout9_0_0 .Prose >
81
- | (2 , Some ("belt" )) => <BeltDocsLayout9_0_0 .Prose > content </BeltDocsLayout9_0_0 .Prose >
82
- | (_ , Some ("js" )) => <JsDocsLayout9_0_0 .Docs > content </JsDocsLayout9_0_0 .Docs >
83
- | (_ , Some ("belt" )) => <BeltDocsLayout9_0_0 .Docs > content </BeltDocsLayout9_0_0 .Docs >
84
- | (_ , Some ("dom" )) => <DomDocsLayout9_0_0 .Docs > content </DomDocsLayout9_0_0 .Docs >
115
+ | _ =>
116
+ switch url -> Url .getVersionString {
117
+ | "v8.0.0" =>
118
+ <ManualDocsLayout .V800 frontmatter = {component -> frontmatter }>
119
+ content
120
+ </ManualDocsLayout .V800 >
121
+ | "v9.0.0" =>
122
+ <ManualDocsLayout .V900 frontmatter = {component -> frontmatter }>
123
+ content
124
+ </ManualDocsLayout .V900 >
125
+ | "v10.0.0" =>
126
+ <ManualDocsLayout .V1000 frontmatter = {component -> frontmatter }>
127
+ content
128
+ </ManualDocsLayout .V1000 >
129
+ | "v11.0.0" =>
130
+ <ManualDocsLayout .V1100 frontmatter = {component -> frontmatter }>
131
+ content
132
+ </ManualDocsLayout .V1100 >
133
+ | "v12.0.0" =>
134
+ <ManualDocsLayout .V1200 frontmatter = {component -> frontmatter }>
135
+ content
136
+ </ManualDocsLayout .V1200 >
85
137
| _ => React .null
86
138
}
87
- | "v10.0.0" =>
88
- switch (Array .length (pagepath ), pagepath [1 ]) {
89
- | (1 , _ ) => <ApiOverviewLayout10_0_0 .Docs > content </ApiOverviewLayout10_0_0 .Docs >
90
- | (2 , Some ("js" )) => <JsDocsLayout10_0_0 .Prose > content </JsDocsLayout10_0_0 .Prose >
91
- | (2 , Some ("belt" )) => <BeltDocsLayout10_0_0 .Prose > content </BeltDocsLayout10_0_0 .Prose >
92
- | (_ , Some ("js" )) => <JsDocsLayout10_0_0 .Docs > content </JsDocsLayout10_0_0 .Docs >
93
- | (_ , Some ("belt" )) => <BeltDocsLayout10_0_0 .Docs > content </BeltDocsLayout10_0_0 .Docs >
94
- | (_ , Some ("dom" )) => <DomDocsLayout10_0_0 .Docs > content </DomDocsLayout10_0_0 .Docs >
95
- | _ => React .null
96
- }
97
- | _ => content
98
- }
99
- | _ =>
100
- switch url -> Url .getVersionString {
101
- | "v8.0.0" =>
102
- <ManualDocsLayout .V800 frontmatter = {component -> frontmatter }>
103
- content
104
- </ManualDocsLayout .V800 >
105
- | "v9.0.0" =>
106
- <ManualDocsLayout .V900 frontmatter = {component -> frontmatter }>
107
- content
108
- </ManualDocsLayout .V900 >
109
- | "v10.0.0" =>
110
- <ManualDocsLayout .V1000 frontmatter = {component -> frontmatter }>
139
+ }}
140
+ </EnableCollapsibleNavbar >
141
+
142
+ | {base : ["docs" , "react" ], version } =>
143
+ <EnableCollapsibleNavbar >
144
+ {switch version {
145
+ | Latest =>
146
+ <ReactDocsLayout .Latest frontmatter = {component -> frontmatter }>
111
147
content
112
- </ManualDocsLayout . V1000 >
113
- | "v11.0 .0" =>
114
- <ManualDocsLayout . V1100 frontmatter = {component -> frontmatter }>
148
+ </ReactDocsLayout . Latest >
149
+ | Version ( "v0.10 .0") =>
150
+ <ReactDocsLayout . V0100 frontmatter = {component -> frontmatter }>
115
151
content
116
- </ManualDocsLayout . V1100 >
117
- | "v12.0 .0" =>
118
- <ManualDocsLayout . V1200 frontmatter = {component -> frontmatter }>
152
+ </ReactDocsLayout . V0100 >
153
+ | Version ( "v0.11 .0") =>
154
+ <ReactDocsLayout . V0110 frontmatter = {component -> frontmatter }>
119
155
content
120
- </ManualDocsLayout . V1200 >
156
+ </ReactDocsLayout . V0110 >
121
157
| _ => React .null
122
- }
123
- }
124
-
125
- | {base : ["docs" , "react" ], version } =>
126
- switch version {
127
- | Latest =>
128
- <ReactDocsLayout .Latest frontmatter = {component -> frontmatter }>
129
- content
130
- </ReactDocsLayout .Latest >
131
- | Version ("v0.10.0" ) =>
132
- <ReactDocsLayout .V0100 frontmatter = {component -> frontmatter }> content </ReactDocsLayout .V0100 >
133
- | Version ("v0.11.0" ) =>
134
- <ReactDocsLayout .V0110 frontmatter = {component -> frontmatter }> content </ReactDocsLayout .V0110 >
135
- | _ => React .null
136
- }
158
+ }}
159
+ </EnableCollapsibleNavbar >
137
160
138
161
// common routes
139
162
| {base } =>
140
163
switch List .fromArray (base ) {
141
164
| list {"community" , ... _rest } =>
142
- <CommunityLayout frontmatter = {component -> frontmatter }> content </CommunityLayout >
165
+ <EnableCollapsibleNavbar >
166
+ <CommunityLayout frontmatter = {component -> frontmatter }> content </CommunityLayout >
167
+ </EnableCollapsibleNavbar >
143
168
144
169
| list {"try" } => content
145
- | list {"blog" } => content // Blog implements its own layout as well
146
- | list {"syntax-lookup" } => content
147
- | list {"packages" } => content
148
- | list {"blog" , ... _rest } => // Here, the layout will be handled by the Blog_Article component
149
- // to keep the frontmatter parsing etc in one place
150
- content
170
+ | list {"blog" } => <EnableCollapsibleNavbar > content </EnableCollapsibleNavbar > // Blog implements its own layout as well
171
+ | list {"syntax-lookup" } => <EnableCollapsibleNavbar > content </EnableCollapsibleNavbar >
172
+ | list {"packages" } => <EnableCollapsibleNavbar > content </EnableCollapsibleNavbar >
173
+ | list {"blog" , ... _rest } =>
174
+ <EnableCollapsibleNavbar >
175
+ // Here, the layout will be handled by the Blog_Article component
176
+ // to keep the frontmatter parsing etc in one place
177
+ content
178
+ </EnableCollapsibleNavbar >
151
179
| _ =>
152
180
let fm = component -> frontmatter -> DocFrontmatter .decode
153
181
let title = switch url {
0 commit comments