Skip to content

Commit 0351d33

Browse files
committed
Fix: Add fallback to GitHub raw content when local content fails
- If loading from docs/content/ fails, automatically fall back to GitHub raw content URL - Handles edge cases where GitHub Pages may not serve files with certain special characters - Ensures all files load successfully regardless of filename
1 parent 46b85c7 commit 0351d33

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

docs/app.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,16 @@ async function loadFile(path, meta = {}) {
113113
codeBlock.className = languageClass ? `language-${languageClass}` : "";
114114

115115
try {
116-
const response = await fetch(fileUrlForPath(path));
116+
let url = fileUrlForPath(path);
117+
let response = await fetch(url);
118+
119+
// If local content fails, fall back to GitHub raw content
120+
if (!response.ok && state.useLocalContent) {
121+
const encoded = encodePath(path);
122+
url = `https://raw.githubusercontent.com/${state.repoOwner}/${state.repoName}/${state.branch}/${encoded}`;
123+
response = await fetch(url);
124+
}
125+
117126
if (!response.ok) {
118127
throw new Error(`Failed to fetch ${path}`);
119128
}

0 commit comments

Comments
 (0)