Decap CMS

运行 Decap CMS 以更新站点内容

配置参数

local boolean

Force the local_backend option. By default is detected automatically.

previewStyle string

Path of a CSS file with custom styles for the preview

path string

Directory path of the admin (by default /admin/)

Default:
"/admin/"
configKey string

Data key of the configuration

Default:
"decap_cms"
identity netlify

Whether use a identity method

extraHTML string

Custom HTML code to append in the index.html page

Default:
""
proxyCommand string

Command to run the proxy server

Default:
"deno run --allow-read --allow-net=0.0.0.0 --allow-write --allow-env npm:decap-server@3.1.2"

描述

此插件生成运行 Decap CMS 的代码,以便在本地和远程环境中更快更轻松地更新站点内容。默认情况下,CMS 可通过 /admin/ 路径访问,但您可以在 path 选项中更改它。

安装

在您的 _config.ts 文件中导入此插件以使用它:

import lume from "lume/mod.ts";
import decapCMS from "lume/plugins/decap_cms.ts";

const site = lume();

site.use(decapCMS(/* Options */)); // Options

export default site;

用法

在项目的根目录中创建数据文件 /_data/decap_cms.yml。请参阅 Decap CMS 站点中的配置选项

backend:
  name: git-gateway
  branch: master

media_folder: statics

collections:
  - label: Posts
    name: posts
    description: List of posts // 文章列表
    folder: posts
    extension: md
    create: true
    fields:
      - label: Title
        name: title
        widget: string
      - label: Content
        name: body
        widget: markdown

这将创建带有 CMS 配置的 decap_cms 键。请注意,它不一定必须是 yaml 文件;您可以使用任何数据格式(JSON、JavaScript 模块、TypeScript 模块等)。此插件将生成页面 /admin/index.html/admin/config.yml 以运行 CMS。

本地模式

如果站点位置主机名为 localhost,则默认启用本地模式。这意味着在运行 lume --serve 后,您可以转到 http://localhost:3000/admin/ 以访问 CMS 并更改站点的内容。

请记住,本地模式运行 deno run --allow-read --allow-net=0.0.0.0 --allow-write --allow-env npm:decap-server 以启动 CMS 的本地代理服务器。您可以使用 proxyCommand 选项更改此命令,或通过在插件配置中设置 local: false 来禁用本地模式。

权限

默认情况下,Lume 在启用所有权限的情况下执行。如果您想配置权限,此插件需要以下权限:

  • --allow-run=npm:decap-server
  • --allow-net=0.0.0.0
  • --allow-env
  • --allow-read
  • --allow-write