@@ -415,8 +415,10 @@ document.addEventListener('DOMContentLoaded', () => {
415415
416416// CARD OF THE DAY //
417417( function ( ) {
418- const GRAPH_PATH = "website/assets/json/smtGraph.jsonld" ;
419- const TEXTS_PATH = "website/assets/json/texts.json" ;
418+ const isRoot = ! window . location . pathname . includes ( '/website/' ) ;
419+ const basePath = isRoot ? 'website/' : '' ;
420+ const GRAPH_PATH = `${ basePath } assets/json/smtGraph.jsonld` ;
421+ const TEXTS_PATH = `${ basePath } assets/json/texts.json` ;
420422
421423 // ----- Constants for Mapping -----
422424 const MAJOR_NUMBER_MAP = {
@@ -482,7 +484,9 @@ document.addEventListener('DOMContentLoaded', () => {
482484 function githubUrlToLocal ( url ) {
483485 const marker = "website/" ;
484486 const idx = url . indexOf ( marker ) ;
485- return idx !== - 1 ? url . slice ( idx ) : url ;
487+ let path = idx !== - 1 ? url . slice ( idx + marker . length ) : url ;
488+ if ( path . startsWith ( '/' ) ) path = path . slice ( 1 ) ;
489+ return `${ basePath } ${ path } ` ;
486490 }
487491
488492 function graphIdToCardParam ( graphId ) {
@@ -532,6 +536,8 @@ document.addEventListener('DOMContentLoaded', () => {
532536 }
533537
534538 async function loadCardOfTheDay ( ) {
539+ if ( ! document . getElementById ( "dailyCardImage" ) ) return ;
540+
535541 try {
536542 const [ graphResponse , textsResponse ] = await Promise . all ( [
537543 fetch ( GRAPH_PATH ) ,
@@ -570,7 +576,7 @@ document.addEventListener('DOMContentLoaded', () => {
570576 const title = selected . title || "Tarot Card" ;
571577 const localImg = githubUrlToLocal ( selected . image_url ?. [ "@id" ] || "" ) ;
572578 const cardParam = graphIdToCardParam ( selected [ "@id" ] || "" ) ;
573- const cardLink = `website/ card.html?id=${ cardParam } ` ;
579+ const cardLink = `${ basePath } card.html?id=${ cardParam } ` ;
574580
575581 // Update DOM
576582 const imgEl = document . getElementById ( "dailyCardImage" ) ;
@@ -598,7 +604,7 @@ document.addEventListener('DOMContentLoaded', () => {
598604 The mundane mirrored. <br>Explore the <span class="highlight">four suits</span> and their meanings.
599605 </h3>
600606 </div>
601- <a href="website/ deepening.html?id=suits_page" id="dailyCardDiscoverMore" class="discover-more">
607+ <a href="${ basePath } deepening.html?id=suits_page" id="dailyCardDiscoverMore" class="discover-more">
602608 <span class="discover-svg">
603609 <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" fill="currentColor" viewBox="0 0 16 16">
604610 <circle cx="4" cy="8" r="1.5"/><circle cx="8" cy="8" r="1.5"/><circle cx="12" cy="8" r="1.5"/>
@@ -628,7 +634,7 @@ document.addEventListener('DOMContentLoaded', () => {
628634 evolutionCards . forEach ( evo => {
629635 const evoImg = githubUrlToLocal ( evo . image_url ?. [ "@id" ] || "" ) ;
630636 const evoParam = graphIdToCardParam ( evo [ "@id" ] || "" ) ;
631- const evoUrl = `website/ card.html?id=${ evoParam } ` ;
637+ const evoUrl = `${ basePath } card.html?id=${ evoParam } ` ;
632638 evoHtml += `
633639 <div class="mini-card-thumb">
634640 <a href="${ evoUrl } ">
@@ -639,7 +645,7 @@ document.addEventListener('DOMContentLoaded', () => {
639645 } ) ;
640646
641647 const archetypeParam = archetypeId ? graphIdToCardParam ( archetypeId ) : "" ;
642- const archetypeLink = archetypeParam ? `website/ deepening.html?id=${ archetypeParam } ` : cardLink ;
648+ const archetypeLink = archetypeParam ? `${ basePath } deepening.html?id=${ archetypeParam } ` : cardLink ;
643649
644650 rightColHtml = `
645651 <div class="evolution-frame compact-evolution mt-0 mx-0">
0 commit comments