4.0.1 • Public • Published

    Content Source: Content API v4 endpoint

    This the Arc Core Component representing a content source that hooks into the Content API portion of the Arc Suite.

    The most important part is the pattern, which defines the endpoint that PageBuilder Fusion uses to look up content.

    This Core Component takes advantage of PageBuilder Fusion's ability to use CONTENT_BASE to define the credentials for a Content API, ensuring that no private secrets are exposed.




    This content source takes one parameter: a website URL, typically the path to the story following the domain name.

    Getting started

    This Core Component must be used within a Fusion project.

    1. Add this schema as a dependency of the repo. npm install @arc-core-components/content-source_content-api-v4
    2. Create a file of your desired content source name within the /content/sources folder. For this content source, the suggested name is content-api-v4.js
    3. This is the name you should use when referencing this content source in any content config within a custom field.
    4. Paste the following into content-api-v4.js:
    import source from "@arc-core-components/content-source_content-api-v4";
    export default source;

    What does this content source return?

    This will return an ANS document representing a single story from a Content API.

    Overwriting the default website

    The default export of the content source is set up for multisite deployments where a _website url parameter is necessary when visiting a specific page. Example: http://localhost/pf/sample-page/?_website=the-gazette. To override this behavior for a single site build we provide a factory function for creating an otherwise unchanged content source with a user provided website.

    import { createContentSource } from "@arc-core-components/content-source_content-api-v4";
    export default createContentSource("washingtonpost");

    Adding resizer URLs to images

    This module also exports a helper function addResizedUrls that can be called within the transform function to automatically add resizer URLs to all images in the content source:

    import source, { addResizedUrls } from '@arc-core-components/content-source_content-api-v4';
    import { resizerSecret, resizerUrl } from 'fusion:environment';
    const transform = (data) => {
      return addResizedUrls(data, { resizerUrl, resizerSecret, presets: {
        small: { width: 50, height: 50 },
        large: {width: 480 }
    export default {

    Then you can use the sizePreset prop in the image core component and it will be automatically resized:

    <Image sizePreset="large" {...additionalProps} />

    Here's an example for multisite, where each site could have its own resizer endpoint. This is helpful for clients that have publications in different continents - you can set up a resizer endpoint in each site's properties.

    // properties/sites/my-site.json
        resizerUrl: "my-resizer-endpoint.com",
        resizerSecretKeyEnvVar: "RESIZER_SECRET_EU"
    // content/sources/content-api-v4.js
    import source, { addResizedUrls } from '@arc-core-components/content-source_content-api-v4';
    import envVars from 'fusion:environment';
    import getProperties from 'fusion:properties';
    const transform = (data) => {
      const { website } = data;
      const { resizerSecretKeyEnvVar, resizerUrl } = getProperties(website);
      const resizerSecret = envVars[resizerSecretKeyEnvVar];
      return addResizedUrls(data, { resizerUrl, resizerSecret, presets: {
        small: { width: 50, height: 50 },
        large: {width: 480 }
      * Alternately you can give addResizedUrls a callback
      * return addResizedUrls(data, function ({ url, width, height, focalPoint }) {
      *  return { customSize: thumbor.setImagePath(url, resize(480, 0).buildUrl() }
      * });
    export default {

    See also:

    Testing & Linting

    We are using Jest and XO for testing and linting.

    We are using Husky to run a pre-push hook, preventing un-linted or code that fails tests from making it into the repo.

    To test: npm test

    To lint: npm run lint - This will also fix any simple linter errors automatically.

    To push without testing or linting: git push --no-verify - This can often be helpful if you just need to push a branch for demonstration purposes or for help.




    npm i @arc-core-components/content-source_content-api-v4

    DownloadsWeekly Downloads






    Unpacked Size

    51.3 kB

    Total Files


    Last publish


    • styonsk
    • maddoxnelson
    • amyerz
    • danielkim1
    • design1online
    • juliebacon
    • yonm
    • dan-weaver
    • imaus10
    • wyattjohnston
    • badmintonkid
    • npmwbcook
    • npmcojocaruv
    • robin.giannattasio
    • arcsubs
    • chenghsinw