Rss feeds now show full article with images that use absolute urls for relative ones.
This commit is contained in:
parent
db783414c9
commit
a432fa74aa
3 changed files with 76 additions and 4 deletions
|
|
@ -2,6 +2,7 @@ import { Feed } from "feed"
|
|||
import { getAllPodcastSeries, getAllPosts, getProjectDetails } from "../external/cms"
|
||||
import fs from "fs"
|
||||
import config from './config'
|
||||
import htmlFindReplaceElementAttrs from "html-find-replace-element-attrs"
|
||||
|
||||
export const generateRssFeed = async (filter) => {
|
||||
|
||||
|
|
@ -67,6 +68,23 @@ export const generateRssFeed = async (filter) => {
|
|||
|
||||
const url = `${siteURL}/news/${post.attributes.Slug}`;
|
||||
|
||||
console.log(htmlFindReplaceElementAttrs.find(
|
||||
post.attributes.Body,
|
||||
{tag: "img", attr: "src"}
|
||||
))
|
||||
|
||||
const body = htmlFindReplaceElementAttrs.replace(
|
||||
post.attributes.Body,
|
||||
item => item.parsedUrl,
|
||||
{
|
||||
tag: "img",
|
||||
attr: "src",
|
||||
parseAttrValueAsUrl: true,
|
||||
baseUrl: config.siteURL,
|
||||
urlProtocol: "https",
|
||||
}
|
||||
)
|
||||
|
||||
feed.addItem({
|
||||
|
||||
title: post.attributes.Title,
|
||||
|
|
@ -75,9 +93,9 @@ export const generateRssFeed = async (filter) => {
|
|||
|
||||
link: url,
|
||||
|
||||
description: post.attributes.Abstract,
|
||||
description: body,
|
||||
|
||||
content: post.attributes.Abstract,
|
||||
content: body,
|
||||
|
||||
author: [author],
|
||||
|
||||
|
|
@ -192,3 +210,4 @@ export const generatePodcastFeeds = async () => {
|
|||
fs.writeFileSync(`./public/feed/${series.attributes.Slug}.xml`, feed.rss2());
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
"bootstrap": "^4.6.0",
|
||||
"feed": "^4.2.2",
|
||||
"fs": "^0.0.1-security",
|
||||
"html-find-replace-element-attrs": "^1.0.0",
|
||||
"less": "^3.13.1",
|
||||
"mdbreact": "^5.1.0",
|
||||
"next": "^10.2.3",
|
||||
|
|
|
|||
56
yarn.lock
56
yarn.lock
|
|
@ -411,6 +411,15 @@ babel-code-frame@^6.26.0:
|
|||
esutils "^2.0.2"
|
||||
js-tokens "^3.0.2"
|
||||
|
||||
babel-loader@^7.1.4:
|
||||
version "7.1.5"
|
||||
resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.5.tgz#e3ee0cd7394aa557e013b02d3e492bfd07aa6d68"
|
||||
integrity sha512-iCHfbieL5d1LfOQeeVJEUyD9rTwBcP/fcEbRCfempxTDuqrKpu0AZjLAQHEQa3Yqyj9ORKe2iHfoj4rHLf7xpw==
|
||||
dependencies:
|
||||
find-cache-dir "^1.0.0"
|
||||
loader-utils "^1.0.2"
|
||||
mkdirp "^0.5.1"
|
||||
|
||||
babel-plugin-syntax-jsx@6.18.0:
|
||||
version "6.18.0"
|
||||
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-jsx/-/babel-plugin-syntax-jsx-6.18.0.tgz#0af32a9a6e13ca7a3fd5069e62d7b0f58d0d8946"
|
||||
|
|
@ -1270,7 +1279,16 @@ find-cache-dir@3.3.1:
|
|||
make-dir "^3.0.2"
|
||||
pkg-dir "^4.1.0"
|
||||
|
||||
find-up@2.1.0:
|
||||
find-cache-dir@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f"
|
||||
integrity sha512-46TFiBOzX7xq/PcSWfFwkyjpemdRnMe31UQF+os0y+1W3k95f6R4SEt02Hj4p3X0Mir9gfrkmOtshFidS0VPUg==
|
||||
dependencies:
|
||||
commondir "^1.0.1"
|
||||
make-dir "^1.0.0"
|
||||
pkg-dir "^2.0.0"
|
||||
|
||||
find-up@2.1.0, find-up@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"
|
||||
integrity sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ==
|
||||
|
|
@ -1496,6 +1514,14 @@ hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.2.1:
|
|||
dependencies:
|
||||
react-is "^16.7.0"
|
||||
|
||||
html-find-replace-element-attrs@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/html-find-replace-element-attrs/-/html-find-replace-element-attrs-1.0.0.tgz#c286011ee127d9052b0eeb035e26a67e28902110"
|
||||
integrity sha512-3qbLhWkHurf+UZXydlri9pU7uJ5Qw9v/AW+iXpbdHkDM49VFw4aDC9J/rBqT1MjaQzYGy1kLLOfeFfxrSkTUhg==
|
||||
dependencies:
|
||||
babel-loader "^7.1.4"
|
||||
url-join "^4.0.0"
|
||||
|
||||
http-errors@1.7.3:
|
||||
version "1.7.3"
|
||||
resolved "https://registry.yarnpkg.com/http-errors/-/http-errors-1.7.3.tgz#6c619e4f9c60308c38519498c14fbb10aacebb06"
|
||||
|
|
@ -2016,6 +2042,13 @@ lru-cache@^6.0.0:
|
|||
dependencies:
|
||||
yallist "^4.0.0"
|
||||
|
||||
make-dir@^1.0.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c"
|
||||
integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==
|
||||
dependencies:
|
||||
pify "^3.0.0"
|
||||
|
||||
make-dir@^2.1.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
|
||||
|
|
@ -2142,7 +2175,7 @@ minimalistic-crypto-utils@^1.0.1:
|
|||
resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a"
|
||||
integrity sha512-JIYlbt6g8i5jKfJ3xz7rF0LXmv2TkDxBLUkiBeZ7bAx4GnnNMr8xFpGnOxn6GhTEHx3SjRrZEoU+j04prX1ktg==
|
||||
|
||||
minimist@^1.2.0, minimist@^1.2.3:
|
||||
minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.6:
|
||||
version "1.2.6"
|
||||
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44"
|
||||
integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q==
|
||||
|
|
@ -2152,6 +2185,13 @@ mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3:
|
|||
resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113"
|
||||
integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==
|
||||
|
||||
mkdirp@^0.5.1:
|
||||
version "0.5.6"
|
||||
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6"
|
||||
integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==
|
||||
dependencies:
|
||||
minimist "^1.2.6"
|
||||
|
||||
moment@^2.10.2:
|
||||
version "2.29.3"
|
||||
resolved "https://registry.yarnpkg.com/moment/-/moment-2.29.3.tgz#edd47411c322413999f7a5940d526de183c031f3"
|
||||
|
|
@ -2529,6 +2569,13 @@ pify@^4.0.1:
|
|||
resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231"
|
||||
integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==
|
||||
|
||||
pkg-dir@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b"
|
||||
integrity sha512-ojakdnUgL5pzJYWw2AIDEupaQCX5OPbM688ZevubICjdIX01PRSYKqm33fJoCOJBRseYCTUlQRnBNX+Pchaejw==
|
||||
dependencies:
|
||||
find-up "^2.1.0"
|
||||
|
||||
pkg-dir@^4.1.0:
|
||||
version "4.2.0"
|
||||
resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-4.2.0.tgz#f099133df7ede422e81d1d8448270eeb3e4261f3"
|
||||
|
|
@ -3649,6 +3696,11 @@ uri-js@^4.2.2:
|
|||
dependencies:
|
||||
punycode "^2.1.0"
|
||||
|
||||
url-join@^4.0.0:
|
||||
version "4.0.1"
|
||||
resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7"
|
||||
integrity sha512-jk1+QP6ZJqyOiuEI9AEWQfju/nB2Pw466kbA0LEZljHwKeMgd9WrAEgEGxjPDD2+TNbbb37rTyhEfrCXfuKXnA==
|
||||
|
||||
url-loader@^4.0.0, url-loader@^4.1.0:
|
||||
version "4.1.1"
|
||||
resolved "https://registry.yarnpkg.com/url-loader/-/url-loader-4.1.1.tgz#28505e905cae158cf07c92ca622d7f237e70a4e2"
|
||||
|
|
|
|||
Loading…
Reference in a new issue