Skip to content

Commit

Permalink
fix(front): revert all RSS changes but replace ampersands
Browse files Browse the repository at this point in the history
  • Loading branch information
dgrebb committed Feb 17, 2024
1 parent c81989b commit 2098949
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bdt-fe--release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
description: "Target deployment environment."
type: environment
required: true
default: "stg"
default: "prd"
branches: [release/*]
push:
branches: [main]
Expand Down
92 changes: 42 additions & 50 deletions front/src/lib/_utils/rss.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,55 +6,47 @@ const feedDescription = 'Thoughts, learnings, and updates from Dan Grebb.';
const feedLink = 'https://www.dgrebb.com';
const feedUpdated = new Date();

export const xml = (posts) => `<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/">
<channel xmlns="http://www.w3.org/2005/Atom">
<title>${feedTitle}</title>
<link href="${feedLink}/RSS.xml" rel="self"/>
<link href="${feedLink}"/>
<id>${feedLink}/</id>
<updated>${feedUpdated.toISOString()}</updated>
<author>
<name>Dan Grebb</name>
</author>
<subtitle>${feedDescription}</subtitle>
<generator>JavaScript</generator>
${posts
.map((post) => {
const { slug, publishedAt, summary } = post.attributes;
export const xml = (posts) => `<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>${feedTitle}</title>
<link href="${feedLink}/RSS.xml" rel="self"/>
<link href="${feedLink}"/>
<id>${feedLink}/</id>
<updated>${feedUpdated.toISOString()}</updated>
<author>
<name>Dan Grebb</name>
</author>
<subtitle>${feedDescription}</subtitle>
<generator>JavaScript</generator>
${posts
.map((post) => {
const { slug, publishedAt, summary } = post.attributes;
const image =
post?.attributes?.hero?.data?.attributes?.formats?.small?.url ||
false,
thumbnail =
post?.attributes?.hero?.data?.attributes?.formats?.thumbnail?.url ||
false,
imageMIME = post?.attributes?.hero?.data?.attributes?.mime || false,
imageAlt =
post?.attributes?.hero?.data?.attributes.alternativeText || false;
const image =
post?.attributes?.hero?.data?.attributes?.formats?.thumbnail?.url ||
false;
return `<entry>
<title>${post.attributes.title.replaceAll('&', '&amp;')}</title>
<link href="${website}${path}/${slug}/"/>
<id>${website}${path}/${slug}/</id>
<updated>${new Date(publishedAt).toISOString()}</updated>
<published>${new Date(publishedAt).toISOString()}</published>
${
summary &&
`
<content type="html">
<![CDATA[
<div style="text-align: center;">
<img src="${image}" alt="${imageAlt}" style="display: inline-block;" />
</div>
<p>${summary}</p>
]]>
</content>`
}
${thumbnail && `<enclosure url="${thumbnail}" type="${imageMIME}" />`}
</entry>`;
})
.join('\n')}
</channel>
</rss>
`;
const { altText } = post?.attributes?.hero?.data?.attributes || false;
return `<entry>
<title>${post.attributes.title.replaceAll('&', '&amp;')}</title>
<link href="${website}${path}/${slug}/"/>
<id>${website}${path}/${slug}/</id>
<updated>${new Date(publishedAt).toISOString()}</updated>
<published>${new Date(publishedAt).toISOString()}</published>
${
summary ? `<content type="html"><![CDATA[${summary}]]></content>` : ''
}
${
image
? `<image>
<url>${image}</url>
<title>${altText}</title>
<link>${slug}</link>
</image>`
: ''
}
</entry>`;
})
.join('\n')}
</feed>`;

0 comments on commit 2098949

Please sign in to comment.