File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ window.addEventListener("popstate", e => {
118118/* -------------------- Initialization -------------------- */
119119
120120// Fetch posts and initialize the page
121- fetch ( "/posts/metadata/entries.json" )
121+ fetch ( ". /posts/metadata/entries.json" )
122122 . then ( response => response . json ( ) )
123123 . then ( data => {
124124 posts = data ;
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ document.addEventListener("DOMContentLoaded", () => {
2323
2424 // load existing
2525 fetch ( `/api/comments?slug=${ slug } ` )
26- . then ( r => r . json ( ) )
26+ . then ( r => r . ok ? r . json ( ) : [ ] )
2727 . then ( arr => {
2828 if ( ! arr . length ) {
2929 commentsList . innerHTML =
Original file line number Diff line number Diff line change 1- import jsYaml from 'js-yaml' ;
2-
31function parseFrontMatter ( md ) {
42 const re = / ^ - - - \r ? \n ( [ \s \S ] + ?) \r ? \n - - - (?: \r ? \n | $ ) / ;
53 const m = re . exec ( md ) ;
@@ -29,7 +27,7 @@ if (!content) {
2927 throw new Error ( "Required DOM element not found." ) ;
3028}
3129
32- fetch ( `/posts/entries/${ slug } .md` )
30+ fetch ( `. /posts/entries/${ slug } .md` )
3331 . then ( r => r . text ( ) )
3432 . then ( md => {
3533 const { meta, body } = parseFrontMatter ( md ) ;
Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ function createLanguageBar(languages) {
3737async function fetchLanguages ( repo ) {
3838 if ( langCache . has ( repo ) ) return langCache . get ( repo ) ;
3939
40- const resp = await fetch ( `/api/github-languages?repo=${ repo } ` ) ;
40+ const url = `https://api.github.com/repos/${ repo } /languages` ;
41+ const resp = await fetch ( url ) ;
42+
4143 if ( ! resp . ok ) {
4244 console . warn ( `Could not load languages for ${ repo } : ${ resp . status } ` ) ;
4345 langCache . set ( repo , { } ) ;
Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ <h3>Add a Comment</h3>
5555 < script src ="js/mathjax.js "> </ script >
5656 < script src ="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js " async > </ script >
5757 < script type ="module " src ="js/header-footer.js "> </ script >
58+ < script src ="https://cdn.jsdelivr.net/npm/js-yaml@4/dist/js-yaml.min.js "> </ script >
5859 < script type ="module " src ="js/post.js "> </ script >
5960 < script src ="js/comments.js "> </ script >
6061</ body >
You can’t perform that action at this time.
0 commit comments