(This is just for my understanding)
If I have json file that contains array of data is it possible to generate html page for each entry/object of the array?
The json file is static and it is located under the src folder:
//+page.js
import snippets from '../../../data/product_data.json';
export async function load({ params }) {
const { slug } = params;
return snippets.filter((s) => s.name == slug)[0];
}
//+page.svelte
<script>
export const prerender = true;
export let data;
</script>
<div>{data.name}</div>
//svelte.config.js
import adapter from '@sveltejs/adapter-static';
/** @type {import('@sveltejs/kit').Config} */
const config = {
kit: {
adapter: adapter({ precompress: true, fallback: 'index.html' })
}
};
export default config;
