Swap convertStringToHTML with html-escaper module

This commit is contained in:
Ahmad Al Maaz 2021-06-18 22:19:29 +03:00
parent 464ab08c69
commit 4c1b4fbd78
3 changed files with 10625 additions and 33 deletions

View File

@ -1,14 +1,13 @@
import siteMetadata from '@/data/siteMetadata'
import { escape } from 'html-escaper'
const convertStringToHTML = (string) =>
string.replace(/&/g, '&amp;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/"/g, '&quot;')
import siteMetadata from '@/data/siteMetadata'
const generateRssItem = (post) => `
<item>
<guid>${siteMetadata.siteUrl}/blog/${post.slug}</guid>
<title>${convertStringToHTML(post.title)}</title>
<title>${escape(post.title)}</title>
<link>${siteMetadata.siteUrl}/blog/${post.slug}</link>
<description>${convertStringToHTML(post.summary)}</description>
<description>${escape(post.summary)}</description>
<pubDate>${new Date(post.date).toUTCString()}</pubDate>
<author>${siteMetadata.email} (${siteMetadata.author})</author>
${post.tags.map((t) => `<category>${t}</category>`).join('')}
@ -18,9 +17,9 @@ const generateRssItem = (post) => `
const generateRss = (posts, page = 'index.xml') => `
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>${convertStringToHTML(siteMetadata.title)}</title>
<title>${escape(siteMetadata.title)}</title>
<link>${siteMetadata.siteUrl}/blog</link>
<description>${convertStringToHTML(siteMetadata.description)}</description>
<description>${escape(siteMetadata.description)}</description>
<language>${siteMetadata.language}</language>
<managingEditor>${siteMetadata.email} (${siteMetadata.author})</managingEditor>
<webMaster>${siteMetadata.email} (${siteMetadata.author})</webMaster>

10644
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
"@tailwindcss/typography": "^0.4.0",
"autoprefixer": "^10.2.5",
"gray-matter": "^4.0.2",
"html-escaper": "^3.0.3",
"image-size": "1.0.0",
"next": "10.2.3",
"next-mdx-remote": "^3.0.1",