@@ -15,6 +15,18 @@ const sideBar = {
15
15
source : "/content/essentials" ,
16
16
key : "essentials" ,
17
17
} ,
18
+ aesthetics : {
19
+ order : 3 ,
20
+ label : "Aesthetics" ,
21
+ source : "/content/aesthetics" ,
22
+ key : "aesthetics" ,
23
+ } ,
24
+ "developer-experience" : {
25
+ order : 4 ,
26
+ label : "Developer Experience" ,
27
+ source : "/content/developer-experience" ,
28
+ key : "developer-experience" ,
29
+ } ,
18
30
} ;
19
31
20
32
main ( ) ;
@@ -35,11 +47,12 @@ async function main() {
35
47
sidebarRoot
36
48
) ;
37
49
50
+ let storedContent = new Array ( Object . keys ( sideBar ) . length ) ;
38
51
const promiseChain = Object . entries ( sideBar )
39
52
. sort ( ( x , y ) => x [ 1 ] . order - y [ 1 ] . order )
40
53
. map ( async ( entry , index , source ) => {
41
54
const [ key , value ] = entry ;
42
- fetch ( `${ value . source } .md` ) . then ( async ( d ) => {
55
+ return fetch ( `${ value . source } .md` ) . then ( async ( d ) => {
43
56
if ( ! d . ok ) {
44
57
return ;
45
58
}
@@ -53,16 +66,30 @@ async function main() {
53
66
if ( source . length - 1 == index ) {
54
67
layoutSpacing . push ( "pb-12 mb-12" ) ;
55
68
}
56
- contentRoot . innerHTML += `<section id="${ key } " class="flex flex-col ${ layoutSpacing
57
- . filter ( Boolean )
58
- . join ( " " ) } ">
59
- ${ await marked ( content , { } ) }
60
- </section>` ;
69
+ storedContent . push ( {
70
+ order : value . order ,
71
+ content : `<section id="${ key } " class="flex flex-col ${ layoutSpacing
72
+ . filter ( Boolean )
73
+ . join ( " " ) } ">
74
+ ${ await marked ( content , { } ) }
75
+ </section>` ,
76
+ } ) ;
61
77
} ) ;
62
78
} ) ;
79
+
63
80
await promiseChain . reduce ( ( acc , item ) => {
64
81
return acc . then ( ( _ ) => item ) ;
65
82
} , Promise . resolve ( ) ) ;
83
+
84
+ console . log ( { storedContent } ) ;
85
+ const usableContent = storedContent
86
+ // .sort((x, y) => x.order - y.order)
87
+ . map ( ( x ) => {
88
+ return x . content ;
89
+ } )
90
+ . join ( "\n" ) ;
91
+
92
+ contentRoot . innerHTML = usableContent ;
66
93
}
67
94
68
95
function Sidebar ( { items = [ ] } = { } ) {
@@ -91,15 +118,15 @@ function Sidebar({ items = [] } = {}) {
91
118
}
92
119
93
120
function SidebarItem ( { item, active, onPress } ) {
94
- return html `< li >
95
- < a
96
- href =" # ${ item . key } "
97
- onClick = ${ onPress }
98
- class ="text-zinc-600 hover:underline hover:text-black underline-offset-4 ${ active
99
- ? "underline !text-black "
100
- : "" } "
101
- > ${ item . label } </ a
102
- >
121
+ return html `< li class =" w-fit " >
122
+ < a href =" # ${ item . key } " onClick = ${ onPress } class ="group text-zinc-600"
123
+ > ${ item . label }
124
+ < span
125
+ class ="block max-w-0 group- hover:max-w-full transition-all duration-500 h-0.5 bg-black ${ active
126
+ ? "max-w-full !bg-zinc-600 "
127
+ : "" } "
128
+ > </ span >
129
+ </ a >
103
130
</ li > ` ;
104
131
}
105
132
0 commit comments