File tree Expand file tree Collapse file tree 4 files changed +34
-5
lines changed
Expand file tree Collapse file tree 4 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 1616
1717 </ div >
1818 < script src ="./js/archive.js "> </ script >
19+ < script >
20+ function scrollToHash ( ) {
21+ if ( window . location . hash ) {
22+ const el = document . querySelector ( window . location . hash ) ;
23+ if ( el ) {
24+ el . scrollIntoView ( { behavior : "smooth" } ) ;
25+ return true ;
26+ }
27+ }
28+ return false ;
29+ }
30+ if ( ! scrollToHash ( ) ) {
31+ const observer = new MutationObserver ( ( ) => {
32+ if ( scrollToHash ( ) ) {
33+ observer . disconnect ( ) ;
34+ }
35+ } ) ;
36+ observer . observe ( document . body , { childList : true , subtree : true } ) ;
37+ }
38+ </ script >
39+
1940</ body >
2041</ html >
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ fetch('../blog-posts/posts.json').then(response => {
77 return response . json ( ) ;
88} ) . then ( data => {
99 let blogPosts = data . posts ;
10- console . log ( blogPosts ) ;
1110 let followingPosts = blogPosts . slice ( 1 ) ;
1211
1312 followingPosts . forEach ( post => {
@@ -30,6 +29,7 @@ fetch('../blog-posts/posts.json').then(response => {
3029 blogTitle . innerText = post [ "title" ] ;
3130 blogDate . innerText = post [ "date" ] ;
3231 blogSong . innerHTML = post [ "song" ] ;
32+ blogContent . id = post [ "id" ] ;
3333
3434 blogContent . appendChild ( blogTitle ) ;
3535 blogContent . appendChild ( blogDate ) ;
You can’t perform that action at this time.
0 commit comments