Skip to content

Commit

Permalink
Set sitemap content type to xml
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Kuzyakov committed Aug 3, 2023
1 parent 13a0940 commit 5947152
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 10 deletions.
11 changes: 9 additions & 2 deletions functions/sitemap/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export async function onRequest({ request, next, env }) {
return new Response(`<?xml version="1.0" encoding="UTF-8"?>
return new Response(
`<?xml version="1.0" encoding="UTF-8"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<sitemap>
<loc>https://near.social/sitemap/posts/0</loc>
Expand All @@ -13,5 +14,11 @@ export async function onRequest({ request, next, env }) {
<sitemap>
<loc>https://near.social/sitemap/sources/</loc>
</sitemap>
</sitemapindex>`);
</sitemapindex>`,
{
headers: {
"content-type": "application/xml;charset=UTF-8",
},
}
);
}
11 changes: 9 additions & 2 deletions functions/sitemap/posts/[index].js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ export async function onRequest({ request, env, next }) {
}
const offset = parseInt(parts[3]);

return new Response(`<?xml version="1.0" encoding="UTF-8"?>
return new Response(
`<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${await generateSitemapPosts(env, offset)}
</urlset>`);
</urlset>`,
{
headers: {
"content-type": "application/xml;charset=UTF-8",
},
}
);
}
11 changes: 9 additions & 2 deletions functions/sitemap/profiles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,15 @@ export const generateSitemapProfiles = async (env) => {
};

export async function onRequest({ env }) {
return new Response(`<?xml version="1.0" encoding="UTF-8"?>
return new Response(
`<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${await generateSitemapProfiles(env)}
</urlset>`);
</urlset>`,
{
headers: {
"content-type": "application/xml;charset=UTF-8",
},
}
);
}
11 changes: 9 additions & 2 deletions functions/sitemap/sources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ export const generateSitemapSources = async (env) => {
};

export async function onRequest({ env }) {
return new Response(`<?xml version="1.0" encoding="UTF-8"?>
return new Response(
`<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${await generateSitemapSources(env)}
</urlset>`);
</urlset>`,
{
headers: {
"content-type": "application/xml;charset=UTF-8",
},
}
);
}
11 changes: 9 additions & 2 deletions functions/sitemap/widgets/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,15 @@ export const generateSitemapWidgets = async (env) => {
};

export async function onRequest({ env }) {
return new Response(`<?xml version="1.0" encoding="UTF-8"?>
return new Response(
`<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
${await generateSitemapWidgets(env)}
</urlset>`);
</urlset>`,
{
headers: {
"content-type": "application/xml;charset=UTF-8",
},
}
);
}

0 comments on commit 5947152

Please sign in to comment.