@@ -3,14 +3,115 @@ import path, { resolve } from "path";
3
3
import handlebars from "vite-plugin-handlebars" ;
4
4
import { fileURLToPath } from "node:url" ;
5
5
6
+ const config = {
7
+ currentRoute : "" ,
8
+ items : [
9
+ {
10
+ url : "about.html" ,
11
+ name : "About" ,
12
+ description : "Learn about Material Design and our Project Team." ,
13
+ icon : "info" ,
14
+ } ,
15
+ {
16
+ url : "getting-started.html" ,
17
+ name : "Getting started" ,
18
+ icon : "apps" ,
19
+ } ,
20
+ {
21
+ name : "Styles" ,
22
+ icon : "palette" ,
23
+ items : [
24
+ { url : "color.html" , name : "Color" } ,
25
+ { url : "grid.html" , name : "Grid" } ,
26
+ { url : "helpers.html" , name : "Helpers" } ,
27
+ { url : "media-css.html" , name : "Media" } ,
28
+ { url : "pulse.html" , name : "Pulse" } ,
29
+ { url : "sass.html" , name : "Sass" } ,
30
+ { url : "shadow.html" , name : "Shadow" } ,
31
+ { url : "table.html" , name : "Table" } ,
32
+ { url : "css-transitions.html" , name : "Transitions" } ,
33
+ { url : "typography.html" , name : "Typography" } ,
34
+ { url : "themes.html" , name : "Themes" } ,
35
+ { url : "waves.html" , name : "Waves" } ,
36
+ ] ,
37
+ } ,
38
+ {
39
+ name : "Components" ,
40
+ icon : "add_circle" ,
41
+ items : [
42
+ { url : "badges.html" , name : "Badges" } ,
43
+ { url : "buttons.html" , name : "Buttons" } ,
44
+ { url : "breadcrumbs.html" , name : "Breadcrumbs" } ,
45
+ { url : "cards.html" , name : "Cards" } ,
46
+ { url : "collections.html" , name : "Collections" } ,
47
+ { url : "floating-action-button.html" , name : "Floating Action Button" } ,
48
+ { url : "footer.html" , name : "Footer" } ,
49
+ { url : "icons.html" , name : "Icons" } ,
50
+ { url : "navbar.html" , name : "Navbar" } ,
51
+ { url : "pagination.html" , name : "Pagination" } ,
52
+ { url : "preloader.html" , name : "Preloader" } ,
53
+ { url : "auto-init.html" , name : "Auto Init" } ,
54
+ { url : "carousel.html" , name : "Carousel" } ,
55
+ { url : "collapsible.html" , name : "Collapsible" } ,
56
+ { url : "dropdown.html" , name : "Dropdown" } ,
57
+ { url : "feature-discovery.html" , name : "Feature Discovery" } ,
58
+ { url : "media.html" , name : "Media" } ,
59
+ { url : "modals.html" , name : "Modals" } ,
60
+ { url : "parallax.html" , name : "Parallax" } ,
61
+ { url : "pushpin.html" , name : "Pushpin" } ,
62
+ { url : "scrollspy.html" , name : "Scrollspy" } ,
63
+ { url : "sidenav.html" , name : "Sidenav" } ,
64
+ { url : "tabs.html" , name : "Tabs" } ,
65
+ { url : "toasts.html" , name : "Toasts" } ,
66
+ { url : "tooltips.html" , name : "Tooltips" } ,
67
+ ] ,
68
+ badges : { url : "/badges.html" , name : "Badges" } ,
69
+ grid : { url : "/grid.html" , name : "Grid" } ,
70
+ } ,
71
+ {
72
+ name : "Forms" ,
73
+ icon : "text_fields" ,
74
+ items : [
75
+ { url : "autocomplete.html" , name : "Autocomplete" } ,
76
+ { url : "checkboxes.html" , name : "Checkboxes" } ,
77
+ { url : "chips.html" , name : "Chips" } ,
78
+ { url : "pickers.html" , name : "Pickers" } ,
79
+ { url : "radio-buttons.html" , name : "Radio Buttons" } ,
80
+ { url : "range.html" , name : "Range" } ,
81
+ { url : "select.html" , name : "Select" } ,
82
+ { url : "switches.html" , name : "Switches" } ,
83
+ { url : "text-inputs.html" , name : "Text Inputs" } ,
84
+ ] ,
85
+ } ,
86
+ {
87
+ url : "mobile.html" ,
88
+ name : "Mobile" ,
89
+ icon : "mobile_friendly" ,
90
+ } ,
91
+ ] ,
92
+ } ;
93
+
6
94
export default {
7
95
base : "./" ,
8
96
plugins : [
9
97
handlebars ( {
10
98
context ( pagePath ) {
11
- return {
12
- title : pagePath ,
13
- } ;
99
+ config . currentRoute = pagePath ;
100
+ return config ;
101
+ } ,
102
+ helpers : {
103
+ lookup : function ( item ) {
104
+ return item . items ? "menucollapsible" : "menuitem" ; // JSON.stringify(item);
105
+ //return "menuitem";
106
+ } ,
107
+ icon : function ( ) {
108
+ if ( ! this . icon ) return "" ;
109
+ return `<span class="material-icons">${ this . icon } </span>` ;
110
+ } ,
111
+ isActive : function ( ctx ) {
112
+ const currentRoute = ctx . data . root . currentRoute ;
113
+ return currentRoute === "/" + this . url ? "active" : "" ;
114
+ } ,
14
115
} ,
15
116
partialDirectory : resolve ( __dirname , "partials" ) ,
16
117
} ) ,
@@ -20,12 +121,11 @@ export default {
20
121
//this is needed for "vite publish" to include all html files, not only the index.
21
122
input : Object . fromEntries (
22
123
globSync ( "*.html" ) . map ( ( file ) => [
23
- // // This remove the file extension from each
24
- // // file, so e.g. nested/foo.js becomes nested/foo
124
+ // This remove the file extension from each
125
+ // file, so e.g. nested/foo.js becomes nested/foo
25
126
file . slice ( 0 , file . length - path . extname ( file ) . length ) ,
26
-
27
- // // This expands the relative paths to absolute paths, so e.g.
28
- // // src/nested/foo becomes /project/src/nested/foo.js
127
+ // This expands the relative paths to absolute paths, so e.g.
128
+ // src/nested/foo becomes /project/src/nested/foo.js
29
129
fileURLToPath ( new URL ( file , import . meta. url ) ) ,
30
130
] )
31
131
) ,
0 commit comments