File tree Expand file tree Collapse file tree 12 files changed +166
-99
lines changed Expand file tree Collapse file tree 12 files changed +166
-99
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ category : guides
3
+ tags :
4
+ - testing
5
+ languages :
6
+ - javascript
7
+ ---
8
+
9
+ # Testing JavaScript
Original file line number Diff line number Diff line change
1
+ ---
2
+ category : references
3
+ languages : [javascript]
4
+ ---
5
+
6
+ # Sample JavaScript Reference
7
+
8
+ > TODO Remove this file
9
+
10
+ This file exists to show how the sidebar on language pages are automatically populated and grouped by ` category ` .
Original file line number Diff line number Diff line change 2
2
- id : docs
3
3
name : Docs
4
4
description : Docs
5
+
6
+ - id : guides
7
+ name : Guides
8
+ - id : references
9
+ name : References
10
+ description : Reference Manuals
Original file line number Diff line number Diff line change 9
9
name : Content
10
10
- id : codewars
11
11
name : Codewars
12
+
13
+ - id : testing
14
+ name : Testing
Original file line number Diff line number Diff line change @@ -61,9 +61,9 @@ module.exports = {
61
61
typeName : "Tag" ,
62
62
} ,
63
63
// Can reference multiple languages to be listed on the language page.
64
- // languages: {
65
- // typeName: "Language",
66
- // },
64
+ languages : {
65
+ typeName : "Language" ,
66
+ } ,
67
67
} ,
68
68
} ,
69
69
} ,
Original file line number Diff line number Diff line change @@ -149,7 +149,7 @@ pre[class*="language-"] {
149
149
}
150
150
151
151
& > code [class *= "language-" ] {
152
- @apply border-none leading-relaxed;
152
+ @apply border-none leading-relaxed px-0 ;
153
153
}
154
154
}
155
155
Original file line number Diff line number Diff line change 22
22
</div >
23
23
</template >
24
24
25
- <static-query >
26
- query {
27
- allMarkdownPage {
28
- edges {
29
- node {
30
- path
31
- title
32
- }
33
- }
34
- }
35
- }
36
- </static-query >
37
-
38
25
<script >
39
26
import { ArrowLeftIcon , ArrowRightIcon } from " vue-feather-icons" ;
40
27
41
28
export default {
42
29
props: {
43
- prevPath: {
44
- type: String ,
30
+ prev: {
31
+ // {path: string; title: string}
32
+ type: Object ,
45
33
},
46
- nextPath: {
47
- type: String ,
34
+ next: {
35
+ // {path: string; title: string}
36
+ type: Object ,
48
37
},
49
38
},
50
39
51
40
components: {
52
41
ArrowLeftIcon,
53
42
ArrowRightIcon,
54
43
},
55
-
56
- computed: {
57
- pages () {
58
- return this .$static .allMarkdownPage .edges .map ((edge ) => edge .node );
59
- },
60
- next () {
61
- if (! this .nextPath ) return false ;
62
-
63
- return this .pages .find ((page ) => page .path === this .nextPath );
64
- },
65
- prev () {
66
- if (! this .prevPath ) return false ;
67
-
68
- return this .pages .find ((page ) => page .path === this .prevPath );
69
- },
70
- },
71
44
};
72
45
</script >
Original file line number Diff line number Diff line change 1
1
<template >
2
2
<div
3
3
ref =" sidebar"
4
- v-if =" showSidebar "
4
+ v-if =" sidebarSections "
5
5
class =" px-4 pt-8 lg:pt-12 divide-y divide-ui-border"
6
6
>
7
- <div v-for =" section of sidebar.sections " :key =" section.title" class =" py-4" >
7
+ <div v-for =" section of sidebarSections " :key =" section.title" class =" py-4" >
8
8
<h3
9
9
class =" pt-0 mt-0 mb-1 font-black text-sm leading-snug tracking-tight uppercase border-none text-ui-typo"
10
10
>
13
13
14
14
<ul class =" max-w-full pl-2 mb-0" >
15
15
<li
16
- v-for =" page in findPages( section.items) "
16
+ v-for =" page in section.items"
17
17
:id =" page.path"
18
18
:key =" page.path"
19
19
:class =" getClassesForAnchor(page.path)"
34
34
</div >
35
35
</template >
36
36
37
- <static-query >
38
- query Sidebar {
39
- metadata {
40
- settings {
41
- sidebar {
42
- name
43
- sections {
44
- title
45
- items
46
- }
47
- }
48
- }
49
- }
50
-
51
- allMarkdownPage {
52
- edges {
53
- node {
54
- path
55
- title
56
- }
57
- }
58
- }
59
- }
60
- </static-query >
61
-
62
37
<script >
63
38
export default {
64
39
props: {
65
40
currentPath: {
66
41
type: String ,
67
42
required: true ,
68
43
},
69
- // Name of the sidebar.
70
- name: {
71
- type: String ,
72
- },
73
- },
74
- data () {
75
- return {
76
- expanded: [],
77
- };
78
- },
79
- computed: {
80
- pages () {
81
- return this .$static .allMarkdownPage .edges .map ((edge ) => edge .node );
82
- },
83
- sidebar () {
84
- const name = this .name ;
85
- return this .$static .metadata .settings .sidebar .find (
86
- (sidebar ) => sidebar .name === name
87
- );
88
- },
89
- showSidebar () {
90
- return this .name && this .sidebar ;
44
+ sidebarSections: {
45
+ // Array of sections
46
+ type: Array ,
91
47
},
92
48
},
93
49
methods: {
@@ -98,9 +54,6 @@ export default {
98
54
" transition transform hover:translate-x-1 hover:text-ui-primary" : ! current,
99
55
};
100
56
},
101
- findPages (links ) {
102
- return links .map ((link ) => this .pages .find ((page ) => page .path === link));
103
- },
104
57
},
105
58
};
106
59
</script >
Original file line number Diff line number Diff line change 21
21
<div class =" w-full pb-16 bg-ui-background" >
22
22
<Sidebar
23
23
@navigate =" sidebarOpen = false"
24
- :name = " sidebarName "
24
+ :sidebarSections = " sidebarSections "
25
25
:currentPath =" currentPath"
26
26
/>
27
27
</div >
52
52
query {
53
53
metadata {
54
54
siteName
55
+ settings {
56
+ sidebar {
57
+ name
58
+ sections {
59
+ title
60
+ items
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ allMarkdownPage {
67
+ edges {
68
+ node {
69
+ path
70
+ title
71
+ }
72
+ }
55
73
}
56
74
}
57
75
</static-query >
@@ -66,8 +84,9 @@ export default {
66
84
currentPath: {
67
85
type: String ,
68
86
},
69
- sidebarName: {
70
- type: String ,
87
+ sidebar: {
88
+ // Name of the sidebar defined in settings or array of sections.
89
+ type: [String , Array ],
71
90
},
72
91
},
73
92
components: {
@@ -95,6 +114,9 @@ export default {
95
114
},
96
115
},
97
116
computed: {
117
+ pages () {
118
+ return this .$static .allMarkdownPage .edges .map ((edge ) => edge .node );
119
+ },
98
120
sidebarStyle () {
99
121
return {
100
122
top: this .headerHeight + " px" ,
@@ -104,10 +126,27 @@ export default {
104
126
hasSidebar () {
105
127
return (
106
128
this .$page &&
107
- (this .$page .markdownPage || this .sidebarName ) &&
129
+ (this .$page .markdownPage || this .sidebar ) &&
108
130
this .headerHeight > 0
109
131
);
110
132
},
133
+ sidebarSections () {
134
+ if (Array .isArray (this .sidebar )) return this .sidebar ;
135
+
136
+ const def = this .$static .metadata .settings .sidebar .find (
137
+ (sidebar ) => sidebar .name === this .sidebar
138
+ );
139
+ if (! def) return null ;
140
+
141
+ return def .sections .map ((section ) => {
142
+ return {
143
+ title: section .title ,
144
+ items: section .items .map ((link ) =>
145
+ this .pages .find ((page ) => page .path === link)
146
+ ),
147
+ };
148
+ });
149
+ },
111
150
},
112
151
mounted () {
113
152
this .setHeaderHeight ();
Original file line number Diff line number Diff line change 1
1
<template >
2
- <Layout currentPath =" /languages/" sidebarName =" docs" >
2
+ <Layout currentPath =" /languages/" sidebar =" docs" >
3
3
<div class =" w-full md:w-2/3" >
4
4
<div class =" content" >
5
5
<h1 id =" supported-languages" >
You can’t perform that action at this time.
0 commit comments