mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-04 12:00:02 +00:00
Add support for rss/atom feed
This commit is contained in:
parent
cb07db7e1a
commit
ea7f584614
@ -6,6 +6,7 @@ const faviconPlugin = require("eleventy-favicon");
|
||||
const tocPlugin = require("eleventy-plugin-nesting-toc");
|
||||
const { parse } = require("node-html-parser");
|
||||
const htmlMinifier = require("html-minifier");
|
||||
const pluginRss = require("@11ty/eleventy-plugin-rss");
|
||||
|
||||
const { headerToId, namedHeadingsFilter } = require("./src/helpers/utils");
|
||||
const {
|
||||
@ -304,6 +305,7 @@ module.exports = function (eleventyConfig) {
|
||||
collapseWhitespace: true,
|
||||
minifyCSS: true,
|
||||
minifyJS: true,
|
||||
keepClosingSlash: true,
|
||||
});
|
||||
}
|
||||
return content;
|
||||
@ -317,6 +319,12 @@ module.exports = function (eleventyConfig) {
|
||||
ul: true,
|
||||
tags: ["h1", "h2", "h3", "h4", "h5", "h6"],
|
||||
});
|
||||
eleventyConfig.addPlugin(pluginRss, {
|
||||
posthtmlRenderOptions: {
|
||||
closingSingleTag: "slash",
|
||||
singleTags: ["link"]
|
||||
}
|
||||
});
|
||||
eleventyConfig.addFilter("jsonify", function (variable) {
|
||||
return JSON.stringify(variable) || '""';
|
||||
});
|
||||
|
27
package-lock.json
generated
27
package-lock.json
generated
@ -31,6 +31,7 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"@11ty/eleventy": "^2.0.0",
|
||||
"@11ty/eleventy-plugin-rss": "^1.2.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"html-minifier": "^4.0.0",
|
||||
"node-html-parser": "^6.1.4",
|
||||
@ -143,6 +144,21 @@
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@11ty/eleventy-plugin-rss": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-1.2.0.tgz",
|
||||
"integrity": "sha512-YzFnSH/5pObcFnqZ2sAQ782WmpOZHj1+xB9ydY/0j7BZ2jUNahn53VmwCB/sBRwXA/Fbwwj90q1MLo01Ru0UaQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"debug": "^4.3.4",
|
||||
"posthtml": "^0.16.6",
|
||||
"posthtml-urls": "1.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/11ty"
|
||||
}
|
||||
},
|
||||
"node_modules/@11ty/eleventy-utils": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.1.tgz",
|
||||
@ -5569,6 +5585,17 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"@11ty/eleventy-plugin-rss": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-1.2.0.tgz",
|
||||
"integrity": "sha512-YzFnSH/5pObcFnqZ2sAQ782WmpOZHj1+xB9ydY/0j7BZ2jUNahn53VmwCB/sBRwXA/Fbwwj90q1MLo01Ru0UaQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"debug": "^4.3.4",
|
||||
"posthtml": "^0.16.6",
|
||||
"posthtml-urls": "1.0.0"
|
||||
}
|
||||
},
|
||||
"@11ty/eleventy-utils": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.1.tgz",
|
||||
|
@ -18,6 +18,7 @@
|
||||
"license": "ISC",
|
||||
"devDependencies": {
|
||||
"@11ty/eleventy": "^2.0.0",
|
||||
"@11ty/eleventy-plugin-rss": "^1.2.0",
|
||||
"cross-env": "^7.0.3",
|
||||
"html-minifier": "^4.0.0",
|
||||
"node-html-parser": "^6.1.4",
|
||||
@ -45,4 +46,4 @@
|
||||
"markdown-it-plantuml": "^1.4.1",
|
||||
"markdown-it-task-checkbox": "^1.0.6"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
30
src/site/feed.njk
Normal file
30
src/site/feed.njk
Normal file
@ -0,0 +1,30 @@
|
||||
---json
|
||||
{
|
||||
"permalink": "/feed.xml",
|
||||
"eleventyExcludeFromCollections": true
|
||||
}
|
||||
---
|
||||
{%if meta.siteBaseUrl %}<?xml version="1.0" encoding="utf-8"?>
|
||||
<feed xmlns="http://www.w3.org/2005/Atom" xml:base="{{ meta.siteBaseUrl }}">
|
||||
<title>{{ meta.siteName}}</title>
|
||||
<link href="{{ meta.siteBaseUrl }}{{ permalink }}" rel="self"//>
|
||||
<link href="{{ meta.siteBaseUrl}}" //>
|
||||
<updated>{{ collections.notes | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
|
||||
<id>{{ meta.siteBaseUrl }}</id>
|
||||
{%- for note in collections.note | reverse %}
|
||||
<entry>
|
||||
<title>
|
||||
{% if note.title %}{{ note.title }}
|
||||
{% else %}{{ note.fileSlug }}
|
||||
{% endif %}
|
||||
</title>
|
||||
<updated>{{ (note.updated or note.date ) | dateToRfc3339 }}</updated>
|
||||
<id>{{ meta.siteBaseUrl }}{{note.url | url }}</id>
|
||||
<content type="html">
|
||||
{{ note.templateContent | hideDataview | link | taggify | htmlToAbsoluteUrls(meta.siteBaseUrl) }}
|
||||
</content>
|
||||
<link href="{{ meta.siteBaseUrl }}{{note.url | url }}" //>
|
||||
</entry>
|
||||
{%- endfor %}
|
||||
</feed>
|
||||
{% endif %}
|
Loading…
x
Reference in New Issue
Block a user