Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion plugins/rss/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Create a `rss.config.json` in your root with the following properties:
"outDir": "./dist/static",
"categories": ["Categories", "of", "your", "choice"],
"blogPostRouteSlug": "/blog",
"newestPostsFirst": true
"newestPostsFirst": true,
"markupLanguage": "markdown"
}
```

Expand Down
18 changes: 13 additions & 5 deletions plugins/rss/src/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ const showdown = require('showdown');
const { writeFileSync, readFileSync } = require('fs');
const { join } = require('path');
const { log, logError, yellow } = require('@scullyio/scully');
const asciidoctor = require('asciidoctor.js')();

const configFile = readFileSync(`${process.cwd()}/rss.config.json`, 'utf8');
const config = JSON.parse(configFile.toString());
const blogPostRouteSlug = config.blogPostRouteSlug || '/blog';
const filename = config.filename || 'feed';
const markupLanguage = config.markupLanguage || 'markdown';
const feed = new Feed(config);

config.categories.forEach((cat) => {
Expand Down Expand Up @@ -61,13 +63,19 @@ const createFeedItemFromRoute = (route) => {
let item;
try {
if (route.data.published) {
const mdString = readFileSync(route.templateFile, 'utf8').toString();
const articleString = readFileSync(route.templateFile, 'utf8').toString();

const md = mdString.slice(
nth_occurrence(mdString, '---', 2) + 3,
mdString.length - 1
const article = articleString.slice(
nth_occurrence(articleString, '---', 2) + 3,
articleString.length - 1
);
const articleHTML = new showdown.Converter().makeHtml(md);

const articleHTML = '';
if (markupLanguage === 'asciidoc') {
articleHTML = asciidoctor.convert(article);
} else {
articleHTML = new showdown.Converter().makeHtml(article);
}

item = {
title: route.data.title,
Expand Down