feat: add a call to action to daily emails
This commit is contained in:
parent
f5974a2083
commit
7acf00dbca
|
@ -2,6 +2,7 @@ import MarkdownIt from 'markdown-it';
|
||||||
import rss from '@astrojs/rss';
|
import rss from '@astrojs/rss';
|
||||||
import sanitizeHtml from 'sanitize-html';
|
import sanitizeHtml from 'sanitize-html';
|
||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
|
import * as _ from 'lodash';
|
||||||
|
|
||||||
export async function get() {
|
export async function get() {
|
||||||
const emails = await getCollection('daily-email');
|
const emails = await getCollection('daily-email');
|
||||||
|
@ -14,13 +15,26 @@ export async function get() {
|
||||||
|
|
||||||
const parser = new MarkdownIt();
|
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({
|
return rss({
|
||||||
title: 'Daily email list',
|
title: 'Daily email list',
|
||||||
description: 'A daily newsletter on software development, DevOps, community, and open-source.',
|
description: 'A daily newsletter on software development, DevOps, community, and open-source.',
|
||||||
site: import.meta.env.SITE,
|
site: import.meta.env.SITE,
|
||||||
|
|
||||||
items: sortedEmails.slice(0, 1).map((email) => ({
|
items: sortedEmails.slice(0, 1).map((email) => ({
|
||||||
description: `<div style="max-width: 550px;">${sanitizeHtml(parser.render(email.body))}</div>`,
|
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}`,
|
link: `${import.meta.env.SITE}/${email.data.permalink}`,
|
||||||
pubDate: email.data.pubDate,
|
pubDate: email.data.pubDate,
|
||||||
title: `${email.data.title}`,
|
title: `${email.data.title}`,
|
||||||
|
|
Loading…
Reference in a new issue