diff --git a/config/filters/index.js b/config/filters/index.js index 593022a3..00215c08 100644 --- a/config/filters/index.js +++ b/config/filters/index.js @@ -80,42 +80,54 @@ export default { // feeds normalizeEntries: (entries) => { const posts = [] - entries.forEach((entry) => { - const dateKey = Object.keys(entry).find((key) => key.includes('date')) - const date = new Date(entry[dateKey]) + const mdGenerator = () => { const md = markdownIt({ html: true, linkify: true }) + + md.use(markdownItAnchor, { + level: [1, 2], + permalink: markdownItAnchor.permalink.headerLink({ + safariReaderFix: true + }) + }) + md.use(markdownItFootnote) + md.renderer.rules.footnote_ref = (tokens, idx) => { + const id = tokens[idx].meta.id + 1 + return `${id}` + } + md.renderer.rules.footnote_block_open = () => ( + '
\n
\n
    \n' + ) + md.renderer.rules.footnote_open = (tokens, idx) => { + const id = tokens[idx].meta.id + 1 + return `
  1. ${id}. ` + } + md.renderer.rules.footnote_anchor = () => '' + + return md + } + + entries.forEach((entry) => { + const dateKey = Object.keys(entry).find(key => key.includes('date')) + const date = new Date(entry[dateKey]) + const md = mdGenerator() let excerpt = '' let url = '' let title = entry.title const feedNote = '

    This is a full text feed, but not all content can be rendered perfectly within the feed. If something looks off, feel free to visit my site for the original post.

    ' - md.use(markdownItAnchor, { - level: [1, 2], - permalink: markdownItAnchor.permalink.headerLink({ - safariReaderFix: true, - }), - }) - md.use(markdownItFootnote) - - // set the entry url if (entry.url?.includes('http')) url = entry.url if (!entry.url?.includes('http')) url = new URL(entry.url, BASE_URL).toString() - if (entry?.slug) url = new URL(entry.slug, BASE_URL).toString() + if (entry?.slug) url = new URL(entry.slug, BASE_URL).toString() if (entry?.link) { title = `${entry.title} via ${entry.authors.name}` url = entry.link } - - // set the entry excerpt - if (entry.description) excerpt = entry.description // general case - if (entry.type === 'book' || entry.type === 'movie' || entry.type === 'link') excerpt = `${entry.description}

    ` // books - - // send full post content to rss + if (entry.description) excerpt = entry.description + if (entry.type === 'book' || entry.type === 'movie' || entry.type === 'link') excerpt = `${entry.description}

    ` if (entry?.slug && entry.content) excerpt = sanitizeHtml(`${md.render(entry.content)}${feedNote}`, { - disallowedTagsMode: 'completelyDiscard' - }) + disallowedTagsMode: 'completelyDiscard' + }) - // if there's a valid entry return a normalized object if (entry) posts.push({ title: title.trim(), url, diff --git a/package-lock.json b/package-lock.json index 0c899f4a..109725fb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coryd.dev", - "version": "19.6.19", + "version": "19.7.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coryd.dev", - "version": "19.6.19", + "version": "19.7.0", "license": "MIT", "dependencies": { "@cdransf/api-text": "^1.4.0", diff --git a/package.json b/package.json index f4fdc58f..11f4b4dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coryd.dev", - "version": "19.6.19", + "version": "19.7.0", "description": "The source for my personal site. Built using 11ty.", "type": "module", "scripts": {