Skip to content

Commit f31a584

Browse files
committed
js script update
1 parent ddebca2 commit f31a584

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

assets/js/script.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ function parseURL() {
188188

189189
// Function to update meta tags dynamically
190190
async function fetchRepoTree() {
191+
// Check if this is a static page that should prevent fetching
192+
if (window.preventRepoFetch === true) {
193+
console.log("Static page detected - skipping API fetch");
194+
return;
195+
}
196+
191197
const repoInputVal = repoInput.value.trim();
192198
const branch = branchInput.value.trim() || 'main';
193199

@@ -198,7 +204,7 @@ async function fetchRepoTree() {
198204
updateMetaData(
199205
'GitHub repo explorer: visualize and navigate github project structures', // Title
200206
'Effortlessly explore and visualize the file structure of any public GitHub repository online. Navigate project folders, view directory trees, and copy paths without cloning.', // Description
201-
'/' // Canonical back to homepage
207+
'/'
202208
);
203209
return;
204210
}

assets/js/static-repo.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// This script is loaded on statically-generated repository pages
2+
// It prevents the automatic API fetch that would normally happen
3+
4+
document.addEventListener('DOMContentLoaded', function() {
5+
// Override the fetchRepoTree function to prevent API calls on static pages
6+
window.preventRepoFetch = true;
7+
8+
// Add a meta indicator that this is a pre-generated page (for debugging)
9+
const meta = document.createElement('meta');
10+
meta.name = 'static-page';
11+
meta.content = 'true';
12+
document.head.appendChild(meta);
13+
});

0 commit comments

Comments
 (0)