improve SEO on UGC, proxy S3

This commit is contained in:
Face 2025-06-28 17:31:05 +03:00
parent 6e4e8a4eaa
commit 107c78a5f2
13 changed files with 149 additions and 34 deletions

View file

@ -0,0 +1,31 @@
import { error } from '@sveltejs/kit';
export async function load({ params, fetch }) {
const questionId = parseInt(params.id);
if (isNaN(questionId)) {
throw error(400, 'Invalid question ID');
}
try {
const response = await fetch(`/api/hopium/questions/${questionId}`);
if (!response.ok) {
if (response.status === 404) {
throw error(404, 'Question not found');
}
throw error(500, 'Failed to load question');
}
const result = await response.json();
return {
questionId,
question: result.question || result,
probabilityData: result.probabilityHistory || []
};
} catch (e) {
console.error('Failed to fetch question:', e);
throw error(500, 'Failed to load question');
}
}

View file

@ -28,9 +28,10 @@
import type { PredictionQuestion } from '$lib/types/prediction';
import HopiumQuestionSkeleton from '$lib/components/self/skeletons/HopiumQuestionSkeleton.svelte';
let question = $state<PredictionQuestion | null>(null);
let loading = $state(true);
let probabilityData = $state<any[]>([]);
const { data } = $props();
let question = $state(data.question);
let loading = $state(false);
let probabilityData = $state(data.probabilityData);
// Betting form
let betSide = $state<boolean>(true);
@ -38,7 +39,7 @@
let customBetAmount = $state('');
let userBalance = $derived($PORTFOLIO_SUMMARY ? $PORTFOLIO_SUMMARY.baseCurrencyBalance : 0);
let questionId = $derived(parseInt(page.params.id));
let questionId = $derived(data.questionId);
// Chart related
let chartContainer = $state<HTMLDivElement>();
@ -46,7 +47,6 @@
let lineSeries: any = null;
onMount(() => {
fetchQuestion();
if ($USER_DATA) {
fetchPortfolioSummary();
}
@ -54,6 +54,7 @@
async function fetchQuestion() {
try {
loading = true;
const response = await fetch(`/api/hopium/questions/${questionId}`);
if (response.ok) {
const result = await response.json();