Skip to content

Commit 09a017b

Browse files
committed
add support for atom feeds
1 parent b6cb960 commit 09a017b

File tree

5 files changed

+38
-31
lines changed

5 files changed

+38
-31
lines changed

index.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,17 @@ async function handleRequest(request) {
5555
response = new Response(content, {
5656
headers: {
5757
'content-type': 'application/rss+xml',
58-
'Cache-Control': 'max-age=3600',
58+
'Cache-Control': `max-age=${cacheMaxAge}`,
59+
},
60+
})
61+
} else if (path === '/atom') {
62+
let content = await WORKER_PLANET_STORE.get('atom')
63+
response = new Response(content, {
64+
headers: {
65+
'content-type': 'application/atom+xml',
66+
'Cache-Control': `max-age=${cacheMaxAge}`,
5967
},
6068
})
61-
// } else if (path === '/atom') {
62-
// let content = await WORKER_PLANET_STORE.get('atom')
63-
// response = new Response(content)
6469
} else {
6570
return new Response('', { status: 404 })
6671
}
@@ -118,7 +123,7 @@ async function handleScheduled() {
118123
let html = createHTML(content, sources)
119124
// Store
120125
await WORKER_PLANET_STORE.put('rss', feed.rss2())
121-
//await WORKER_PLANET_STORE.put('atom', feed.atom1())
126+
await WORKER_PLANET_STORE.put('atom', feed.atom1())
122127
await WORKER_PLANET_STORE.put('html', html)
123128
}
124129

templates/default.handlebars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<meta property="og:description" content="{{page_description}}" />
1111
<meta http-equiv="Content-Security-Policy" content="script-src https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js; style-src https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css 'sha256-G3Hryz5a3r//doprn3mQdVn71SMV/Wb1C6hMehrBGnk=';" />
1212
<link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" />
13+
<link rel="alternate" type="application/atom+xml" title="Planet Atom feed" href="/atom" />
1314
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
1415
integrity="sha384-+0n0xVW2eSR5OomGNYDnhzAbDsOXxcvSN1TPprVMTNDbiYZCxYbOOl7+AMvyTG2x" crossorigin="anonymous" />
1516
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"

templates/default.precompiled.js

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/headlines.handlebars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<meta property="og:description" content="{{page_description}}" />
1010
<meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-hashes' 'sha256-2drSom6Fplo+OFvNUVKnb+wZyrq6v1lOEkVaexi/Fw4=' 'sha256-JeTyInHTbNelTT9AfPH8MBCkB4sU4yMQjoaIQNeLIZ8='; style-src https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css;" />
1111
<link rel="alternate" type="application/rss+xml" title="Planet RSS feed" href="/rss" />
12+
<link rel="alternate" type="application/atom+xml" title="Planet Atom feed" href="/atom" />
1213
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@picocss/pico@1/css/pico.min.css">
1314
</head>
1415
<body>

0 commit comments

Comments
 (0)