contentful-readme-generator

0.0.24 • Public • Published

Contentful Readme Generator


Project Abbreviation: RDME

NPM version NPM downloads

Developer Emails: scott.rouse@gmail.com

NPM URL: https://www.npmjs.com/package/contentful-readme-generator

Repo URL: https://github.com/srouse/contentful-readme-generator

Description

This is a service that loads a Contentful entry and renders it as a README file in the repo folder. It has the side effect of being able to use this information for other uses, such as project overviews.

Readme Install

To install

yarn add contentful-readme-generator

Create a .env file in your project

# CTFL README
CTFL_README_CONTENTFUL_SPACE=[Your Space Id *]
CTFL_README_CONTENTFUL_ENVIRONMENT=[Your Environment Id *]
CTFL_README_CONTENTFUL_ENTRY_ID=[Your Entry Id *]
CTFL_README_CONTENTFUL_ACCESS_TOKEN=[Your Access Token Id]

Setup Local Configuration *

  • The .env variables are not necessary if using a configuration file.
// ctfl-readme.json
{
  "contentfulSpace": "[Your Space Id]",
  "contentfulEnvironment": "[Your Env]",
  "contentfulEntryId": "[Your Entry Id]",
  "rootFilename": "README",
  "folderName": "README",
  "htmlTemplate": "templates/htmlTemplate.mjs",
  "htmlRootFileName": "index",
  "htmlDist": "dist"
}

build

yarn ctfl-readme

✎ edit

Contentful Content

Build your Content Type

There is no specific structure needed to build a readme file, but there are limitations. For instance, ctfl-readme will try to render out whatever you put into your Entry, but text and markdown (large text) are ideal. A simple, but effective example would be:

{
  "name": "Readme Project",
  "description": "",
  "displayField": "title",
  "fields": [
    {
      "id": "title",
      "name": "Title",
      "type": (TEXT),
      ...
    },
    {
      "id": "Badges",
      "name": "badges",
      "type": (JSON),
      ...
    },
    {
      "id": "tableOfContents",
      "name": "Table of Contents",
      "type": "Boolean",
      "defaultValue": {
        "en-US": true
      },
      ...
    },
    {
      "id": "repoUrl",
      "name": "Repo URL",
      "type": (TEXT, URL VALIDATED),
      ...
    },
    {
      "id": "description",
      "name": "## Description",
      "type": (MARKDOWN TEXT),
      ...
    },
    {
      "id": "howToInstall",
      "name": "## How To Install",
      "type": (MARKDOWN TEXT),
      ...
    },

What Does NOT work as well

Rich Text. Avoid rich text in your Content Type. There is a markdown editor in Contentful, so rich text is a very round about way of getting back to markdown.

Badges

ctfl-readme does understand how to create badges via badges. Add a property to your content type with an id of "badges" with the type of JSON and you will be able to pass in a formatted object into badges' renderBadges. Each argument will be a line in the JSON object:

{
    "list": [
        "npmversion"
    ],
    "config": {
        "npmPackageName": "contentful-readme-generator"
    },
    "options": {}
}

Headers

Properties with header characters (#, ##, ###) will be expressed as headers before their content is rendered. This works well for markdown entries. The only special case is "# Title" which will render the actual title instead of the literal word "title".

Table of Contents

Adding a property with an id of "tableOfContents" with a type of boolean will trigger (if true) the rendering of a table of contents. It is done via markdown-toc.

Arguments

There is only one argument where you can change the destination file name

ctfl-readme --fileName README-OTHER.md

✎ edit

Page Example ➚

Figma Design System Widget ➚

Build Information

Dynamically built using contentful-readme-generator. Do not edit directly.

updated: 6/16/2023, 1:25:07 PM

space: rtkhko6y3s3u

environment: master

entity id: 2Ox6brgaOxUyE0QDuNOAmH

✎ edit

Readme

Keywords

none

Package Sidebar

Install

npm i contentful-readme-generator

Weekly Downloads

311

Version

0.0.24

License

MIT

Unpacked Size

25.3 kB

Total Files

12

Last publish

Collaborators

  • srouse