diff --git a/.env.demo b/.env.demo
new file mode 100644
index 00000000..fbeecd6d
--- /dev/null
+++ b/.env.demo
@@ -0,0 +1,2 @@
+CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48
+CONTENT_API_URL=https://ghostdemo.matthiesen.xyz
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 00000000..92068a14
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,24 @@
+# build output
+dist
+.vercel
+# generated types
+.astro/
+# dependencies
+node_modules/
+.snowpack/
+
+# logs
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# environment variables
+.env
+.env.production
+
+# macOS-specific files
+.DS_Store
+
+# editor
+.idea
+package-lock.json
\ No newline at end of file
diff --git a/README.md b/README.md
index 4253ed39..339063db 100644
--- a/README.md
+++ b/README.md
@@ -1,42 +1,95 @@
# Welcome to Astro-GhostCMS
-This addon uses the `@tryghost/content-api` and creates astro friendly functions to interface between ghost and astro.
+Astro minimum Version: **Astro v4.0**
-*This package contains a independent copy of the tryghost content-api.js that is used to establish the connection so this package dose not depend on `@tryghost/content-api` package.*
+This Integration is 2 parts. Firstly, there is the API portion that uses the `@tryghost/content-api` to create the link between astro and GhostCMS. From there we move to the Second Part, which is a theme pre-programmed to pull ALL of its data from GhostCMS iteself instead of storing any data locally outside of Build.
-## Astro Integration Mode *(Planned for V2)*
+- *This package contains a independent copy of the tryghost content-api.js that is used to establish the connection so this package dose not depend on `@tryghost/content-api` package.*
+- If you are looking for a more Customizable option please check [astro-ghostcms-basetheme](https://github.com/MatthiesenXYZ/astro-ghostcms-basetheme)
+- This project is not setup for SSR in Integration mode. As such is will most likely not function properly in that mode. You will need to build your own project around the API or customize the *basetheme* linked above.
-This is coming soon. And will allow the user to utilize the prebuilt astro-ghostcms-basetheme to be integrated through this main project. This feature is not yet setup or integrated. If you want a easy quick and simple deploy please copy this Template Repo, [astro-ghostcms-basetheme](https://github.com/MatthiesenXYZ/astro-ghostcms-basetheme) This will get you setup and ready to deploy in minutes using this addon!
+## Astro Integration Mode
-## Manual Installation
+In this mode, the addon will not be just an API, but will be a full Route takeover, there is plans to add more themes in time, but for now there is only the base Casper theme based on Ghost's main Theme.
+
+### Astro Add Installation *(Coming Soon)*
+
+```
+# NOT READY YET DO NOT USE
+astro add @matthiesenxyz/astro-ghostcms
+```
+
+### Manual Installation
```
npm i @matthiesenxyz/astro-ghostcms
```
-Must create `.env` with the following:
+Then set your astro.config.ts to look like this:
+
+```ts
+import { defineConfig } from "astro/config";
+import sitemap from "@astrojs/sitemap";
+import GhostCMS from '@matthiesenxyz/astro-ghostcms';
+
+// https://astro.build/config
+export default defineConfig({
+ site: "https://YOUR-DOMAIN-HERE.com"
+ integrations: [sitemap(), GhostCMS()],
+});
+```
+
+### Dont forget to set your environment Variables!
+
+You must also create 2 environment variables in a `.env` file with the following:
```env
-CONTENT_API_KEY=
-CONTENT_API_URL=
+CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48
+CONTENT_API_URL=https://ghostdemo.matthiesen.xyz
```
**When you deploy your install dont forget to set the above ENVIRONMENT VARIABLES!**
-Astro minimum Version: **Astro v4.0**
+#### Created Routes
-Dependencies:
-- **Axios v1.0** *Will be auto installed*
-- **Typescript v5.3.3** *Will be auto installed*
+The routes are the same as a standard Ghost Blog so you can migrate to Astro easily.
-## Function Usage Examples:
+| Route | Content |
+| --------------------- | ----------------------------------------- |
+| `/` | Homepage with recents/features Blog Posts |
+| `/[slug]` | Post or Page |
+| `/author/[slug]` | Author page with related posts |
+| `/authors` | All the authors |
+| `/tag[slug]` | Tag page with related posts |
+| `/tags` | All the tags |
+| `/archives/[...page]` | All the posts, paginated |
+
+
+## Manual Function Mode (DIY MODE)
+
+In this mode the integration will not deploy routes at all. you will have to build your own website to utilize the exported functions listed below.
+
+```
+npm i @matthiesenxyz/astro-ghostcms
+```
+
+You must also create 2 environment variables in a `.env` file with the following:
+
+```env
+CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48
+CONTENT_API_URL=https://ghostdemo.matthiesen.xyz
+```
+
+**When you deploy your install dont forget to set the above ENVIRONMENT VARIABLES!**
+
+## Manual Function Usage Examples:
### getGhostPosts() - Get list of posts
```astro
---
// IMPORT {GET} GhostPosts Function
-import { getGhostPosts } from '@matthiesenxyz/astro-ghostcms';
+import { getGhostPosts } from '@matthiesenxyz/astro-ghostcms/api';
// GET LIST OF ALL POSTS
const ghostPosts = await getGhostPosts();
---
@@ -47,7 +100,7 @@ const ghostPosts = await getGhostPosts();
```astro
---
// IMPORT {GET} GhostFeaturedPosts Function
-import { getGhostRecentPosts } from "@matthiesenxyz/astro-ghostcms";
+import { getGhostRecentPosts } from "@matthiesenxyz/astro-ghostcms/api";
// CREATE INTERFACE TO PASS 'setLimit' for POST LIMIT
interface Props {
setLimit?:number;
@@ -64,7 +117,7 @@ const ghostPosts = await getGhostRecentPosts(setLimit);
```astro
---
// IMPORT {GET} GhostFeaturedPosts Function
-import { getGhostFeaturedPosts } from "@matthiesenxyz/astro-ghostcms";
+import { getGhostFeaturedPosts } from "@matthiesenxyz/astro-ghostcms/api";
// CREATE INTERFACE TO PASS 'setLimit' for POST LIMIT
interface Props {
setLimit?:number;
@@ -81,7 +134,7 @@ const ghostPosts = await getGhostFeaturedPosts(setLimit);
```astro
---
// IMPORT {GET} GhostPostbySlug Function
-import { getGhostPostbySlug } from '@matthiesenxyz/astro-ghostcms';
+import { getGhostPostbySlug } from '@matthiesenxyz/astro-ghostcms/api';
// GET SLUG from /blog/[slug]
const { slug } = Astro.params;
// GET CURRENT POST BY PASSING SLUG TO FUNCTION
@@ -94,7 +147,7 @@ const ghostPost = await getGhostPostbySlug(slug);
```astro
---
// IMPORT {GET} GhostPostsbyTag, and GhostTagbySlug Functions
-import { getGhostPostsbyTag, getGhostTagbySlug } from '@matthiesenxyz/astro-ghostcms';
+import { getGhostPostsbyTag, getGhostTagbySlug } from '@matthiesenxyz/astro-ghostcms/api';
// GET SLUG from /blog/tag/[slug]
const { slug } = Astro.params;
// GET TAG BY SLUG TO DISPLAY TAG INFO
@@ -109,7 +162,7 @@ const ghostPosts = await getGhostPostsbyTag(slug)
```astro
---
// IMPORT {GET} GhostTags Function
-import { getGhostTags } from "@matthiesenxyz/astro-ghostcms";
+import { getGhostTags } from "@matthiesenxyz/astro-ghostcms/api";
// GET LIST OF ALL TAGS
const ghostTags = await getGhostTags();
---
@@ -120,7 +173,7 @@ const ghostTags = await getGhostTags();
```astro
---
// IMPORT {GET} GhostAuthors Function
-import { getGhostAuthors } from "@matthiesenxyz/astro-ghostcms";
+import { getGhostAuthors } from "@matthiesenxyz/astro-ghostcms/api";
// GET LIST OF ALL AUTHORS
const ghostAuthors = await getGhostAuthors();
---
@@ -131,7 +184,7 @@ const ghostAuthors = await getGhostAuthors();
```astro
---
// IMPORT {GET} GhostAuthors Function
-import { getGhostPages } from "@matthiesenxyz/astro-ghostcms";
+import { getGhostPages } from "@matthiesenxyz/astro-ghostcms/api";
// GET LIST OF ALL AUTHORS
const ghostPages = await getGhostPages();
---
@@ -142,7 +195,7 @@ const ghostPages = await getGhostPages();
```astro
---
// IMPORT {GET} GhostPostbySlug Function
-import { getGhostPage } from '@matthiesenxyz/astro-ghostcms';
+import { getGhostPage } from '@matthiesenxyz/astro-ghostcms/api';
// GET SLUG from /blog/[slug]
const { slug } = Astro.params;
// GET CURRENT POST BY PASSING SLUG TO FUNCTION
@@ -155,7 +208,7 @@ const ghostpage = await getGhostPage(slug);
```astro
---
// IMPORT {GET} GhostAuthors Function
-import { getGhostSettings } from "@matthiesenxyz/astro-ghostcms";
+import { getGhostSettings } from "@matthiesenxyz/astro-ghostcms/api";
// GET LIST OF ALL AUTHORS
const ghostSettings = await getGhostSettings();
---
diff --git a/index.ts b/index.ts
index b19b164e..82dd7edd 100644
--- a/index.ts
+++ b/index.ts
@@ -1,5 +1,51 @@
-// FUNCTION EXPORTS
-export { getGhostPosts, getGhostRecentPosts, getGhostFeaturedPosts, getGhostPostbySlug, getGhostPostsbyTag, getGhostTags, getGhostTagbySlug, getGhostAuthors, getGhostPages, getGhostPage, getGhostSettings } from './src/functions';
+import type { AstroIntegration } from "astro"
-// TYPE EXPORTS
-export type { PostOrPage, ArrayOrValue, Author, Authors, BrowseFunction, CodeInjection, Excerpt, Facebook, FieldParam, FilterParam, FormatParam, GhostAPI, GhostContentAPIOptions, GhostData, GhostError, Identification, IncludeParam, LimitParam, Metadata, Nullable, OrderParam, PageParam, Pagination, Params, PostsOrPages, ReadFunction, Settings, SettingsResponse, SocialMedia, Tag, TagVisibility, Tags, Twitter } from './index.d';
\ No newline at end of file
+export default function GhostCMS(): AstroIntegration {
+ return {
+ name: 'astro-ghostcms',
+ hooks: {
+ 'astro:config:setup': async ({
+ injectRoute,
+ logger,
+ }) => {
+
+ injectRoute({
+ pattern: '/',
+ entrypoint: '@matthiesenxyz/astro-ghostcms/index.astro'
+ })
+
+ injectRoute({
+ pattern: '/[slug]',
+ entrypoint: '@matthiesenxyz/astro-ghostcms/[slug].astro'
+ })
+
+ injectRoute({
+ pattern: '/tags',
+ entrypoint: '@matthiesenxyz/astro-ghostcms/tags.astro'
+ })
+
+ injectRoute({
+ pattern: '/authors',
+ entrypoint: '@matthiesenxyz/astro-ghostcms/authors.astro'
+ })
+
+ injectRoute({
+ pattern: '/tag/[slug]',
+ entrypoint: '@matthiesenxyz/astro-ghostcms/tag/[slug].astro'
+ })
+
+ injectRoute({
+ pattern: '/author/[slug]',
+ entrypoint: '@matthiesenxyz/astro-ghostcms/author/[slug].astro'
+ })
+
+ injectRoute({
+ pattern: '/archives/[...page]',
+ entrypoint: '@matthiesenxyz/astro-ghostcms/archives/[...page].astro'
+ })
+
+ logger.info('Astro GhostCMS Plugin Loaded!')
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/package.json b/package.json
index 98395732..349ca7cb 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "@matthiesenxyz/astro-ghostcms",
"description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content",
- "version": "1.0.6",
+ "version": "2.0.0",
"author": "MatthiesenXYZ (https://matthiesen.xyz)",
"type": "module",
"license": "MIT",
@@ -14,31 +14,63 @@
},
"homepage": "https://github.com/MatthiesenXYZ/astro-ghostcms",
"exports": {
- ".": "./index.ts"
+ "./api": "./src/api/index.ts",
+ "./index.astro": "./src/routes/index.astro",
+ "./[slug].astro": "./src/routes/[slug].astro",
+ "./tags.astro": "./src/routes/tags.astro",
+ "./authors.astro": "./src/routes/authors.astro",
+ "./tag/[slug].astro": "./src/routes/tag/[slug].astro",
+ "./author/[slug].astro": "./src/routes/author/[slug].astro",
+ "./archives/[...page].astro": "./src/routes/archives/[...page].astro",
+ "./DefaultLayout": "./src/layouts/default.astro"
},
"main": "index.ts",
- "types": "index.d.ts",
+ "types": "src/api/ghosttypes.ts",
"files": [
"src",
- "index.ts",
- "index.d.ts"
+ "index.ts"
],
"keywords": [
"astro-component",
+ "astro-integration",
"withastro",
+ "astro",
+ "blog",
+ "content",
+ "integration",
"ghost",
- "ghostcms"
+ "ghostcms",
+ "ghostcms-theme",
+ "ghost-theme",
+ "astro-theme"
],
- "scripts": {},
- "devDependencies": {
- "astro": "^4.1.1"
- },
- "peerDependencies": {
- "astro": "^4.0.0"
+ "scripts": {
+ "dev": "astro dev",
+ "build": "astro build",
+ "typecheck": "astro check && tsc --noEmit",
+ "preview": "astro preview",
+ "format": "prettier --write .",
+ "lint": "eslint --cache --cache-location ./node_modules/.cache/eslint ."
},
"dependencies": {
"@astrojs/check": "^0.3.4",
"typescript": "^5.3.3",
- "axios": "^1.0.0"
+ "axios": "^1.0.0",
+ "astro-font": "^0.0.72",
+ "@astrojs/renderer-svelte": "0.5.2",
+ "@astrojs/rss": "^4.0.2",
+ "@astrojs/sitemap": "^3.0.4",
+ "@snowpack/plugin-dotenv": "^2.2.0",
+ "@typescript-eslint/eslint-plugin": "^6.5.0",
+ "@typescript-eslint/parser": "^6.5.0",
+ "astro": "^4.1.2",
+ "eslint": "^8.48.0",
+ "eslint-config-prettier": "^9.0.0",
+ "eslint-plugin-astro": "^0.29.0",
+ "prettier": "^3.0.3",
+ "prettier-plugin-astro": "^0.12.0",
+ "sass": "^1.66.1",
+ "tiny-invariant": "^1.3.1",
+ "vite": "^4.4.9"
}
}
diff --git a/src/functions.ts b/src/api/functions.ts
similarity index 99%
rename from src/functions.ts
rename to src/api/functions.ts
index f9500485..021b83ca 100644
--- a/src/functions.ts
+++ b/src/api/functions.ts
@@ -1,5 +1,5 @@
// IMPORT Ghost Types
-import type { PostOrPage, PostsOrPages, Authors, Tag, Tags, ArrayOrValue, IncludeParam, LimitParam, Settings, Nullable } from '..';
+import type { PostOrPage, PostsOrPages, Authors, Tag, Tags, ArrayOrValue, IncludeParam, LimitParam, Settings, Nullable } from './ghosttypes';
// IMPORT Ghost API Client
import api from './interface';
diff --git a/index.d.ts b/src/api/ghosttypes.ts
similarity index 100%
rename from index.d.ts
rename to src/api/ghosttypes.ts
diff --git a/src/api/index.ts b/src/api/index.ts
new file mode 100644
index 00000000..1621bb3a
--- /dev/null
+++ b/src/api/index.ts
@@ -0,0 +1,5 @@
+// FUNCTION EXPORTS
+export { getGhostPosts, getGhostRecentPosts, getGhostFeaturedPosts, getGhostPostbySlug, getGhostPostsbyTag, getGhostTags, getGhostTagbySlug, getGhostAuthors, getGhostPages, getGhostPage, getGhostSettings } from './functions';
+
+// TYPE EXPORTS
+export type { PostOrPage, ArrayOrValue, Author, Authors, BrowseFunction, CodeInjection, Excerpt, Facebook, FieldParam, FilterParam, FormatParam, GhostAPI, GhostContentAPIOptions, GhostData, GhostError, Identification, IncludeParam, LimitParam, Metadata, Nullable, OrderParam, PageParam, Pagination, Params, PostsOrPages, ReadFunction, Settings, SettingsResponse, SocialMedia, Tag, TagVisibility, Tags, Twitter } from './ghosttypes';
\ No newline at end of file
diff --git a/src/interface.js b/src/api/interface.js
similarity index 100%
rename from src/interface.js
rename to src/api/interface.js
diff --git a/src/tryghost-content-api.js b/src/api/tryghost-content-api.js
similarity index 100%
rename from src/tryghost-content-api.js
rename to src/api/tryghost-content-api.js
diff --git a/src/components/AuthorCard.astro b/src/components/AuthorCard.astro
new file mode 100644
index 00000000..23e4ab86
--- /dev/null
+++ b/src/components/AuthorCard.astro
@@ -0,0 +1,80 @@
+---
+import { getGhostImgPath } from "../utils";
+import type { Settings, Author } from "../api";
+export type Props = {
+ author: Author;
+ wide?: boolean;
+ addClass?: string;
+ settings: Settings;
+ showCover?: boolean;
+};
+const {
+ author,
+ wide = false,
+ settings,
+ showCover = true,
+} = Astro.props as Props;
+---
+
+