Skip to content

The Content Hub ONE NextJS starterkit will contain helping functionalities such as handling GraphQL JSON output conversion to HTML for Rich Text, Media Fields and References. Also it will contain a small example implementation that Developers can use to start their customer projects on.

License

Notifications You must be signed in to change notification settings

zul-m/content-hub-one-nextjs-starterkit

 
 

Repository files navigation

content-hub-one-nextjs-starterkit

The Content Hub ONE NextJS starter kit is intended to help you begin Content Hub ONE development quickly. It includes useful functionalities, such as the handling of GraphQL JSON output conversion to HTML for rich text, media fields, and references and contains a small sample implementation that you can use to start building customer projects on.

This is a Next.js project bootstrapped with create-next-app.

More Information about Content Hub ONE, including video tutorials, is available from the Developer Portal.

Prerequisites

To use this starter kit you require

Install the Content Hub ONE CLI.

You can install the Content Hub ONE CLI using chocolatey:

choco install Sitecore.ContentHubOne.Cli --source https://nuget.sitecore.com/resources/v2/

For more information see CLI documentation.

Connect Content Hub ONE Tenant with your CLI

You can login to several Content Hub ONE instances but one needs to be set active.

To login and add your tenant run:

ch-one-cli tenant add \
--organization-id <Organization ID> \
--tenant-id <Tenant ID> \
--client-id <Client credentials: OAuth client ID> \
--client-secret <Client credentials: OAuth client secret>

For more information check: Log in with the Content Hub ONE CLI

Clone this repository

Clone this repository to your local drive.

Install required npm packages

In the root of your repository folder, run the following command:

npm install

setup .env

Copy the .env.example file to your repository root and rename it to ".env".

Provide the following parameters:

SITECORE_CLIENT_ID --> You can find the Client Id in the Content Hub ONE app under 'Settings'>'OAuthClient'>'Client Credentials'

SITECORE_CLIENT_SECRET --> You can find the Client Secret in the Content Hub ONE app under 'Settings'>'OAuthClient'>'Client Credentials'

This is required when uploading the demo images using the setup.js.

SITECORE_ENDPOINT_URL --> Here you need the Delivery API Url, for example, https://edge.sitecorecloud.io/api/graphql/v1. More Information you find in the Delivery API documentation.

SITECORE_DEV_AUTH_TOKEN --> In Content Hub ONE, create an API key. This can be done through the Content Hub ONE app, CLI, or Content Management API

This is required to connect your app with the Content Hub ONE tenant.

Push content to your tenant

The starter kit uses images, content types and content items. To install those to your Content Hub ONE tenant use your command prompt.

Setup

Navigate to the root of the app (content-hub-one-nextjs-starterkit).

run in the root of your app directory:

node setup

The Script will push the images to your environment, next the content types and last the content items.

The script is re-runnable.

Publish

To make the newly created images and content items available on the content delivery API (GraphQl endpoint on Edge) you need to publish.

run in the root of your app directory:

node publish

The Script will publish all the required items. Please note that publishing is just being scheduled and can take up to a few minutes after finish of the script.

The script is re-runnable.

Start the application

navigate back to the root folder of your application/repo and run the development server:

npm run dev
# or
yarn dev

To see the result, open http://localhost:3000 in your browser.

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

See the Next.js deployment documentation for more information.

Removal of starter kit related content

In case you want to remove all content items, content types or images installed by starter kit use the command prompt and navigate to the root of your app directory.

Unpublish

First content items and images need to be unpublished.

run in your app root directory:

node unpublish

The Script will unpublish all the required items. Please note that unpublishing is just being scheduled and can take up to a few minutes after finish of the script.

The script is re-runnable.

Remove content

Make sure that the content has been unpublished. You can check that in the Content Hub ONE editing UI.

run in your app root directory:

node remove

The script is re-runnable.

About

The Content Hub ONE NextJS starterkit will contain helping functionalities such as handling GraphQL JSON output conversion to HTML for Rich Text, Media Fields and References. Also it will contain a small example implementation that Developers can use to start their customer projects on.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 45.2%
  • TypeScript 38.0%
  • CSS 16.8%