Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@prismicio/helpers

prismicio179.4kApache-2.02.3.9TypeScript support: included

Set of helpers to manage Prismic data

typescript, helpers, utils, toolbox, prismic

readme

@prismicio/helpers

npm version npm downloads Github Actions CI Codecov Conventional Commits License

Set of helpers to manage Prismic data.

  • 📅  Transform Date and Timestamp fields into Date objects;
  • 🗺  Resolve any kind of Link fields;
  • 🌐  Dedicated GraphQL API support.

Install

npm install @prismicio/helpers

Documentation

To discover what's new on this package check out the changelog. For full documentation, visit the official Prismic documentation.

Contributing

Whether you're helping us fix bugs, improve the docs, or spread the word, we'd love to have you as part of the Prismic developer community!

Asking a question: Open a new topic on our community forum explaining what you want to achieve / your question. Our support team will get back to you shortly.

Reporting a bug: Open an issue explaining your application's setup and the bug you're encountering.

Suggesting an improvement: Open an issue explaining your improvement or feature so we can discuss and learn more.

Submitting code changes: For small fixes, feel free to open a pull request with a description of your changes. For large changes, please first open an issue so we can discuss if and how the changes should be implemented.

For more clarity on this project and its structure you can also check out the detailed CONTRIBUTING.md document.

License

   Copyright 2013-2022 Prismic <contact@prismic.io> (https://prismic.io)

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.3.9 (2023-01-28)

Refactor

Chore

  • deps: maintain dependencies (75a77a8)

2.3.8 (2022-12-19)

Chore

  • deps: maintain dependencies (22040aa)

2.3.7 (2022-12-19)

Chore

  • deps: maintain dependencies (f0fe858)

2.3.6 (2022-11-16)

Bug Fixes

  • allow Content Relationship field's data property overrides when using isFilled helpers (#62) (cc75ce5)

Chore

2.3.5 (2022-09-20)

Bug Fixes

  • simplify isFilled.embed() for better TypeScript compatibility (#57) (55b093c)

2.3.4 (2022-09-15)

Bug Fixes

  • omit target attribute on links without a target (#59) (9b2dddd)

Chore

2.3.3 (2022-08-05)

Bug Fixes

  • resolve invalid compiled TypeScript types (#56) (6122cb7)

2.3.2 (2022-07-13)

Chore

2.3.1 (2022-06-09)

Bug Fixes

  • support partial document in asLink() and documentToLinkField() (#51) (e3a3493)

2.3.0 (2022-04-15)

Features

  • opt-in automatic responsive view support for asImageWidthSrcSet() (#47) (2a1ad82)

Bug Fixes

  • include url property when using asLink() with a document (#48) (f437962)

Chore

  • deps: upgrade dependencies (2c2360e)

2.2.1 (2022-03-18)

Bug Fixes

Chore

2.2.0 (2022-02-25)

Features

  • narrow return types when field is known (#43) (40f41f9)
  • support nullish inputs for isFilled helpers (#44) (6c5597b)

Chore

2.1.1 (2022-02-04)

Bug Fixes

  • isFilled.image thumbnail names should extend string | null, fixes #41 (659c212)

Chore

  • deps: maintain dependencies (ea814ca)

2.1.0 (2022-02-01)

Features

  • add asImageSrc(), asImageWidthSrcSet(), asImagePixelDensitySrcSet() (#38) (2b4984a)

Chore

2.0.1 (2022-01-28)

Chore

  • add Size Limit repo support (da22d5b)
  • deps: update @prismicio/richtext (4c97a27)
  • deps: update dependencies (ffbf66e)
  • fix Size Limit integration (660bd1e)
  • support React Native's Metro bundler (51151f9)

2.0.0 (2022-01-05)

2.0.0-beta.8 (2021-12-16)

Features

Documentation

  • update docs link [skip ci] (662a077)

2.0.0-beta.7 (2021-12-06)

Features

  • allow nullish field in asHTML and asText (4c7c8bc)

Bug Fixes

  • support documents without slugs in documentToLinkField (a60f4be)

2.0.0-beta.6 (2021-12-03)

Chore

  • deps: maintain dependencies (dc71bc6)

2.0.0-beta.5 (2021-11-29)

Bug Fixes

  • support nullish slugs property when passing a document to asLink (85eedea)

2.0.0-beta.4 (2021-11-29)

Features

  • export Elements as a deprecated alias for Element (b6fbe0c)

2.0.0-beta.3 (2021-11-10)

Bug Fixes

  • prioritize Link Resolver over Route Resolver (#30) (acc4a17)

2.0.0-beta.2 (2021-11-05)

Features

  • pass HTML serializer children as string (c3634f9)

Refactor

  • use runtime-generated map serializer (ff15253)

Documentation

  • update TSDoc for new HTML serializer types (05bd482)

Chore

  • deps: maintain dependencies (2a8037f)

2.0.0-beta.1 (2021-10-12)

Bug Fixes

  • type issue with empty links in asLink (542b4d9)

Chore

  • deps: update dependencies (6165b41)
  • mark package as side effect free (9636f9d)

Refactor

  • use currying to build HTML serializer (b7ba08a)

2.0.0-beta.0 (2021-09-29)

Chore

  • deps: maintain dependencies (eda08bb)

2.0.0-alpha.9 (2021-09-27)

Features

  • remove documentAsLink (5cdee16)
  • update asLink to handle documents (ae14694)

Chore

  • tag graphql functions as experimental to help with potential breaking changes (b0432a4)
  • update template config (e05d381)

2.0.0-alpha.8 (2021-09-14)

Chore

2.0.0-alpha.7 (2021-08-12)

Features

  • allow explicit null for linkResolver & HTML serializer (275bfca)

2.0.0-alpha.6 (2021-08-11)

Features

  • export serializer elements types for convenience (715f11d)

Bug Fixes

  • prevent XSS on image tag serialization (c0e6d6d)

Chore

  • update pull request template (8330ddd)

2.0.0-alpha.5 (2021-07-07)

Features

Bug Fixes

  • also export types for graphql export (124f837)
  • escape external links to prevent xss (0cb7c43)

Documentation

  • document asHTML new helper (d40d3c6)

Chore

  • deps: examples dependencies (76e6b41)
  • ignore examples lock files (699febc)

2.0.0-alpha.4 (2021-07-03)

Chore

2.0.0-alpha.3 (2021-07-03)

Bug Fixes

  • optional Link Resolver for asLink and asHTML (#22) (b007ff1), closes #21
  • retain data field in documentToLinkField (#23) (81b0706), closes #19

2.0.0-alpha.2 (2021-07-01)

Chore

2.0.0-alpha.1 (2021-06-29)

Bug Fixes

  • update dependencies and @prismicio/richtext types (f30aa18)

Refactor

  • extract serializer helpers into a dedicated file (5d1d2a8)
  • migrate asHTML to @prismicio/richtext@2 (a565d02)
  • migrate asHtml to typescript (f589b05)
  • provide asText from @prismicio/richtext directly (987105f)

Chore

2.0.0-alpha.0 (2021-05-27)

⚠ BREAKING CHANGES

  • migrate existing functions to typescript

Features

  • examples: add examples directory (6f2e6ca)
  • add graphql support (45858a9)
  • allow asLink to also resolve prismic documents (experimental) (ed5ad52)
  • allow return type to be specified for link resolver (be75fb5)

Bug Fixes

  • handle link field edge cases on asLink (83f1a61)

Refactor

  • examples: refactor example directory (01051cb)
  • graphql: refactor graphql asLink resolving (b0ada1d)
  • extract document cast to link field into its own function (ef16ef5)
  • migrate existing functions to typescript (a52cc56)
  • move ArgumentError to lib folder (8726268)

Documentation

  • examples: add graphql examples (123eeb7)
  • add todo (b757e27)
  • document linkResolverFunction (3172393)
  • update readme and issue template (aeacfd3)

Chore

  • deps: bump @prismicio/types (7b5f470)
  • maintain dependencies (12ca991)
  • revamp repo structure (b9c05ca)
  • update eslint config (2397998)
  • deps: maintain dependencies (b76687b)
  • update template (3342a50)
  • config: update .eslintignore (c5a9f3e)
  • deps: maintain dependencies (87e7f77)
  • deps: upgrade @prismicio/types (d4dea1c)