Spaces:
Running
Running
const getAllModels = async () => { | |
const response = await fetch("https://lorastudio.co/api/models/sitemap", { | |
method: "GET", | |
headers: { | |
"Content-Type": "application/json" | |
} | |
}) | |
const models = await response.json() | |
return models.cards | |
}; | |
export async function GET() { | |
const models = await getAllModels() | |
return new Response( | |
` | |
<?xml version="1.0" encoding="UTF-8" ?> | |
<urlset | |
xmlns="https://www.sitemaps.org/schemas/sitemap/0.9" | |
xmlns:xhtml="https://www.w3.org/1999/xhtml" | |
xmlns:mobile="https://www.google.com/schemas/sitemap-mobile/1.0" | |
xmlns:news="https://www.google.com/schemas/sitemap-news/0.9" | |
xmlns:image="https://www.google.com/schemas/sitemap-image/1.1" | |
xmlns:video="https://www.google.com/schemas/sitemap-video/1.1" | |
> | |
<url> | |
<loc>https://lorastudio.co/</loc> | |
<lastmod>${new Date().toISOString()}</lastmod> | |
</url> | |
${models | |
.map( | |
(model) => | |
` | |
<url> | |
<loc>https://lorastudio.co/models/${model.id}</loc> | |
<lastmod>${new Date(model.createdAt).toISOString()}</lastmod> | |
</url> | |
` | |
) | |
.join("")} | |
<!-- <url> elements go here --> | |
</urlset>`.trim(), | |
{ | |
headers: { | |
'Content-Type': 'application/xml' | |
} | |
} | |
); | |
} |