This package provides a GhostCMS loader for astro. Allowing ease of use of all your GhostCMS content within astro's built in Content Layer!
npm install astro-ghostcms-loader
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
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' // Your GhostCMS Instance URL
apiVersion?: 'v5.0' // OPTIONAL - Allows you to define a specific version (min: v5.0)
}),
}
Query the content collection like any other Astro content collection entry:
import { getCollection } from "astro:content"
const pages = await getCollection("ghostPages"); // Supports the render() function from astro
const posts = await getCollection("ghostPosts"); // Supports the render() function from astro
const tags = await getCollection("ghostTags");
const authors = await getCollection("ghostAuthors");
const tiers = await getCollection("ghostTiers");
const settings = await getEntry('ghostSettings', 'settings');
See the Changelog for the change history of this loader.
If you see any errors or room for improvement, feel free to open an issues or pull request . Thank you in advance for contributing! ❤️