-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from foomo/contentful-v0.5.0
Contentful v0.5.1
- Loading branch information
Showing
45 changed files
with
1,349 additions
and
575 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: '/' | ||
schedule: | ||
interval: weekly | ||
- package-ecosystem: gomod | ||
directory: '/' | ||
schedule: | ||
interval: weekly |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,48 @@ | ||
# gocontentful | ||
# Gocontentful | ||
|
||
A Contentful API code generator for Go. Features: | ||
Gocontentful is a command line tool that generates a set of APIs for the [Go Language](https://go.dev) to interact with a [Contentful](https://www.contentful.com) CMS space. | ||
|
||
- Creates and updates a full set of Value Objects from Contentful content model | ||
- Supports CDA, CPA and CMA operations through a simplified, idiomatic Go API based on the model | ||
- Caches entire spaces and handles updates automatically | ||
- Simplifies management/resolution of references | ||
- Adds several utility functions for RichText from/to HTML conversion, assets handling and more | ||
Unlike the plain Contentful API for Go, the Gocontentful API is idiomatic. Go types are provided with names that mirror the content types of the Contentful space, and get/set methods are named after each field. | ||
|
||
Full documentation available at [foomo.org](https://www.foomo.org/docs/projects/cms/gocontentful/introduction) | ||
In addition, Gocontentful supports in-memory caching and updates of spaces. This way, the space is always accessible through fast Go function calls, even offline. | ||
|
||
## What is Contentful | ||
|
||
[Contentful](https://www.contentful.com/) is a content platform (often referred to as headless CMS) for [micro-content](https://www.contentful.com/r/knowledgebase/content-as-a-microservice/). | ||
|
||
Unlike traditional CMSes, there's no pages or content trees in Contentful. The data model is built from scratch for the purpose of the consuming application, is completely flexible and can be created and hot-changed through the same Web UI that the content editors use. The model dictates which content types can reference others and the final structure is a graph. | ||
|
||
## How applications interact with Contentful | ||
|
||
Contentful hosts several APIs that remote applications use to create, retrieve, update and delete content. Content is any of the following: | ||
|
||
- **Entries**, each with a content type name and a list of data fields as defined by the developer in the content model editor at Contentful | ||
- **Assets** (images, videos, other binary files) | ||
|
||
The Contentful APIs exist as either REST or GraphQL endpoints. Gocontentful only supports the REST APIs. | ||
|
||
The REST APIs used to manage and retrieve content use standard HTTP verbs (GET, POST, PUT and DELETE) and a JSON payload for both the request (where needed) and the response. | ||
|
||
## What is gocontentful | ||
|
||
A golang API code generator that simplifies interacting with a Contentful space. The generated API: | ||
|
||
- Supports most of the Contentful APIs to perform all read/write operation on entries and assets | ||
- Hides the complexity of the Contentful REST/JSON APIs behind an idiomatic set of golang functions and methods | ||
- Allows for in-memory caching of an entire Contentful space | ||
|
||
## Why we need a Go API generator | ||
|
||
While it's perfectly fine to call a REST service and receive data in JSON format, in Go that is not very practical. For each content type, the developer needs to maintan type definitions by hand and decode the JSON coming from the Contentful server into the value object. | ||
|
||
In addition, calling a remote API across the Internet each time a piece of content is needed, even multiple times for a single page rendering, can have significant impact on performance. | ||
|
||
Gocontentful generates a Go API that handles both issues above and can be regenerated every time the content model changes. The developer never needs to update the types by hand, or deal with the complexity of caching content locally. It all happens auytomatically in the generated client. | ||
|
||
> **NOTE** - _How much code does Gocontentful generate? In a real-world production scenario where Gocontentful is in use as of 2024, a space content model with 43 content types of various field counts generates around 65,000 lines of Go code._ | ||
|
||
[//]: # (Footer) | ||
|
||
--- | ||
|
||
Read the documentation: [Getting Started](docs/00-gettingstarted.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
package config | ||
|
||
type Config struct { | ||
SpaceID string `yaml:"spaceId,omitempty"` | ||
Environment string `yaml:"environment,omitempty"` | ||
ExportFile string `yaml:"exportFile,omitempty"` | ||
ContentTypes []string `yaml:"contentTypes,omitempty"` | ||
PathTargetPackage string `yaml:"pathTargetPackage,omitempty"` | ||
RequireVersion string `yaml:"requireVersion,omitempty"` | ||
SpaceID string `json:"spaceId,omitempty" yaml:"spaceId,omitempty"` | ||
Environment string `json:"environment,omitempty" yaml:"environment,omitempty"` | ||
ExportFile string `json:"exportFile,omitempty" yaml:"exportFile,omitempty"` | ||
ContentTypes []string `json:"contentTypes,omitempty" yaml:"contentTypes,omitempty"` | ||
PathTargetPackage string `json:"pathTargetPackage,omitempty" yaml:"pathTargetPackage,omitempty"` | ||
RequireVersion string `json:"requireVersion,omitempty" yaml:"requireVersion,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
--- | ||
sidebar_label: Setup | ||
sidebar_position: 1 | ||
--- | ||
|
||
# Gocontentful Setup | ||
|
||
## Installation | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,3 @@ | ||
--- | ||
sidebar_label: The Client At Work | ||
sidebar_position: 0 | ||
--- | ||
|
||
# The Client At Work | ||
|
||
This section explains how to work with the Gocontentful client to create, retrieve, update and delete entities, such as entries and assets. It also walks you through working with references to handle a graph-like structure in a Contentful space. Finally, it dives into some more specific functionalities, like converting to/from RichText and HTML. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.