I have code like this
import fs from 'fs';
import { promisify } from 'util';
import type { SvelteComponent } from 'svelte';
const readdir = promisify(fs.readdir);
export async function getAllPosts() {
const files = (await readdir(`src/data/posts`)).map((i) => i.replace(/.svx$/, ''));
return files;
}
and my server route
import { getAllPosts } from '../../lib/blog';
export async function get() {
return { body: await getAllPosts() };
}
and it works fine in development, but it doesn't work in production on netlify, because there isn't really a src/data/posts directory anymore. How can I get sveltekit to generate this array at buildtime?
I have tried using the static adaptor but it doesn't generate the routes properly becuase although there are links to all the pages on the site, they aren't generated right away. So I think I have to go with the netlify adapter.