Revert "chore: fix feeds"

This reverts commit 29c6a2df7d.
This commit is contained in:
Cory Dransfeldt 2023-09-20 09:32:18 -07:00
parent 39ecabb8f7
commit 5e24c70091
No known key found for this signature in database
4 changed files with 10 additions and 11 deletions

View file

@ -1,29 +1,24 @@
const markdownIt = require('markdown-it')
const { URL } = require('url')
const BASE_URL = 'https://coryd.dev'
module.exports = {
normalizeEntries: (entries) => {
// md instance
const md = markdownIt({ html: true, linkify: true })
const posts = []
entries.forEach((entry) => {
const dateKey = Object.keys(entry).find((key) => key.includes('date'))
const date = new Date(entry[dateKey])
let excerpt = ''
// set the entry excerpt
if (entry.data?.post_excerpt) excerpt = entry.data.post_excerpt
if (entry.description) excerpt = entry.description
if (entry.data?.post_excerpt) excerpt = md.render(entry.data.post_excerpt)
// if there's a valid entry return a normalized object
if (entry && !entry.data?.link) {
posts.push({
title: entry.data?.title || entry.title,
url: entry.url.includes('http') ? entry.url : new URL(entry.url, BASE_URL).toString(),
content: excerpt,
content: entry.description,
date,
excerpt,
})

View file

@ -1,3 +1,4 @@
const marked = require('marked')
const sanitizeHTML = require('sanitize-html')
const utmPattern = /[?&](utm_[^&=]+=[^&#]*)/gi
@ -10,6 +11,9 @@ module.exports = {
stripIndex: (path) => {
return path.replace('/index.html', '/')
},
mdToHtml: (content) => {
return marked.parse(content)
},
btoa: (string) => {
return btoa(string)
},