mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-05-15 19:54:27 -04:00
refactor note processing functions
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
import { cache } from "react";
|
||||
import { Feed } from "feed";
|
||||
import { getAllPosts, getPostContent } from "./posts";
|
||||
import { getFrontMatter, getContent } from "./posts";
|
||||
import * as config from "../config";
|
||||
import { BASE_URL } from "../config/constants";
|
||||
|
||||
import ogImage from "../../app/opengraph-image.jpg";
|
||||
|
||||
/**
|
||||
* Returns a `Feed` object, which can then be processed with `feed.rss2()`, `feed.atom1()`, or `feed.json1()`.
|
||||
* @see https://github.com/jpmonette/feed#example
|
||||
*/
|
||||
export const buildFeed = cache(async (): Promise<Feed> => {
|
||||
// https://github.com/jpmonette/feed#example
|
||||
const feed = new Feed({
|
||||
id: BASE_URL,
|
||||
link: BASE_URL,
|
||||
@@ -28,8 +31,8 @@ export const buildFeed = cache(async (): Promise<Feed> => {
|
||||
});
|
||||
|
||||
// add posts separately using their frontmatter
|
||||
const posts = await getAllPosts();
|
||||
for (const post of posts.reverse()) {
|
||||
const posts = await getFrontMatter();
|
||||
for (const post of posts) {
|
||||
feed.addItem({
|
||||
guid: post.permalink,
|
||||
link: post.permalink,
|
||||
@@ -42,7 +45,10 @@ export const buildFeed = cache(async (): Promise<Feed> => {
|
||||
},
|
||||
],
|
||||
date: new Date(post.date),
|
||||
content: `${await getPostContent(post.slug)}\n\n<p><a href="${post.permalink}"><strong>Continue reading...</strong></a></p>`,
|
||||
content: `
|
||||
${await getContent(post.slug)}
|
||||
<p><a href="${post.permalink}"><strong>Continue reading...</strong></a></p>
|
||||
`.trim(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user