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)
},

View file

@ -8,9 +8,9 @@
"items": [{% for entry in entries limit: 20 -%}
{
"id": "{{ entry.url | btoa }}",
"title": "{{ entry.title }}",
"title": "{{ entry.title | escape }}",
"url": "{{ entry.url }}",
"content_text": "{{ entry.title }}{% if tagMap %} {{ entry.url | tagLookup: tagMap }}{% endif %} {{ entry.url }}",
"content_text": "{{ entry.title | escape }}{% if tagMap %} {{ entry.url | tagLookup: tagMap }}{% endif %} {{ entry.url }}",
"date_published": "{{ entry.date | stringToDate | dateToRfc822 }}"
}{% if not forloop.last %},{% endif %}
{%- endfor %}

View file

@ -15,11 +15,11 @@
</image>
{% for entry in entries limit: 20 -%}
<item>
<title>{{ entry.title }}</title>
<title>{{ entry.title | escape }}</title>
<link>{{ entry.url | stripUtm | encodeAmp }}</link>
<pubDate>{{ entry.date | stringToDate | dateToRfc822 }}</pubDate>
<guid>{{ entry.url | stripUtm | encodeAmp }}</guid>
<description>{{ entry.excerpt }}</description>
<description>{{ entry.excerpt | markdown | escape }}</description>
</item>
{%- endfor %}
</channel>