Skip to content

A small Contentful App that provides a simple but convenient code editor for storing code snippets in your content.

License

Notifications You must be signed in to change notification settings

pauloamgomes/Contentful-Code-Editor-Field-App

Repository files navigation

Contentful Code Editor Field

A small Contentful App that utilizes the React Textarea Code Editor to provide a simple but convenient code editor for storing code snippets in your content.

▶️ Demo

screencast-code-editor-app.mp4

🛠 Setup

Install the App by doing the below steps:

  1. Create a new Contentful custom App and define the Application Name (e.g. Code Editor)

  2. Download, extract bundle.zip and drag the resulting folder into the Bundles upload zone. You can find more details about hosting an Contentful app here

  3. Set the App configuration screen and Field locations (JSON Object field).

  4. Save, and Install the App in your space, you'll see the configuration screen:

App Configuration Screen

  1. Go to the Content Model you want to use the Code Editor, create a new JSON Object field and select the App in the Appearance tab.

  2. Open or create a new entry of that Content Model and see it in action

Entry Screen

🥷 Development

Clone this Repo and install dependencies pnpm install

In the project directory, you can run:

pnpm run start

Creates or updates your app definition in Contentful, and runs the app in development mode. Open your app to view it in the browser.

The page will reload if you make edits. You will also see any lint errors in the console.

pnpm run build

Builds the app for production to the dist folder. It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes. Your app is ready to be deployed!

pnpm run upload

Uploads the dist folder to Contentful and creates a bundle that is automatically activated. The command guides you through the deployment process and asks for all required arguments. Read here for more information about the deployment process.

pnpm run upload-ci

Similar to npm run upload it will upload your app to contentful and activate it. The only difference is that with this command all required arguments are read from the environment variables, for example when you add the upload command to your CI pipeline.

For this command to work, the following environment variables must be set:

  • CONTENTFUL_ORG_ID - The ID of your organization
  • CONTENTFUL_APP_DEF_ID - The ID of the app to which to add the bundle
  • CONTENTFUL_ACCESS_TOKEN - A personal access token

Learn More

This project was bootstrapped with Create Contentful App using the vite-react example, and using pnpm as package manager.

Copyright and license

Copyright 2023 pauloamgomes under the MIT license.

About

A small Contentful App that provides a simple but convenient code editor for storing code snippets in your content.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published