0.2.0 • Published 11 months ago

@last-rev/contentful-app-components v0.2.0

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

Last Rev Next Starter

Special components

  • Asset - Displays a media asset from contentful. Please see the AssetParser in the Last Rev Adapter package for the expected shape. Note: items that have gone through the adapter will already have been parsed to fit this model and no further manipulation should be necessary.
  • ContentModule - This is a content lookup. Pass in the contentTypeId and fields of a content item and it will use the mapping at src/buildArtifacts/mapping (auto-generated with lr-prefetch) to determine the component to render. This is used on general pages as well as within the PreviewWrapper.
  • ElementLink - This component renders an ElementLink content item, or can be used to display a link extracted from other info on the page. Please see the LinkParser inthe Last Rev Adapter package for the expected shape. Note: items that have gone through the adapter will already have been parsed to fit this model and no further manipulation should be necessary. The only exceptions to this would be if you are wrapping something in a link that is not an elementLink content item, or if you want to generate a nested slug hierarchy that is context dependent (such as /course/[courseSlug]/topics/[topicSlug]).
  • ErrorBoundary - limits a component's error state to the defined boundary. Useful to allow the rest of the site to render when a sub-component fails.
  • Head - This is a wrapper for the head HTML element. This expects SEO data to be passed into it that is extracted from the page coontent.
  • Layout - This is a wrapper for the page. Should be used on most pages. This will read in the settings (auto-generated with lr-prefetch) and also takes the extracted seo data that will be passed on to the Head component.
  • PreviewWrapper - This component calls into ContentModule to render a preview item. It is called from the Preview page.
  • RichTextParser - Renders a rich text field from contentful.

All other components should be generated, using the LastRev Generator, from the content types they are meant to render.

Tooling and configuration

  • LastRev Generator - Generates component scaffolding based on contentType fields. Useful for getting a project up and running very quickly.
  • LastRev Contentful Integration - Frequently used functions to query Contentful. Can be used with or without the adapter (see below).
  • LastRev Contentful Adapter - Converts the data that comes from contentful into the flattened shape shich is expected by the components. Eliminates the need to parse fields out in each component. It can also generate dynamic URLs based on a config passed to it using .lastrevrc (see below).
  • LastRev Content Prefetcher - Prefetches useful data in order to save build time. Will also generate component mappings and locale data.
  • .lastrevrc - This is the config file, in JSON format, that configures the tools listed above. See the one in this project for an example oof all the options.