1document.addEventListener("DOMContentLoaded", function() { 2 // Map of URL path patterns to repository names 3 const repoMap = { 4 'hed-python/': 'hed-python', 5 'hed-schemas/': 'hed-schemas', 6 'hed-matlab/': 'hed-matlab', 7 'hed-javascript/': 'hed-javascript', 8 'hed-mcp/': 'hed-mcp', 9 'hed-server/': 'hed-server', 10 'hed-vis/': 'hed-vis', 11 'ndx-hed/': 'ndx-hed', 12 'table-remodeler/': 'table-remodeler', 13 'CTagger/': 'CTagger', 14 'hed-specification/': 'hed-specification', 15 'hed-tests/': 'hed-tests', 16 'hed-task/': 'hed-task' 17 }; 18 19 // Function to determine which repository we're currently viewing 20 function getCurrentRepo() { 21 const currentPath = window.location.pathname; 22 23 // Check if path contains any submodule identifier 24 for (const [pathPattern, repoName] of Object.entries(repoMap)) { 25 if (currentPath.includes(pathPattern)) { 26 return repoName; 27 } 28 } 29 30 // Default to hed-resources if not in a submodule 31 return 'hed-resources'; 32 } 33 34 // Function to determine repository from the link's own href 35 function getRepoFromHref(href) { 36 // Extract the repository name from the GitHub URL 37 // Example: https://github.com/hed-standard/hed-resources/blob/main/docs/source/hed-python/... 38 const match = href.match(/github\.com\/hed-standard\/([^\/]+)/); 39 if (!match) { 40 return null; 41 } 42 43 const repoInHref = match[1]; 44 45 // If the href points to hed-resources but contains a submodule path, extract the correct repo 46 if (repoInHref === 'hed-resources') { 47 // Check if the path contains a submodule directory 48 for (const [pathPattern, repoName] of Object.entries(repoMap)) { 49 const sourcePattern = `/docs/source/${pathPattern}`; 50 if (href.includes(sourcePattern)) { 51 return repoName; 52 } 53 } 54 return repoInHref; 55 } 56 57 // For non-hed-resources repos (direct links to other repos), return the detected repo 58 return repoInHref; 59 } 60 61 // Function to fix the icons 62 function fixGitHubIcons() { 63 const currentRepo = getCurrentRepo(); 64 65 // Furo puts icons in .content-icon-container 66 // We look for links that point to GitHub 67 const links = document.querySelectorAll(".content-icon-container a"); 68 69 links.forEach((link, index) => { 70 const href = link.getAttribute("href"); 71 if (!href) return; 72 73 // Check if it's a GitHub link (edit or blob/view) 74 if (href.includes("github.com")) { 75 // If it's the Edit link, hide it 76 if (href.includes("/edit/")) { 77 link.style.display = "none"; 78 link.classList.add("hidden-edit-link"); // Marker for CSS 79 } 80 // If it's the View/Blob link, hijack it 81 else if (href.includes("/blob/") || href.includes("/tree/")) { 82 // Determine the correct repo - prefer detection from href, fallback to currentRepo 83 const detectedRepo = getRepoFromHref(href) || currentRepo; 84 const repoUrl = `https://github.com/hed-standard/${detectedRepo}`; 85 86 // Change URL to the correct repo root based on detected repository 87 link.href = repoUrl; 88 link.title = `Go to ${detectedRepo} repository`; 89 link.setAttribute("aria-label", `Go to ${detectedRepo} repository`); 90 91 // Mark this link so CSS can style it as an icon-only GitHub link 92 // (e.g. hide any text/SVG content and show a custom background icon). 93 // The actual hiding of text/SVG is handled in CSS using the github-repo-link 94 link.classList.add("github-repo-link"); // Add class for CSS targeting 95 link.style.display = "inline-flex"; 96 } 97 } 98 }); 99 } 100 101 fixGitHubIcons(); 102});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.