mirror of
https://github.com/juherr/kill-the-news.git
synced 2026-06-21 06:13:48 +00:00
feat(websub): add hub discovery Link headers to RSS and Atom feeds
This commit is contained in:
@@ -51,11 +51,17 @@ export async function handle(c: Context): Promise<Response> {
|
|||||||
const baseUrl = `https://${env.DOMAIN}`;
|
const baseUrl = `https://${env.DOMAIN}`;
|
||||||
const atomXml = generateAtomFeed(feedConfig, emailsData, baseUrl, feedId);
|
const atomXml = generateAtomFeed(feedConfig, emailsData, baseUrl, feedId);
|
||||||
|
|
||||||
|
const linkHeader = [
|
||||||
|
`<https://${env.DOMAIN}/hub>; rel="hub"`,
|
||||||
|
`<https://${env.DOMAIN}/atom/${feedId}>; rel="self"`,
|
||||||
|
].join(", ");
|
||||||
|
|
||||||
return new Response(atomXml, {
|
return new Response(atomXml, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/atom+xml",
|
"Content-Type": "application/atom+xml",
|
||||||
"Cache-Control": "max-age=1800",
|
"Cache-Control": "max-age=1800",
|
||||||
|
Link: linkHeader,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@@ -65,11 +65,17 @@ export async function handle(c: Context): Promise<Response> {
|
|||||||
const rssXml = generateRssFeed(feedConfig, emailsData, baseUrl, feedId);
|
const rssXml = generateRssFeed(feedConfig, emailsData, baseUrl, feedId);
|
||||||
|
|
||||||
// Return the RSS feed with appropriate content type
|
// Return the RSS feed with appropriate content type
|
||||||
|
const linkHeader = [
|
||||||
|
`<https://${env.DOMAIN}/hub>; rel="hub"`,
|
||||||
|
`<https://${env.DOMAIN}/rss/${feedId}>; rel="self"`,
|
||||||
|
].join(", ");
|
||||||
|
|
||||||
return new Response(rssXml, {
|
return new Response(rssXml, {
|
||||||
status: 200,
|
status: 200,
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/rss+xml",
|
"Content-Type": "application/rss+xml",
|
||||||
"Cache-Control": "max-age=1800", // 30 minutes cache
|
"Cache-Control": "max-age=1800", // 30 minutes cache
|
||||||
|
Link: linkHeader,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user