strudel/website/src/pages/swatch/list.json.js
2023-01-01 11:34:11 +00:00

16 lines
420 B
JavaScript

export function getMyPatterns() {
const my = import.meta.glob('../../../../my-patterns/**', { as: 'raw', eager: true });
return Object.fromEntries(
Object.entries(my) //
.filter(([name]) => name.endsWith('.txt')) //
.map(([name, raw]) => [name.split('/').slice(-1), raw]), //
);
}
export async function get() {
const all = await getMyPatterns();
return {
body: JSON.stringify(all),
};
}