airtonzanon/sculpin-contentful-bundle

获取Contentful内容,并将Markdown文件作为文章导入sculpin


README

使用Contentful作为内容管理系统(CMS),它会从Contentful下载内容并将它们添加到source/_[something]目录。

Packagist Version Packagist PHP Version

如何使用

环境变量

contentful_token=<token> # This is the access token for this space. Normally you get both ID and the token in the Contentful web app
contentful_space_id=<space_id> # This is the space ID. A space is like a project folder in Contentful terms

安装

composer require airtonzanon/sculpin-contentful-bundle dev-master

使用方法

app/SculpinKernel.php中应添加

    // ...
    protected function getAdditionalSculpinBundles(): array
    {
        return [
            SculpinContentfulBundle::class,
        ];
    }
    // ...
# Environment variables
$ export contentful_token=<token>
$ export contentful_space_id=<space_id>

# Sculpin command
$ vendor/bin/sculpin contentful:fetch
Created file: source/_til/2021-04-05-first-post.md
Created file: source/_til/2020-12-05-second-post.md
Created file: source/_til/2020-11-23-third-post.md

在Contentful中

  • 内容类型的名称是我们创建的源目录中的名称;
  • 字段language, title, date和contentMarkdown必须存在;

我们还将添加设置,让用户可以在本包中使用他们特定的字段