From 1166cf38980dc81a509d526639b4f66968f4216d Mon Sep 17 00:00:00 2001 From: Shinichi Okada <147320+shinokada@users.noreply.github.com> Date: Tue, 21 May 2024 18:37:56 +0200 Subject: [PATCH] feat: add sitemap --- src/routes/sitemap.xml/+server.ts | 90 +++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 src/routes/sitemap.xml/+server.ts diff --git a/src/routes/sitemap.xml/+server.ts b/src/routes/sitemap.xml/+server.ts new file mode 100644 index 0000000..2c4f9b7 --- /dev/null +++ b/src/routes/sitemap.xml/+server.ts @@ -0,0 +1,90 @@ +const site = 'https://flowbite-svelte-blocks.codewithshin.com/'; +const pages: string[] = [ + '', + 'application', + 'application/advanced-tables', + 'application/crud-create-drwawers', + 'application/crud-create-forms', + 'application/crud-create-modals', + 'application/crud-delete-confirm', +'application/crud-read-drawers', +'application/crud-read-modals', +'application/crud-read-sections', +'application/crud-success-message', +'application/crud-update-drawers', +'application/crud-update-forms', +'application/crud-update-modals', +'application/dashboard-footer', +'application/faceted-search-drawers', +'application/faceted-search-modals', +'application/filter', +'application/navbar', +'application/sidenav', +'application/table-footers', +'application/table-headers', +'example', +'marketing', +'marketing/404', +'marketing/500', +'marketing/account-recovery', +'marketing/banner', +'marketing/blog', +'marketing/contact', +'marketing/content', +'marketing/cookie', +'marketing/cta', +'marketing/customer-logos', +'marketing/event-schedule', +'marketing/faq', +'marketing/feature', +'marketing/footer', +'marketing/header', +'marketing/hero', +'marketing/login', +'marketing/maintenance', +'marketing/newsletter', +'marketing/popup', +'marketing/portfolio', +'marketing/pricing', +'marketing/register', +'marketing/reset-password', +'marketing/social-proof', +'marketing/team', +'marketing/testimonial', +'marketing/user-onboarding', +'quickstart', +'publisher/blog-templates', +'publisher/comments', +'publisher/related-articles', +]; + +/** @type {import('./$types').RequestHandler} */ +export async function GET({ url }) { + const body = sitemap(pages); + const response = new Response(body); + response.headers.set('Cache-Control', 'max-age=0, s-maxage=3600'); + response.headers.set('Content-Type', 'application/xml'); + return response; +} + +const sitemap = (pages: string[]) => ` + + ${pages + .map( + (page) => ` + + ${site}/${page} + daily + 0.5 + + ` + ) + .join('')} +`; \ No newline at end of file