astro-ghostcms-loader
This package provides a GhostCMS loader for astro. Allowing ease of use of all your GhostCMS content within astro's built in Content Layer!
Installation
npm install astro-ghostcms-loader
Usage
Requirements
To use this loader, it is required that you be on at least Astro v5.0.0
Also make sure to create and set your .env
file with the following:
GHOST_CONTENT_API_KEY=your_api_key_here
Config
In src/content.config.ts
, import and configure the loaderCollection:
import { GhostCMSLoaderCollection} from 'astro-ghostcms-loader';
export const collections = {
...GhostCMSLoaderCollection({
ghostUrl: 'https://demo.ghost.io'
apiVersion?: 'v5.0'
}),
}
Calling the created GhostCMS collections
Query the content collection like any other Astro content collection entry:
import { getCollection } from "astro:content"
const pages = await getCollection("ghostPages");
const posts = await getCollection("ghostPosts");
const tags = await getCollection("ghostTags");
const authors = await getCollection("ghostAuthors");
const tiers = await getCollection("ghostTiers");
const settings = await getEntry('ghostSettings', 'settings');
Changelog
See the Changelog for the change history of this loader.
Contribution
If you see any errors or room for improvement, feel free to open an issues or pull request . Thank you in advance for contributing! ❤️