contentful-hugo

A CLI tool that pulls data from Contentful and turns it into markdown files for Hugo and other static site generators. It also includes an express server that can be used for local development and content previews

Downloads
1.8K
Stars
38
Committers
9

Bot releases are hidden (Show)

contentful-hugo - v1.16.2

Published by joshmossas over 3 years ago

Bugfix

Fix cannot access "sys" of "undefined" error that occurs when an entry is referencing another entry that has been deleted or is inaccessible.

Chores

Dependencies

  • update contentful to 8.3.2
  • update js-yaml to 4.1.0

Dev Dependencies

  • update @babel/cli to 7.13.16
  • update @types/fs-extra to 9.0.11
  • update @types/jest to 26.0.23
  • update @types/js-yaml to 4.0.1
  • update @typescript-eslint/eslint-plugin to 4.22.0
  • update @typescript-eslint/parser to 4.22.0
  • update eslint to 7.25.0
  • update eslint-config-prettier to 8.3.0
  • update ts-jest to 26.5.5
  • update ts-loader to 8.2.0
  • update typescript to 4.2.4
contentful-hugo - v1.16.0

Published by joshmossas over 3 years ago

Introducing Static Content

Static content is a new feature that allows you to specify a "static content" directory. Any content or data files in that directory will be copied into your content and / or data directory at build time. This creates a separate folder for managing content and data files that are not managed in Contentful making it easy to clean those folders (since now you can just delete the whole directory).

Example Config

// contentful-hugo.config.js
module.exports = {
  // rest of config
  staticContent = [
     {
        // all files in "./static_content" will be copied to "./content"
        inputDir: "static_content",
        ouputDir: "content"
      },
      {
        // all files in "./static_data" will be copied to "./data"
        inputDir: "static_data",
        outputDir: "data"
      }
  ]
}

When in running contentful-hugo --server the server will also listen for changes in these static directories and copy updates to the output directories.

Other Changes

  • --clean was added as a flag. Running contentful-hugo --clean will find all root directories of the directories specified in the singleTypes and repeatableTypes and delete them. (Ex. if posts specifies "content/post" as the directory then "./content" will get deleted)
  • fix bug where filters were not being applied in server mode.
contentful-hugo - v1.15.3

Published by joshmossas over 3 years ago

Bugfix

  • fix issue where default shortcode layouts/shortcodes/contentful-hugo/entry-hyperlink.html was missing entryId so a RelPermalink wasn't being rendered.
<!-- before -->
<a href="{{ with .Site.GetPage }}{{ .RelPermalink }}{{ end }}">{{ $linkText }}</a>

<!-- after -->
<a href="{{ with .Site.GetPage $entryId }}{{ .RelPermalink }}{{ end }}">{{ $linkText }}</a>
contentful-hugo - v1.15.2

Published by joshmossas over 3 years ago

Fix bug from v1.15.1 where non-date string fields were getting converted to ISO date strings

contentful-hugo - v1.15.1

Published by joshmossas over 3 years ago

All date fields with time information now get converted to ISO format. Before this only occurred on fields named "date". This should prevent unable to parse date errors in Hugo.

contentful-hugo - v1.15.0

Published by joshmossas over 3 years ago

Dynamic Filename support for repeatable types.

This release closes #39.

The field fileName has been added to repeatable type options. It allows you to dictate the filename based on a Contenful entry property. By default files will be named after the entryId, but now you can override it to something like fields.slug or fields.title. In cases where the specified properties don't exist then the entryId will be used as a fallback.

Ex:

// contentful-hugo.config.js

module.exports = {
  // rest of config
  repeatableTypes: [
    {
      id: "post",
      directory: "content/post",
      fileName: "fields.slug"
    }
  ]
}

Also in this version contentful-hugo will now generate a directory named .contentful-hugo. This is a temporary directory that is used to store rendered file data. For right now it is only being used to track where files were written to so that old copies can be deleted should the filename change. This directory should be added to gitignore.

contentful-hugo -

Published by joshmossas over 3 years ago

running contentful-hugo --server now fetches all the data from Contentful before starting the server. Removing the need to run contentful-hugo && contentful-hugo --server

contentful-hugo -

Published by joshmossas over 3 years ago

  • Fixes 401 error thrown when receiving a webhook from the ContentManagement.Entry.delete event for server mode.
  • Removes body-parser as a dependency
contentful-hugo -

Published by joshmossas over 3 years ago

  • Fix typos in default shortcodes
  • Change $.Site to .Site in default shortcodes
contentful-hugo - v1.14.0

Published by joshmossas over 3 years ago

Multilingual Support Released

This released adds a locales field to the config file, which enables developers to specify multiple locales to pull content from.

Usage instructions can be found here: https://github.com/ModiiMedia/contentful-hugo#localization-options

contentful-hugo -

Published by joshmossas over 3 years ago

Fixes a bug where overrides and filters were being ignored in server mode

contentful-hugo -

Published by joshmossas over 3 years ago

Fixes cannot read property "sys" of undefined error when receiving webhooks from Asset changes and Content Type changes

contentful-hugo -

Published by joshmossas over 3 years ago

Server Mode Beta Release

This release adds the --server flag which fires up a NodeJS server that can receive Contentful webhooks and overwrite / delete the affected files. By default the server runs on port 1414 but can be overwritten with the --port flag.

This release also adds a default sys field to content markdown

sys:
  id: "<entry-id>"
  updatedAt: "<updated-at-date>"
  createdAt: "<created-at-date>"
  revision: <revision-number>
  space: "<space-id>"
  contentType: "<content-type-id>"

The following fields are now marked as depreciated and will be removed in a future release:

  • updated (replaced by sys.updatedAt)
  • createdAt (replaced by sys.createdAt)