Add RSS feed to footer and page. Fix #8

v1.1.0
Max Nuding 2023-04-05 16:57:25 +02:00
parent d723d4264a
commit 4d689a86ab
Signed by: phlaym
GPG Key ID: A06651BAB6777237
7 changed files with 17 additions and 6 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
*.db
feed.xml
node_modules
/build

View File

@ -7,6 +7,7 @@
<meta name="viewport" content="width=device-width" />
<meta name="theme-color" content="#17063B" media="(prefers-color-scheme: dark)" />
<meta name="theme-color" content="#ffffff" media="(prefers-color-scheme: light)" />
<link rel="alternate" type="application/atom+xml" href="/feed.xml" title="Atom Feed" />
%sveltekit.head%
<style>
body {

View File

@ -18,8 +18,8 @@ export const handleError = (({ error }) => {
import type { Handle } from '@sveltejs/kit';
export const handle = (async ({ event, resolve }) => {
if (event.url.pathname === '/feed.atom') {
const f = await fs.readFile('feed.atom', { encoding: 'utf8' });
if (event.url.pathname === '/feed.xml') {
const f = await fs.readFile('feed.xml', { encoding: 'utf8' });
return new Response(
f,
{ headers: [['Content-Type', 'application/atom+xml']] }

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24"><path d="M3 3C12.9411 3 21 11.0589 21 21H18C18 12.7157 11.2843 6 3 6V3ZM3 10C9.07513 10 14 14.9249 14 21H11C11 16.5817 7.41828 13 3 13V10ZM3 17C5.20914 17 7 18.7909 7 21H3V17Z" fill="#000"></path></svg>

After

Width:  |  Height:  |  Size: 285 B

View File

@ -1,5 +1,6 @@
<script>
import git from '$lib/assets/git-branch-fill.svg';
import rss from '$lib/assets/rss-fill.svg';
</script>
<div class="footer">
@ -11,7 +12,14 @@
<div>
<a href="https://phlaym.net/git/phlaym/moshing-mammut">
<img alt="Git branch" src={git} class="icon" />
Source Code&nbsp;
Source Code
</a>
</div>
|
<div>
<a href="/feed.xml">
<img alt="RSS" src={rss} class="icon" />
RSS Feed
</a>
</div>
</div>

View File

@ -17,7 +17,7 @@ export function createFeed(posts: Post[]): Feed {
copyright: '',
generator: 'moshing-mamut',
feedLinks: {
atom: `${BASE_URL}/feed.atom`
atom: `${BASE_URL}/feed.xml`
},
author: {
name: '@aymm',
@ -41,5 +41,5 @@ export function createFeed(posts: Post[]): Feed {
return feed;
}
export async function saveAtomFeed(feed: Feed) {
await fs.writeFile('feed.atom', feed.atom1(), { encoding: 'utf8' });
await fs.writeFile('feed.xml', feed.atom1(), { encoding: 'utf8' });
}

View File

@ -78,7 +78,7 @@ export class TimelineReader {
if (found_urls.length === 0 &&
found_tags.length === 0 &&
!await TimelineReader.checkYoutubeMatches(post.content)) {
//return;
return;
}
await savePost(post);
const posts = await getPosts(null, null, 100);