@dmn-arc-core-components/content-source_retail_offer-v1
v1.0.0-alpha
Published
Content source that hooks into the subscriptions retail offers portion of the Arc Suite.
Downloads
4
Readme
Content Source: Subscriptions Retail API v1 endpoint
This the Arc Core Component representing a content source that hooks into the Subscriptions Retail 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 requires that a CDN has already been configured for the site.
Pattern:
https://api-{org}-{website}{-env}.cdn.arcpublishing.com/retail/public/v1/offer/live/{campaign}
Parameters:
This content source takes three parameters: a website URL, the campaign code and the fusion environment.
Getting started
This Core Component must be used within a Fusion project.
- Add this schema as a dependency of the repo.
npm install @dmn-arc-core-components/content-source_retail_offer-v1
- Create a file of your desired content source name within the
/content/sources
folder. For this content source, the suggested name isoffers-v1.js
- This is the name you should use when referencing this content source in any content config within a custom field.
- Paste the following into
offers-v1.js
:
import { ENVIRONMENT } from "fusion:environment";
import { createContentSource } from "@arc-core-components/content-source_retail_offer-v1";
export default createContentSource(ENVIRONMENT);
What does this content source return?
This will return subscription and product data for a single campaign.
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 { ENVIRONMENT } from "fusion:environment";
import { createContentSource } from "@arc-core-components/content-source_retail_offer-v1";
export default createContentSource(ENVIRONMENT, "washingtonpost");
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.