Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function parsePublishedDate(doc) {
// We fallback to `Date.now()` in case we're in preview and don't have a published date
// This is because we need to have a separate `publishDate` for articles imported from WP
return PrismicDate(doc.data.publishDate || doc.first_publication_date || Date.now());
}
export function parseTimestamp(frag: PrismicFragment): Date {
return PrismicDate(frag);
}
'[my.articles.publishDate, my.webcomics.publishDate, document.first_publication_date desc]',
pageSize: 100,
}
);
const rssFeed = new Rss({
title: 'Wellcome Collection stories',
description:
'Our words and pictures explore the connections between science, medicine, life and art. Dive into a story no matter where in the world you are.',
feed_url: 'https://rss.wellcomecollection.org/stories',
site_url: 'https://wellcomecollection.org/stories',
image_url:
'https://i.wellcomecollection.org/assets/icons/android-chrome-512x512.png',
language: 'en',
categories: ['Science', 'Medicine', 'Art'],
pubDate: PrismicDom.Date(stories.results[0].first_publication_date),
});
stories.results.forEach(story => {
const { data } = story;
const description =
data.promo && data.promo.length > 0
? data.promo
.filter(slice => slice.primary.image)
.map(({ primary: { image, caption } }) => {
return PrismicDom.RichText.asText(caption);
})
.find(Boolean)
: '';
const contributors = data.contributors
.filter(({ contributor }) => contributor.isBroken === false)
})
.find(Boolean)
: '';
const contributors = data.contributors
.filter(({ contributor }) => contributor.isBroken === false)
.map(({ contributor }) => {
return contributor.data.name;
});
rssFeed.item({
title: PrismicDom.RichText.asText(data.title),
description,
url: `https://wellcomecollection.org/articles/${story.id}`,
author: contributors.join(', '),
date: PrismicDom.Date(story.first_publication_date),
});
});