chore: update daily XML feed URL
This commit is contained in:
parent
62ffd9b603
commit
bc02b2b0ee
1 changed files with 0 additions and 0 deletions
44
src/pages/rss/daily.xml.js
Normal file
44
src/pages/rss/daily.xml.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
import MarkdownIt from 'markdown-it';
|
||||
import _ from 'lodash';
|
||||
import rss from '@astrojs/rss';
|
||||
import sanitizeHtml from 'sanitize-html';
|
||||
import { getCollection } from 'astro:content';
|
||||
|
||||
export async function get() {
|
||||
const emails = await getCollection('daily-email');
|
||||
|
||||
const sortedEmails = Object.values(emails)
|
||||
.sort((a, b) =>
|
||||
new Date(b.data.pubDate).valueOf() -
|
||||
new Date(a.data.pubDate).valueOf()
|
||||
);
|
||||
|
||||
const parser = new MarkdownIt();
|
||||
|
||||
const callToAction = () => {
|
||||
return _.sample([
|
||||
'Do you need help or want another pair of eyes on your code? Book a <a href="https://www.oliverdavies.uk/call">1-on-1 consulting call</a> or an <a href="https://www.oliverdavies.uk/pair">online pair programming session</a> with a 100% money-back guarantee.',
|
||||
'If you\'re creating a new Drupal module, try my <a href="https://github.com/opdavies/drupal-module-template">free Drupal module template</a>.',
|
||||
]);
|
||||
};
|
||||
|
||||
return rss({
|
||||
title: 'Daily email list',
|
||||
description: 'A daily newsletter on software development, DevOps, community, and open-source.',
|
||||
site: import.meta.env.SITE,
|
||||
|
||||
items: sortedEmails.slice(0, 1).map((email) => ({
|
||||
description: `
|
||||
<div style="max-width: 550px;">
|
||||
${sanitizeHtml(parser.render(email.body))}
|
||||
<hr />
|
||||
<p>P.S. ${callToAction()}</p>
|
||||
</div>
|
||||
`,
|
||||
link: `${import.meta.env.SITE}/${email.data.permalink}`,
|
||||
pubDate: email.data.pubDate,
|
||||
title: `${email.data.title}`,
|
||||
customData: `<tags>${email.data.tags.map(tag => `<tag>#${tag}</tag>`)}</tags>`,
|
||||
}))
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue