| 12345678910111213141516171819202122 |
- module.exports = function articleDecorator(config, item, meta) {
- let blurb = "No description.";
- const introMatches = item.content.match(
- new RegExp("<p>(?<introText>[a-zA-Z0-9 :,.-]+)</p>", "m")
- );
- if (introMatches) {
- blurb = introMatches.groups.introText.trim();
- }
- const titleStart = item.content.indexOf(">", item.content.indexOf("<h1")) + 1;
- const titleEnd = item.content.indexOf("</h1>");
- const title =
- titleEnd > -1
- ? item.content.substring(titleStart, titleEnd).trim()
- : meta.name;
- return {
- ...item,
- niceName: title,
- blurb: blurb,
- tags: [].concat(item.tags, ["article"])
- };
- };
|