Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/delucis/astro-netlify-cms
Integration to add Netlify CMS’s admin dashboard to any Astro project
https://github.com/delucis/astro-netlify-cms
astro netlify-cms
Last synced: 4 days ago
JSON representation
Integration to add Netlify CMS’s admin dashboard to any Astro project
- Host: GitHub
- URL: https://github.com/delucis/astro-netlify-cms
- Owner: delucis
- Created: 2022-01-26T20:32:40.000Z (almost 3 years ago)
- Default Branch: latest
- Last Pushed: 2023-10-18T02:27:10.000Z (about 1 year ago)
- Last Synced: 2024-10-20T13:09:41.063Z (14 days ago)
- Topics: astro, netlify-cms
- Language: TypeScript
- Homepage:
- Size: 3.99 MB
- Stars: 161
- Watchers: 6
- Forks: 21
- Open Issues: 19
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
- my-awesome-astro - astro-netlify-cms - Astro integration for [Netlify CMS](https://www.netlifycms.org/) (What Do I Use... / If I want to add a CMS?)
- awesome-starred - delucis/astro-netlify-cms - Integration to add Netlify CMS’s admin dashboard to any Astro project (others)
README
![Astro + Netlify CMS](header.png)
Add Netlify CMS’s admin dashboard
to any Astro project## Installation
```bash
npm i astro-netlify-cms
```## What is this?
This is an integration for the [Astro](https://astro.build/) site builder,
which adds support for [Netlify CMS](https://www.netlifycms.org/), an
open-source, Git-based content management system.Adding the integration will:
- Add the Netlify CMS dashboard at `/admin` (or another route if you prefer)
- Inject Netlify’s [Identity Widget](https://github.com/netlify/netlify-identity-widget) across your site to support logging in to the admin app
- Run a [local proxy server](https://www.netlifycms.org/docs/beta-features/#working-with-a-local-git-repository) in `dev` mode to allow local content updates via the CMSUsually each of these requires individual set up and configuration. Using this integration, you configure your CMS once in `astro.config.mjs`, sit back, and enjoy!
> Looking for a quick way to get started? [Try out the Blog Starter with Netlify CMS →](https://github.com/delucis/astro-netlify-cms-starter)
## Usage
### Adding the integration
To add Netlify CMS to your project, import and use the integration in your
Astro config file, adding it to the `integrations` array.```js
// astro.config.mjsimport { defineConfig } from 'astro/config';
import NetlifyCMS from 'astro-netlify-cms';export default defineConfig({
integrations: [
NetlifyCMS({
config: {
backend: {
name: 'git-gateway',
branch: 'main',
},
collections: [
// Content collections
],
},
}),
],
});
```### Configuration options
You can pass an options object to the integration to configure how it behaves.
#### `adminPath`
**Type:** `string`
**Default:** `'/admin'`Determines the route where the Netlify CMS admin dashboard will be available on your site.
Feeling nostalgic for WordPress? You could set this to `'/wp-admin'`!
#### `config`
**Type:** `CmsConfig`
This option is **required**. It allows you to configure Netlify CMS with the
same options you would use when using Netlify CMS’s `config.yml` file format.You can see [a full list of configuration options in the Netlify CMS docs](https://www.netlifycms.org/docs/configuration-options/).
At a minimum, you _must_ set the `backend` and `collections` options:
```js
config: {
// Use Netlify’s “Git Gateway” authentication and target our default branch
backend: {
name: 'git-gateway',
branch: 'main',
},
collections: [
// Define a blog post collection
{
name: 'posts',
label: 'Blog Posts',
folder: 'src/pages/posts',
create: true,
delete: true,
fields: [
{ name: 'title', widget: 'string', label: 'Post Title' },
{ name: 'body', widget: 'markdown', label: 'Post Body' },
],
},
],
};
```#### `previewStyles`
**Type:** `Array`
Sets custom CSS styles to apply in the Netlify CMS preview pane.
You can provide URLs to external CSS stylesheets (Google Fonts for example), paths to local CSS files in your project, or even raw CSS strings:
```js
previewStyles: [
// Path to a local CSS file, relative to your project’s root directory
'/src/styles/main.css',
// An npm module identifier
'@fontsource/roboto',
// A URL to an externally hosted CSS file
'https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap',
// Raw CSS!
['p { color: red; }', { raw: true }],
];
```#### `disableIdentityWidgetInjection`
**Type:** `boolean`
**Default:** `false`By default, `astro-netlify-cms` injects Netlify’s [Identity Widget](https://github.com/netlify/netlify-identity-widget) across your site to enable authentication. If you only want to inject the widget on the admin route, you can set `disableIdentityWidgetInjection: true`.
## To-do
- Support registering custom preview components to render content as it is edited.
- Support registering custom block components for use in the Markdown editor.