Skip to content

Commit

Permalink
attempt at fixing paths for GHP
Browse files Browse the repository at this point in the history
  • Loading branch information
GitPaulo committed Aug 11, 2024
1 parent e8f71a2 commit 20e07f8
Show file tree
Hide file tree
Showing 4 changed files with 1,068 additions and 1,057 deletions.
2 changes: 1 addition & 1 deletion src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ body {
left: 0;
right: 0;
bottom: 0;
background: url('background.jpg') no-repeat center center;
background: url('./background.jpg') no-repeat center center;
background-size: cover;
opacity: 0.9;
z-index: 1;
Expand Down
19 changes: 14 additions & 5 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import "../app.css";
import { base } from "$app/paths";
import type { Quest, Quests } from "$lib/model";
export let data: { quests: Promise<Quests>; loading: boolean };
Expand Down Expand Up @@ -127,9 +128,16 @@
function getImageUrl(imagePath: string | null): string {
const placeholderImage = "/default_quest_image.png";
return imagePath
? `https://beta.xivapi.com/api/1/asset/${imagePath}?format=png`
: placeholderImage;
if (!imagePath || imagePath.trim() === "") {
return placeholderImage;
}
try {
// Validate that there is an image path
new URL(imagePath);
return `https://beta.xivapi.com/api/1/asset/${imagePath}?format=png`;
} catch {
return placeholderImage;
}
}
function handleCheckboxChange(event: Event, quest: Quest) {
Expand All @@ -139,8 +147,9 @@
function updateBackground(): void {
const bgImage = currentExpansion
? `/background_${currentExpansion.replace(/\s/g, "").toLowerCase()}.jpg`
: "/background.jpg";
? `${base}/background_${currentExpansion.replace(/\s/g, "").toLowerCase()}.jpg`
: `${base}/background.jpg`;
const bgElement = document.getElementById("background");
if (bgElement) {
bgElement.style.backgroundImage = `url('${bgImage}')`;
Expand Down
4 changes: 3 additions & 1 deletion src/routes/+page.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
export const ssr = false
export const prerender = true

import { base } from '$app/paths';

export async function load({ fetch }) {
return {
loading: true,
// TODO: There is 100% a better way to do this but I'm new to sveltekit
quests: fetch("/Quests.json").then(async (response) => {
quests: fetch(`${base}/Quests.json`).then(async (response) => {
if (!response.ok) {
throw new Error(`Failed to fetch quests: ${response.status}`);
}
Expand Down
Loading

0 comments on commit 20e07f8

Please sign in to comment.