Hey, the page switches languages. However, check out this error:
[vite:dev] TypeError: Cannot read properties of undefined (reading 'data')
[vite:dev] at C:\Users\janis\screen-website\src\lib\components\ProgressBar.svelte:5:38
[vite:dev] at Object.$$render (C:\Users\janis\screen-website\node_modules\svelte\src\runtime\internal\ssr.js:156:16)
[vite:dev] at eval (C:/Users/janis/screen-website/src/routes/+layout.svelte:77:140)
[vite:dev] at Object.$$render (C:\Users\janis\screen-website\node_modules\svelte\src\runtime\internal\ssr.js:156:16)
[vite:dev] at C:\Users\janis\screen-website.svelte-kit\generated\root.svelte:44:40
[vite:dev] at $$render (C:\Users\janis\screen-website\node_modules\svelte\src\runtime\internal\ssr.js:156:16)
[vite:dev] at Object.render (C:\Users\janis\screen-website\node_modules\svelte\src\runtime\internal\ssr.js:164:17)
[vite:dev] at Module.render_response (C:\Users\janis\screen-website\node_modules@sveltejs\kit\src\runtime\server\page\render.js:171:29)
[vite:dev] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[vite:dev] at async Module.render_page (C:\Users\janis\screen-website\node_modules@sveltejs\kit\src\runtime\server\page\index.js:234:15)
[vite:dev] {
[vite:dev] error: { message: 'Internal Error' },
[vite:dev] params: { uid: 'favicon.ico' },
[vite:dev] route: { id: '/[[preview=preview]]/[uid]' },
[vite:dev] status: 500,
[vite:dev] url: URL {
[vite:dev] href: 'http://localhost:5173/favicon.ico',
[vite:dev] origin: 'http://localhost:5173',
[vite:dev] protocol: 'http:',
[vite:dev] username: '',
[vite:dev] password: '',
[vite:dev] host: 'localhost:5173',
[vite:dev] hostname: 'localhost',
[vite:dev] port: '5173',
[vite:dev] pathname: '/favicon.ico',
[vite:dev] search: '',
[vite:dev] searchParams: URLSearchParams {},
[vite:dev] hash: ''
[vite:dev] },
[vite:dev] data: {},
[vite:dev] form: null,
[vite:dev] state: {}
[vite:dev] }
src\routes[[preview=preview]][lang=lang]+page.server.js
import { asText } from '@prismicio/client';
import { createClient } from '$lib/prismicio';
// @ts-ignore
export async function load({ fetch, cookies, params }) {
const client = createClient({ fetch, cookies });
let settings, nav, errors, social;
const page = await client.getByUID('page', 'accueil', {
lang: params.lang
});
nav = await client.getSingle('navigation', {
lang: params.lang || 'fr-ca'
});
settings = await client.getSingle('settings', {
lang: params.lang || 'fr-ca'
});
errors = await client.getSingle('errors', {
lang: params.lang || 'fr-ca'
});
social = await client.getSingle('socials', {
lang: params.lang || 'fr-ca'
});
return {
page,
nav,
settings,
errors,
social,
title: asText(page.data.title),
meta_description: page.data.meta_description,
meta_title: page.data.meta_title,
meta_image: page.data.meta_image.url
};
}
export function entries() {
return [{}];
}
Is it me or is the lang parameter catching favicon so when I am on my http://localhost:5173/ everything works, but when on the http://localhost:5173/en-us/home I get these errors since it doesn't get the correct parameter. This happend since I added the data that I was fetching from my +layout.server file before.