commit
7be229d9d0
@ -24,6 +24,14 @@ module.exports = function(eleventyConfig) {
|
|||||||
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
|
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Content for jsonfeed
|
||||||
|
eleventyConfig.addFilter('jsonStringify', content => {
|
||||||
|
if (!content) {
|
||||||
|
content = "";
|
||||||
|
}
|
||||||
|
return JSON.stringify(content);
|
||||||
|
});
|
||||||
|
|
||||||
// Get the first `n` elements of a collection.
|
// Get the first `n` elements of a collection.
|
||||||
eleventyConfig.addFilter("head", (array, n) => {
|
eleventyConfig.addFilter("head", (array, n) => {
|
||||||
if( n < 0 ) {
|
if( n < 0 ) {
|
||||||
|
@ -8,6 +8,10 @@
|
|||||||
"path": "/feed/feed.xml",
|
"path": "/feed/feed.xml",
|
||||||
"id": "https://myurl.com/"
|
"id": "https://myurl.com/"
|
||||||
},
|
},
|
||||||
|
"jsonfeed": {
|
||||||
|
"path": "/feed/feed.json",
|
||||||
|
"url": "https://myurl.com/feed/feed.json"
|
||||||
|
},
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Your Name Here",
|
"name": "Your Name Here",
|
||||||
"email": "youremailaddress@example.com"
|
"email": "youremailaddress@example.com"
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
<link rel="stylesheet" href="{{ '/css/index.css' | url }}">
|
<link rel="stylesheet" href="{{ '/css/index.css' | url }}">
|
||||||
<link rel="stylesheet" href="{{ '/css/prism-base16-monokai.dark.css' | url }}">
|
<link rel="stylesheet" href="{{ '/css/prism-base16-monokai.dark.css' | url }}">
|
||||||
<link rel="alternate" href="{{ metadata.feed.path | url }}" type="application/atom+xml" title="{{ metadata.title }}">
|
<link rel="alternate" href="{{ metadata.feed.path | url }}" type="application/atom+xml" title="{{ metadata.title }}">
|
||||||
|
<link rel="alternate" href="{{ metadata.jsonfeed.path | url }}" type="application/json" title="{{ metadata.title }}">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
|
38
feed/json.njk
Normal file
38
feed/json.njk
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
permalink: feed/feed.json
|
||||||
|
eleventyExcludeFromCollections: true
|
||||||
|
---
|
||||||
|
{
|
||||||
|
"version": "https://jsonfeed.org/version/1",
|
||||||
|
"title": "{{ metadata.title }}",
|
||||||
|
"home_page_url": "{{ metadata.url }}",
|
||||||
|
"feed_url": "{{ metadata.jsonfeed.url }}",
|
||||||
|
"description": "{{ metadata.description }}",
|
||||||
|
"author": {
|
||||||
|
"name": "{{ metadata.author.name }}",
|
||||||
|
"url": "{{ metadata.author.url }}"
|
||||||
|
},
|
||||||
|
"items": [
|
||||||
|
{%- for post in collections.posts %}
|
||||||
|
{% set absolutePostUrl %}{{ post.url | url | absoluteUrl(metadata.url) }}{% endset -%}
|
||||||
|
{
|
||||||
|
"id": "{{ absolutePostUrl }}",
|
||||||
|
"url": "{{ absolutePostUrl }}",
|
||||||
|
"title": "{{ post.data.title }}",
|
||||||
|
"content_html": {{ post.templateContent | jsonStringify | safe }},
|
||||||
|
"date_published": "{{ post.date | rssDate }}",
|
||||||
|
"tags": [
|
||||||
|
{%- for c in post.data.category %}
|
||||||
|
"{{ c }}"
|
||||||
|
{%- if not loop.last -%}
|
||||||
|
,
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor %}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
{%- if not loop.last -%}
|
||||||
|
,
|
||||||
|
{%- endif -%}
|
||||||
|
{%- endfor %}
|
||||||
|
]
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user