How to use the prismic-dom.Date function in prismic-dom

To help you get started, we’ve selected a few prismic-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wellcometrust / wellcomecollection.org / server / services / prismic-parsers.js View on Github external
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());
}
github wellcometrust / wellcomecollection.org / common / services / prismic / parsers.js View on Github external
export function parseTimestamp(frag: PrismicFragment): Date {
  return PrismicDate(frag);
}
github wellcometrust / wellcomecollection.org / rss / webapp / stories / index.js View on Github external
'[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)
github wellcometrust / wellcomecollection.org / rss / webapp / stories / index.js View on Github external
})
            .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),
    });
  });

prismic-dom

Set of helpers to manage Prismic data

Apache-2.0
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis