Decap CMS 和 Astro
开盖 CMS(以前称为 Netlify CMS)是一个基于 Git 的开源内容管理系统。
¥Decap CMS (formerly Netlify CMS) is an open-source, Git-based content management system.
Decap 允许你充分利用 Astro 的所有功能,包括图片优化和内容收集。
¥Decap allows you to take full advantage of all of Astro’s features, including image optimization and content collections.
Decap 向你的项目添加了一条路由(通常是 /admin
),该路由将加载 React 应用,以允许授权用户直接从部署的网站管理内容。Decap 将直接将更改提交到你的 Astro 项目的源存储库。
¥Decap adds a route (typically /admin
) to your project that will load a React app to allow authorized users to manage content directly from the deployed website. Decap will commit changes directly to your Astro project’s source repository.
安装 DecapCMS
Section titled 安装 DecapCMS¥Installing DecapCMS
将 Decap 添加到 Astro 有两种选择:
¥There are two options for adding Decap to Astro:
-
通过包管理器安装 Decap 使用以下命令:
-
将包导入页面
<body>
中的<script>
标记
¥Configuration
-
Create a static admin folder at
public/admin/
-
Add
config.yml
topublic/admin/
:Directorypublic
Directoryadmin
- config.yml
-
To add support for content collections, configure each schema in
config.yml
. The following example configures ablog
collection, defining alabel
for each entry’s frontmatter property: -
Add the
admin
route for your React app. This file can be eitherpublic/admin/index.html
alongside yourconfig.yml
or, if you prefer to use an Astro route,src/pages/admin.astro
.Directorypublic
Directoryadmin
- config.yml
- index.html
-
To enable media uploads to a specific folder via the Decap editor, add an appropriate path:
请参阅 Decap CMS 配置文档 以了解完整的说明和选项。
¥See the the Decap CMS configuration documentation for full instructions and options.
¥Usage
导航到 yoursite.com/admin/
以使用 Decap CMS 编辑器。
¥Navigate to yoursite.com/admin/
to use the Decap CMS editor.
¥Authentication
使用 Netlify Identity 的 Decap CMS
Section titled 使用 Netlify Identity 的 Decap CMS¥Decap CMS with Netlify Identity
Decap CMS 最初由 Netlify 开发,对 Netlify Identity 提供一流的支持。
¥Decap CMS was originally developed by Netlify and has first class support for Netlify Identity.
当部署到 netlify 时,通过 Netlify 仪表板为你的项目配置身份,并在项目的 admin
路由中包含 Netlify Identity 小部件。如果你计划通过电子邮件邀请新用户,可以选择在你网站的主页上包含身份小部件。
¥When deploying to netlify, configure Identity for your project via the Netlify dashboard and include the Netlify Identity Widget on the admin
route of your project. Optionally include the Identity Widget on the homepage of your site if you plan to invite new users via email.
使用外部 OAuth 客户端的 Decap CMS
Section titled 使用外部 OAuth 客户端的 Decap CMS¥Decap CMS with External OAuth Clients
当部署到 Netlify 以外的托管服务提供商时,你必须创建自己的 OAuth 路由。
¥When deploying to hosting providers other than Netlify, you must create your own OAuth routes.
在 Astro 中,这可以通过在项目中配置启用 server
或 hybrid
输出 的按需渲染路由来实现。
¥In Astro, this can be done with on-demand rendered routes in your project configured with server
or hybrid
output enabled.
请参阅 Decap 的 OAuth 文档 以获取兼容的社区维护的 OAuth 客户端列表。
¥See Decap’s OAuth Docs for a list of compatible community-maintained OAuth clients.
¥Community Resources
-
Netlify Identity 模板:astro-decap-ssg-netlify
-
使用 Astro 模板按需渲染 Oauth 路由:astro-decap-starter-ssr
-
博客文章:使用基于 Git 的 CMS 创作 Astro 网站的内容,作者:阿夫塔布·阿拉姆
-
Youtube 教程:使用 Astro 和 NetlifyCMS 在几分钟内创建自定义博客!,作者:Kumail Pirzada
¥Production Sites
以下站点在生产中使用 Astro + Decap CMS:
¥The following sites use Astro + Decap CMS in production:
-
yunielacosta.com by Yuniel Acosta — GitHub 上的源代码 (Netlify CMS)
-
portfolioris.nl by Joris Hulsbosch – GitHub 上的源代码
¥Themes