-
-
Save Adammatthiesen/8bd008aef5aaf5d5f90d2e8014d533e8 to your computer and use it in GitHub Desktop.
astro-ghostCMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CONTENT_API_KEY=YOURAPIKEY | |
CONTENT_API_URL=https://ghost.io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For fresh Install | |
npm create astro@latest | |
# Create Empty Install with standard typescript | |
# Then Delete entire `pages` folder under `/src/` | |
npx astro add @matthiesenxyz/astro-ghostcms |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineConfig } from "astro/config"; | |
import sitemap from "@astrojs/sitemap"; //optional but recommended | |
import GhostCMS from '@matthiesenxyz/astro-ghostcms'; | |
// https://astro.build/config | |
export default defineConfig({ | |
site: "https://YOUR-DOMAIN-HERE.com" | |
integrations: [GhostCMS()], | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostPostbySlug Function | |
import { getGhostPostbySlug } from '@matthiesenxyz/astro-ghostcms'; | |
// GET SLUG from /blog/[slug] | |
const { slug } = Astro.params; | |
// GET CURRENT POST BY PASSING SLUG TO FUNCTION | |
const ghostPost = await getGhostPostbySlug(slug); | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostPosts Function | |
import { getGhostPosts } from '@matthiesenxyz/astro-ghostcms'; | |
// GET LIST OF ALL POSTS | |
const ghostPosts = await getGhostPosts(); | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostPostsbyTag, and GhostTagbySlug Functions | |
import { getGhostPostsbyTag, getGhostTagbySlug } from '@matthiesenxyz/astro-ghostcms'; | |
// GET SLUG from /blog/tag/[slug] | |
const { slug } = Astro.params; | |
// GET TAG BY SLUG TO DISPLAY TAG INFO | |
const ghostTag = await getGhostTagbySlug(slug); | |
// GET POSTS FILTERED BY TAG SLUG | |
const ghostPosts = await getGhostPostsbyTag(slug) | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostFeaturedPosts Function | |
import { getGhostFeaturedPosts } from "@matthiesenxyz/astro-ghostcms"; | |
// CREATE INTERFACE TO PASS 'setLimit' for POST LIMIT | |
interface Props { | |
setLimit?:number; | |
} | |
// IF 'setLimit' IS NOT DEFINED AS PROP THEN MAKE IT DEFAULT TO 'undefined' | |
const { setLimit = undefined } = Astro.props | |
// GET POSTS with Limit | |
const ghostPosts = await getGhostFeaturedPosts(setLimit); | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostPostbySlug Function | |
import { getGhostPage } from '@matthiesenxyz/astro-ghostcms/api'; | |
// GET SLUG from /blog/[slug] | |
const { slug } = Astro.params; | |
// GET CURRENT POST BY PASSING SLUG TO FUNCTION | |
const ghostpage = await getGhostPage(slug); | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostAuthors Function | |
import { getGhostPages } from "@matthiesenxyz/astro-ghostcms/api"; | |
// GET LIST OF ALL AUTHORS | |
const ghostPages = await getGhostPages(); | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostAuthors Function | |
import { getGhostSettings } from "@matthiesenxyz/astro-ghostcms/api"; | |
// GET LIST OF ALL AUTHORS | |
const ghostSettings = await getGhostSettings(); | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
// IMPORT {GET} GhostFeaturedPosts Function | |
import { getGhostRecentPosts } from "@matthiesenxyz/astro-ghostcms"; | |
// CREATE INTERFACE TO PASS 'setLimit' for POST LIMIT | |
interface Props { | |
setLimit?:number; | |
} | |
// IF 'setLimit' IS NOT DEFINED AS PROP THEN MAKE IT DEFAULT TO 'undefined' | |
const { setLimit = undefined } = Astro.props | |
// GET POSTS with Limit | |
const ghostPosts = await getGhostRecentPosts(setLimit); | |
--- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rss from "@astrojs/rss"; | |
import { getGhostPosts } from '@matthiesenxyz/astro-ghostcms'; | |
export async function GET() { | |
const ghostPosts = await getGhostPosts(); | |
return rss({ | |
title: "Site Title", | |
description: "Site Description", | |
site: import.meta.env.SITE, | |
//stylesheet: '/rss/styles.xsl', | |
items: ghostPosts.map((ghostPost) => ({ | |
title: ghostPost.title, | |
pubDate: ghostPost.published_at, | |
description: ghostPost.excerpt, | |
link: `/blog/${ghostPost.slug}/`, | |
})), | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment