Merge pull request #6 from MatthiesenXYZ/pnpm-monorepo-migration

Pnpm monorepo migration
This commit is contained in:
Adam Matthiesen 2024-01-23 12:05:56 -08:00 committed by GitHub
commit 18173ea8d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
130 changed files with 14271 additions and 166 deletions

11
.github/dependabot.yml vendored Normal file
View File

@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
version: 2
updates:
- package-ecosystem: "npm" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"

View File

@ -1,12 +1,15 @@
name: publish npm
name: Publish Astro-GhostCMS
on:
release:
types: [created]
types: [published]
jobs:
publishnpm:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/astro-ghostcms
steps:
- name: checkout
uses: actions/checkout@v3
@ -29,6 +32,9 @@ jobs:
contents: read
packages: write
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/astro-ghostcms
steps:
- name: checkout
uses: actions/checkout@v3

24
.github/workflows/lighthouse.yml vendored Normal file
View File

@ -0,0 +1,24 @@
name: Unlighthouse - Demo Site
on:
workflow_call:
jobs:
Unlighthouse-demo:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install Dependencies
run: npm install -g @unlighthouse/cli puppeteer netlify-cli
- name: Unlighthouse assertions and client
run: unlighthouse-ci --site demo.astro-ghostcms.xyz --budget 75 --build-static
- name: Deploy
run: netlify deploy --dir=.unlighthouse --prod --message="New Release Deploy from GitHub Actions"
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

25
.gitignore vendored
View File

@ -1,24 +1 @@
# 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
node_modules

3
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,3 @@
{
"editor.defaultFormatter": "biomejs.biome"
}

18
biome.json Normal file
View File

@ -0,0 +1,18 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.2/schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"suspicious": {
"noExplicitAny": "warn"
}
}
},
"files": {
"ignore": ["dist", ".astro"]
}
}

2
demo/.env.demo Normal file
View File

@ -0,0 +1,2 @@
CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48
CONTENT_API_URL=https://ghostdemo.matthiesen.xyz

4
demo/.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

11
demo/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

21
demo/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Matthiesen XYZ
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

12
demo/README.md Normal file
View File

@ -0,0 +1,12 @@
# Astro-GhostCMS Demo Template
![Vercel](https://vercelbadge.vercel.app/api/matthiesenxyz/astro-ghostcms-demo)
This Repo is a Demo Website for the [@matthiesenxyz/astro-ghostcms](https://github.com/MatthiesenXYZ/astro-ghostcms) integraion.
- For a live preview goto [Demo.Astro-GhostCMS.xyz](https://demo.astro-ghostcms.xyz)
- To see the Current Lighthouse test that is ran every deployment goto [Test.Demo.Astro-GhostCMS.xyz](https://test.demo.astro-ghostcms.xyz)
### For more information Check our website
[Astro-GhostCMS.xyz](https://astro-ghostcms.xyz)

8
demo/astro.config.mjs Normal file
View File

@ -0,0 +1,8 @@
import { defineConfig } from 'astro/config';
import GhostCMS from "@matthiesenxyz/astro-ghostcms";
// https://astro.build/config
export default defineConfig({
site: "https://demo.astro-ghostcms.xyz/",
integrations: [GhostCMS()]
});

20
demo/package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "demo",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.4.1",
"@matthiesenxyz/astro-ghostcms": "^2.1.8",
"astro": "^4.2.0",
"astro-robots-txt": "^1.0.0",
"typescript": "^5.3.3",
"zod-validation-error": "^3.0.0"
}
}

9
demo/public/favicon.svg Normal file
View File

@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 128 128">
<path d="M50.4 78.5a75.1 75.1 0 0 0-28.5 6.9l24.2-65.7c.7-2 1.9-3.2 3.4-3.2h29c1.5 0 2.7 1.2 3.4 3.2l24.2 65.7s-11.6-7-28.5-7L67 45.5c-.4-1.7-1.6-2.8-2.9-2.8-1.3 0-2.5 1.1-2.9 2.7L50.4 78.5Zm-1.1 28.2Zm-4.2-20.2c-2 6.6-.6 15.8 4.2 20.2a17.5 17.5 0 0 1 .2-.7 5.5 5.5 0 0 1 5.7-4.5c2.8.1 4.3 1.5 4.7 4.7.2 1.1.2 2.3.2 3.5v.4c0 2.7.7 5.2 2.2 7.4a13 13 0 0 0 5.7 4.9v-.3l-.2-.3c-1.8-5.6-.5-9.5 4.4-12.8l1.5-1a73 73 0 0 0 3.2-2.2 16 16 0 0 0 6.8-11.4c.3-2 .1-4-.6-6l-.8.6-1.6 1a37 37 0 0 1-22.4 2.7c-5-.7-9.7-2-13.2-6.2Z" />
<style>
path { fill: #000; }
@media (prefers-color-scheme: dark) {
path { fill: #FFF; }
}
</style>
</svg>

After

Width:  |  Height:  |  Size: 749 B

52
demo/public/rss.xsl Normal file

File diff suppressed because one or more lines are too long

9
demo/src/env.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
/// <reference types="astro/client" />
interface ImportMetaEnv {
readonly CONTENT_API_KEY: string
readonly CONTENT_API_URL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

3
demo/tsconfig.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "astro/tsconfigs/strict"
}

View File

@ -1,79 +1,19 @@
{
"name": "@matthiesenxyz/astro-ghostcms",
"description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content",
"version": "2.1.8",
"author": "MatthiesenXYZ (https://matthiesen.xyz)",
"type": "module",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/MatthiesenXYZ/astro-ghostcms.git"
"name": "root",
"private": true,
"packageManager": "pnpm@8.14.1",
"engines": {
"node": ">=18.19.0"
},
"bugs": {
"url": "https://github.com/MatthiesenXYZ/astro-ghostcms/issues",
"email": "issues@astro-ghostcms.xyz"
},
"homepage": "https://astro-ghostcms.xyz/",
"exports": {
".": "./index.ts",
"./api": "./src/api/index.ts",
"./index.astro": "./src/theme/routes/index.astro",
"./404.astro": "./src/theme/routes/404.astro",
"./[slug].astro": "./src/theme/routes/[slug].astro",
"./tags.astro": "./src/theme/routes/tags.astro",
"./authors.astro": "./src/theme/routes/authors.astro",
"./tag/[slug].astro": "./src/theme/routes/tag/[slug].astro",
"./author/[slug].astro": "./src/theme/routes/author/[slug].astro",
"./archives/[...page].astro": "./src/theme/routes/archives/[...page].astro",
"./rss.xml.js": "./src/theme/routes/rss.xml.js"
},
"main": "index.ts",
"types": "src/api/tryghost-content-api.d.ts",
"files": [
"src",
"index.ts"
],
"keywords": [
"astro-component",
"astro-integration",
"withastro",
"astro",
"blog",
"content",
"integration",
"ghost",
"ghostcms",
"ghostcms-theme",
"ghost-theme",
"astro-theme"
],
"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 ."
"playground:dev": "pnpm --filter playground dev",
"www:dev": "pnpm --filter www dev",
"demo:dev": "pnpm --filter demo dev",
"lint": "biome check .",
"lint:fix": "biome check --apply ."
},
"dependencies": {
"@astrojs/check": "^0.3.4",
"@astrojs/rss": "^4.0.2",
"@astrojs/sitemap": "^3.0.5",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"astro": "^4.2.1",
"astro-font": "^0.0.72",
"astro-robots-txt": "^1.0.0",
"axios": "^1.6.5",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-astro": "^0.29.1",
"prettier": "^3.2.4",
"prettier-plugin-astro": "^0.12.3",
"sass": "^1.70.0",
"tiny-invariant": "^1.3.1",
"typescript": "^5.3.3",
"vite": "^4.5.2",
"zod-validation-error": "^3.0.0"
"devDependencies": {
"@biomejs/biome": "1.5.2",
"@changesets/cli": "^2.27.1"
}
}

View File

@ -0,0 +1,2 @@
CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48
CONTENT_API_URL=https://ghostdemo.matthiesen.xyz

View File

@ -0,0 +1,113 @@
<img src="https://ghostdemo.matthiesen.xyz/content/images/size/w50/2024/01/logo-1.png" width="64px" />
# Welcome to Astro-GhostCMS
*Ghost is a trademark of [The Ghost Foundation](https://ghost.org/trademark/). This project is not directly related to or provided by The Ghost Foundation and is intended to help create a easier method to utilize their provided JavaScript tools to link a Headless GhostCMS install in to your Astro project.*
- [Live Demo](https://demo.astro-ghostcms.xyz/) of the Astro-GhostCMS integration in action!
- [Live Demo - Unlighthouse Test](https://test.demo.astro-ghostcms.xyz) for a Automatically updated Lighthouse test from every deploy!
- [Live Demo's Repo](https://github.com/MatthiesenXYZ/astro-ghostcms-demo) for an example of how the setup looks.
- [Ghost.org](https://ghost.org) Get your own Ghost[^1] Install
*Need help but don't have Github? Email us at [issues@astro-ghostcms.xyz](mailto:issues@astroghostcms.xyz) to create an issue here on github!*
Astro minimum Version: **Astro v4.0**
This Integration is 2 parts. Firstly, there is the API portion that uses the `@tryghost/content-api`[^1] 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[^1] iteself instead of storing any data locally outside of Build.
- *This package contains a independent copy of the tryghost content-api.js[^1] that is used to establish the connection so this package dose not depend on `@tryghost/content-api` package.[^1]*
- 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.
## Astro Integration Mode
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
```sh
# 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
```
#### 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=a33da3965a3a9fb2c6b3f63b48
CONTENT_API_URL=https://ghostdemo.matthiesen.xyz
```
## Manual Installation
```
npm i @matthiesenxyz/astro-ghostcms
```
Then set your astro.config.ts to look like this:
```ts
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: [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=a33da3965a3a9fb2c6b3f63b48
CONTENT_API_URL=https://ghostdemo.matthiesen.xyz
```
**When you deploy your install dont forget to set the above ENVIRONMENT VARIABLES!**
#### Created Routes
The routes are the same as a standard Ghost Blog so you can migrate to Astro easily.
| Route | Content |
| --------------------- | ----------------------------------------- |
| `/` | Homepage with recents/features Blog Posts |
| `/404` | 404 Page |
| `/[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 |
| `/rss.xml` | All the posts, in a FEED |
## 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!**
For more information and to see the docs please check our website: [Astro-GhostCMS.xyz](https://astro-ghostcms.xyz)
# Foot Notes & Credits
[^1]: Ghost.org, Ghost.io, Ghost are all trademarks of [The Ghost Foundation](https://ghost.org/). This project is Open Source and not directly related to or provided by The Ghost Foundation and is intended to help create a easier method to utilize their provided JavaScript tools to link a Headless GhostCMS install in to your Astro project.

View File

@ -1,10 +1,10 @@
import type { AstroIntegration } from "astro";
import type { SafeParseError, SafeParseSuccess } from "astro/zod";
import { UserConfigSchema, type UserConfig } from "./src/utils/UserConfigSchema";
import { UserConfigSchema, type UserConfig } from "./src/schemas";
import { ghostSitemap, ghostRobots } from "./src/integrations";
import { loadEnv } from 'vite';
import { fromZodError } from "zod-validation-error";
import { viteGhostCMS } from "./src/utils/virtual-imports";
import { viteGhostCMS } from "./src/virtual";
/** INTERNAL CONSTANTS */
const IC = {
@ -17,9 +17,9 @@ const IC = {
/** SET ENV GRABBER PREFIXES */
PREFIXES: 'CONTENT_API',
/** INTERNAL STRING */
KEY_MISSING:"CONTENT_API_KEY Missing from .env",
KEY_MISSING:"CONTENT_API_KEY Missing from .env/environment variables",
/** INTERNAL STRING */
URL_MISSING:"CONTENT_API_URL Missing from .env",
URL_MISSING:"CONTENT_API_URL Missing from .env/environment variables",
/** INTERNAL STRING */
IT:"Injecting Theme: ",
/** INTERNAL STRING */
@ -104,7 +104,7 @@ export default function GhostCMS(options: UserConfig): AstroIntegration {
injectRoute({
pattern: '/404',
entrypoint: `${entry}/404.astro`
entrypoint: `${IC.PKG}/404.astro`
});
injectRoute({

View File

@ -0,0 +1,90 @@
{
"name": "@matthiesenxyz/astro-ghostcms",
"description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content",
"version": "2.1.8",
"homepage": "https://astro-ghostcms.xyz/",
"type": "module",
"license": "MIT",
"publishConfig": {
"access": "public"
},
"sideEffects": false,
"author": {
"email": "adam@matthiesen.xyz",
"name": "Adam Matthiesen - MatthiesenXYZ",
"url": "https://matthiesen.xyz"
},
"keywords": [
"astro-component",
"astro-integration",
"withastro",
"astro",
"blog",
"content",
"integration",
"ghost",
"ghostcms",
"ghostcms-theme",
"ghost-theme",
"astro-theme"
],
"repository": {
"type": "git",
"url": "git+https://github.com/MatthiesenXYZ/astro-ghostcms.git"
},
"bugs": {
"url": "https://github.com/MatthiesenXYZ/astro-ghostcms/issues",
"email": "issues@astro-ghostcms.xyz"
},
"main": "index.ts",
"types": "src/api/tryghost-content-api.d.ts",
"files": [
"src",
"index.ts"
],
"exports": {
".": "./index.ts",
"./api": "./src/api/index.ts",
"./404.astro": "./src/default-routes/404/404.astro",
"./rss.xml.js": "./src/default-routes/rss.xml.js",
"./index.astro": "./src/theme/routes/index.astro",
"./[slug].astro": "./src/theme/routes/[slug].astro",
"./tags.astro": "./src/theme/routes/tags.astro",
"./authors.astro": "./src/theme/routes/authors.astro",
"./tag/[slug].astro": "./src/theme/routes/tag/[slug].astro",
"./author/[slug].astro": "./src/theme/routes/author/[slug].astro",
"./archives/[...page].astro": "./src/theme/routes/archives/[...page].astro"
},
"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 ."
},
"peerDependencies": {
"astro": "^4.2.1"
},
"dependencies": {
"@astrojs/check": "^0.3.4",
"@astrojs/rss": "^4.0.2",
"@astrojs/sitemap": "^3.0.5",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"@types/node": "^20.11.5",
"astro-font": "^0.0.72",
"astro-robots-txt": "^1.0.0",
"axios": "^1.6.5",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-astro": "^0.29.1",
"prettier": "^3.2.4",
"prettier-plugin-astro": "^0.12.3",
"sass": "^1.70.0",
"tiny-invariant": "^1.3.1",
"typescript": "^5.3.3",
"vite": "^4.5.2",
"zod-validation-error": "^3.0.0"
}
}

View File

@ -1,5 +1,5 @@
---
import '../styles/404.css'
import './404.css';
---
<html lang="en">

View File

@ -58,7 +58,6 @@
font-size: 15px;
text-align: center;
margin: 0 auto;
vertical-align: middle;
display: block;
margin-bottom: 40px;
margin-top: 25px;

View File

@ -1,5 +1,5 @@
import rss from "@astrojs/rss";
import { getGhostPosts, getGhostSettings } from '../../api';
import { getGhostPosts, getGhostSettings } from '../api';
import invariant from "tiny-invariant";
export async function GET(context) {

View File

@ -1,5 +1,5 @@
import robotsTxt, { type RobotsTxtOptions } from "astro-robots-txt";
import { UserConfig } from "../utils/UserConfigSchema";
import type { UserConfig } from "../schemas";
export function getRobotsTxtConfig(opts: UserConfig): RobotsTxtOptions {
const { robotstxt } = opts;

View File

@ -1,5 +1,5 @@
import sitemap, { type SitemapOptions } from '@astrojs/sitemap';
import { UserConfig } from '../utils/UserConfigSchema';
import type { UserConfig } from '../schemas';
export function getSitemapConfig(opts: UserConfig): SitemapOptions {
const { sitemap } = opts

View File

@ -1,5 +1,6 @@
import { z } from 'astro/zod';
import * as S from './schemas';
import { SitemapSchema } from './sitemap';
import { RobotsTxtSchema } from './robots';
export const UserConfigSchema = z.object({
/** OPTIONAL - Disable Route Injector
@ -15,13 +16,13 @@ export const UserConfigSchema = z.object({
* Options shown are the availble options
* REFERENCE https://docs.astro.build/en/guides/integrations-guide/sitemap
*/
sitemap: S.SitemapSchema.optional(),
sitemap: SitemapSchema.optional(),
/** OPTIONAL - astro-robots-txt
* This option allows the user to configure the included integration
* Options shown are the availble options
* REFERENCE https://www.npmjs.com/package/astro-robots-txt#configuration
*/
robotstxt: S.RobotsTxtSchema.optional(),
robotstxt: RobotsTxtSchema.optional(),
});
/** USER CONFIGURATION SCHEMA */

View File

@ -0,0 +1,37 @@
import { z } from "astro/zod";
const RobotsPolicySchema = z.object({
/** You must provide a name of the automatic client (search engine crawler).
* Wildcards are allowed.
*/
userAgent: z.string(),
/** Allowed paths for crawling */
allow: z.string().optional(),
/** Disallowed paths for crawling */
disallow: z.string().optional(),
/** Indicates that the page's URL contains parameters that should be ignored during crawling.
* Maximum string length is limited to 500.
*/
cleanParam: z.string().optional(),
/** Minimum interval (in secs) for the crawler to wait after loading one page, before starting other */
crawlDelay: z.number().optional()
})
export const RobotsTxtSchema = z.object({
/** EXAMPLE1 host: true - automatically resolve using the site option from Astro config
* EXAMPLE2 host: 'example.com'
*/
host: z.string().optional(),
/** EXAMPLE1 sitemap: "https://example.com/sitemap-0.xml"
* EXAMPLE2 sitemap: ['https://example.com/sitemap-0.xml','https://example.com/sitemap-1.xml']
* EXAMPLE3 sitemap: false - If you want to get the robots.txt file without the Sitemap: ... entry, set the sitemap parameter to false.
*/
sitemap: z.string().optional(),
/** astrojs/sitemap and astro-sitemap integrations have the sitemap-index.xml as their primary output. That is why the default value of sitemapBaseFileName is set to sitemap-index.
* EXAMPLE sitemapBaseFileName: 'custom-sitemap'
*/
sitemapBaseFileName: z.string().optional(),
/** SET POLICY RULES */
policy: RobotsPolicySchema.array().optional(),
})

View File

@ -0,0 +1,12 @@
import { z } from "astro/zod";
export const SitemapSchema = z.object({
/** EXAMPLE: ['https://example-1.com', 'https://example-2.com]
* REFERENCE https://docs.astro.build/en/guides/integrations-guide/sitemap/#custompages
*/
customPages: z.string().array().optional(),
/** EXAMPLE: 10000
* REFERENCE https://docs.astro.build/en/guides/integrations-guide/sitemap/#entrylimit
*/
entryLimit: z.number().optional()
})

View File

@ -1,8 +1,8 @@
---
import type { Settings } from "../../api";
import { AstroFont } from "astro-font";
import ViewTransitions from "astro/components/ViewTransitions.astro";
import MainLayout from "../components/MainLayout.astro";
import { ViewTransitions } from "astro:transitions";
export type Props = {
content?: {
title: string|undefined;

View File

@ -1,8 +1,7 @@
import type { AstroConfig, ViteUserConfig } from 'astro'
import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { UserConfig } from './UserConfigSchema'
import type { UserConfig } from '../schemas';
function resolveVirtualModuleId<T extends string>(id: T): `\0${T}` {
return `\0${id}`

View File

@ -0,0 +1,6 @@
{
"extends": "astro/tsconfigs/strict",
"compilerOptions": {
"jsx": "preserve"
}
}

21
playground/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# build output
dist/
# generated types
.astro/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store

4
playground/.vscode/extensions.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"recommendations": ["astro-build.astro-vscode"],
"unwantedRecommendations": []
}

11
playground/.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "./node_modules/.bin/astro dev",
"name": "Development server",
"request": "launch",
"type": "node-terminal"
}
]
}

21
playground/LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2024 Matthiesen XYZ
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

7
playground/README.md Normal file
View File

@ -0,0 +1,7 @@
# Astro-GhostCMS playground
This is the Dev Environment for this package
### For more information Check our website
[Astro-GhostCMS.xyz](https://astro-ghostcms.xyz)

View File

@ -0,0 +1,8 @@
import { defineConfig } from "astro/config";
import ghostcms from "@matthiesenxyz/astro-ghostcms";
// https://astro.build/config
export default defineConfig({
site: "https://demo.astro-ghostcms.xyz/",
integrations: [ghostcms()],
});

21
playground/package.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "playground",
"type": "module",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"astro": "^4.2.1",
"@matthiesenxyz/astro-ghostcms": "workspace:*"
},
"devDependencies": {
"@astrojs/check": "^0.4.1",
"typescript": "^5.3.3"
}
}

View File

@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 128 128">
<path d="M50.4 78.5a75.1 75.1 0 0 0-28.5 6.9l24.2-65.7c.7-2 1.9-3.2 3.4-3.2h29c1.5 0 2.7 1.2 3.4 3.2l24.2 65.7s-11.6-7-28.5-7L67 45.5c-.4-1.7-1.6-2.8-2.9-2.8-1.3 0-2.5 1.1-2.9 2.7L50.4 78.5Zm-1.1 28.2Zm-4.2-20.2c-2 6.6-.6 15.8 4.2 20.2a17.5 17.5 0 0 1 .2-.7 5.5 5.5 0 0 1 5.7-4.5c2.8.1 4.3 1.5 4.7 4.7.2 1.1.2 2.3.2 3.5v.4c0 2.7.7 5.2 2.2 7.4a13 13 0 0 0 5.7 4.9v-.3l-.2-.3c-1.8-5.6-.5-9.5 4.4-12.8l1.5-1a73 73 0 0 0 3.2-2.2 16 16 0 0 0 6.8-11.4c.3-2 .1-4-.6-6l-.8.6-1.6 1a37 37 0 0 1-22.4 2.7c-5-.7-9.7-2-13.2-6.2Z" />
<style>
path { fill: #000; }
@media (prefers-color-scheme: dark) {
path { fill: #FFF; }
}
</style>
</svg>

After

Width:  |  Height:  |  Size: 749 B

9
playground/src/env.d.ts vendored Normal file
View File

@ -0,0 +1,9 @@
/// <reference types="astro/client" />
interface ImportMetaEnv {
readonly CONTENT_API_KEY: string
readonly CONTENT_API_URL: string
}
interface ImportMeta {
readonly env: ImportMetaEnv;
}

4
playground/tsconfig.json Normal file
View File

@ -0,0 +1,4 @@
{
"extends": "astro/tsconfigs/strict",
"exclude": ["dist"]
}

7095
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

6
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,6 @@
packages:
- package
- "packages/*"
- "playground"
- "www"
- "demo"

View File

@ -1,47 +0,0 @@
import { z } from 'astro/zod';
export const SitemapSchema = z.object({
/** EXAMPLE: ['https://example-1.com', 'https://example-2.com]
* REFERENCE https://docs.astro.build/en/guides/integrations-guide/sitemap/#custompages
*/
customPages: z.string().array().optional(),
/** EXAMPLE: 10000
* REFERENCE https://docs.astro.build/en/guides/integrations-guide/sitemap/#entrylimit
*/
entryLimit: z.number().optional()
})
const RobotsPolicySchema = z.object({
/** You must provide a name of the automatic client (search engine crawler).
* Wildcards are allowed.
*/
userAgent: z.string(),
/** Allowed paths for crawling */
allow: z.string().optional(),
/** Disallowed paths for crawling */
disallow: z.string().optional(),
/** Indicates that the page's URL contains parameters that should be ignored during crawling.
* Maximum string length is limited to 500.
*/
cleanParam: z.string().optional(),
/** Minimum interval (in secs) for the crawler to wait after loading one page, before starting other */
crawlDelay: z.number().optional()
})
export const RobotsTxtSchema = z.object({
/** EXAMPLE1 host: true - automatically resolve using the site option from Astro config
* EXAMPLE2 host: 'example.com'
*/
host: z.string().optional(),
/** EXAMPLE1 sitemap: "https://example.com/sitemap-0.xml"
* EXAMPLE2 sitemap: ['https://example.com/sitemap-0.xml','https://example.com/sitemap-1.xml']
* EXAMPLE3 sitemap: false - If you want to get the robots.txt file without the Sitemap: ... entry, set the sitemap parameter to false.
*/
sitemap: z.string().optional(),
/** astrojs/sitemap and astro-sitemap integrations have the sitemap-index.xml as their primary output. That is why the default value of sitemapBaseFileName is set to sitemap-index.
* EXAMPLE sitemapBaseFileName: 'custom-sitemap'
*/
sitemapBaseFileName: z.string().optional(),
/** SET POLICY RULES */
policy: RobotsPolicySchema.array().optional(),
})

21
www/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
# build output
dist/
# generated types
.astro/
# dependencies
node_modules/
# logs
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# environment variables
.env
.env.production
# macOS-specific files
.DS_Store

1
www/README.md Normal file
View File

@ -0,0 +1 @@
Repo for Astro-ghostcms.xyz website

44
www/astro.config.mjs Normal file
View File

@ -0,0 +1,44 @@
import { defineConfig } from 'astro/config';
import fs from 'node:fs';
import { ExpressiveCodeTheme } from '@astrojs/starlight/expressive-code';
import starlight from "@astrojs/starlight";
const houstonFile = `./houston-vscode.jsonc`;
const houston = fs.readFileSync(
new URL(houstonFile, import.meta.url),'utf-8');
const houstonTheme = ExpressiveCodeTheme.fromJSONString(houston);
// https://astro.build/config
export default defineConfig({
site: 'https://astro-ghostcms.xyz',
integrations: [
starlight({
title: 'Astro-GhostCMS',
logo: {
src: './src/assets/favicon.svg'
},
favicon: 'favicon.svg',
customCss: [ './src/styles/starlight.css' ],
expressiveCode: { themes: [ houstonTheme ] },
social: {
github: 'https://github.com/MatthiesenXYZ/astro-ghostcms',
},
sidebar: [
{ label: 'Docs Home', link: '/docs/' },
{ label: 'Introduction', items: [
{ label: 'Getting Started', link: '/docs/introduction/getting-started' },
{ label: 'Integration Mode', items: [
{ label: 'Quick Install', link: '/docs/introduction/integration/quick' },
{ label: 'Manual Install', link: '/docs/introduction/integration/manual' },
{ label: 'Configuration Options', link: '/docs/introduction/integration/config',
badge: { text: 'BETA', variant: 'caution' }, }, ], },
{ label: 'API ( DIY ) Mode', items: [
{ label: 'Install', link: '/docs/introduction/api/install' },
{ label: 'Basic API Usage', link: '/docs/introduction/api/usage' }, ], }, ], },
//{ label: 'Advanced Usage', link: '/docs/#' },
{ label: 'Tutorials', autogenerate: { directory: 'docs/tutorials' }, },
{ label: 'Reference', autogenerate: { directory: 'docs/reference' }, },
],
}),
],
});

2369
www/houston-vscode.jsonc Normal file

File diff suppressed because it is too large Load Diff

20
www/package.json Normal file
View File

@ -0,0 +1,20 @@
{
"name": "www",
"type": "module",
"version": "0.0.1",
"scripts": {
"dev": "astro dev",
"start": "astro dev",
"build": "astro check && astro build",
"preview": "astro preview",
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.4.1",
"@astrojs/starlight": "^0.15.4",
"astro": "^4.2.0",
"sass": "^1.69.5",
"sharp": "^0.32.6",
"typescript": "^5.3.3"
}
}

BIN
www/public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 KiB

1
www/public/favicon.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 1.3 MiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,5 @@
# First Create a fresh Astro Install
npm create astro@latest
# Create Empty Install with standard typescript
# Then Delete entire 'pages' folder under '/src/'
npx astro add @matthiesenxyz/astro-ghostcms

View File

@ -0,0 +1,21 @@
---
import { ViewTransitions } from 'astro:transitions';
import SEO, { type Props as SEOProps } from './SEO.astro';
import { SiteTitle, SiteDescription } from '../consts';
import favicon from '../assets/favicon.svg';
export type Props = Partial<SEOProps>;
const { title = SiteTitle, name = SiteTitle, description = SiteDescription, ...seo } = Astro.props;
---
<SEO {title} {description} {name} {...seo} />
<link rel="icon" type="image/svg" href={favicon.src} />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Lato:wght@400;700&family=Source+Code+Pro&display=swap"
rel="stylesheet"
/>
<ViewTransitions />

View File

@ -0,0 +1,12 @@
---
import '../styles/global.scss';
---
<footer>
<p>© MatthiesenXYZ 2024</p>
<div class="footer_links">
<a href="/archive">Previous Release Archives</a>
<a href="https://github.com/MatthiesenXYZ/astro-ghostcms">GitHub</a>
<a href="https://matthiesen.xyz">MatthiesenXYZ</a>
</div>
</footer>

View File

@ -0,0 +1,25 @@
---
import type { HTMLAttributes } from 'astro/types';
type Props = HTMLAttributes<'time'> & {
date: Date;
};
const { date, ...attrs } = Astro.props;
---
<time datetime={date.toISOString()} {...attrs}>
{
date.toLocaleDateString('en-us', {
year: 'numeric',
month: 'short',
day: 'numeric',
})
}
</time>
<style>
time {
display: block;
}
</style>

View File

@ -0,0 +1,4 @@
---
---
<div>Astro-GhostCMS is independently maintained and not provided by Ghost or <a href="https://astro.build">Astro</a>, Ghost is a trademark of <a href="https://ghost.org">The Ghost Foundation</a>.</div>

View File

@ -0,0 +1,30 @@
---
import '../styles/global.scss';
import { SiteTitle } from '../consts';
import favicon from '../assets/favicon.svg'
import { Image } from 'astro:assets';
---
<header>
<nav>
<h2 id="site_title">
<a href="/">
<Image src={favicon} alt="logo" width={64}/>
{SiteTitle}
</a>
</h2>
<div class="links">
<a href="https://demo.astro-ghostcms.xyz" target="_blank">Live Demo</a>
<a href="https://test.demo.astro-ghostcms.xyz" target="_blank">Lighthouse Report</a>
<a href="/docs" target="">Docs</a>
<a href="https://www.npmjs.com/package/@matthiesenxyz/astro-ghostcms" target="_blank">NPM</a>
<a href="https://github.com/matthiesenxyz/astro-ghostcms" target="_blank">GitHub</a>
</div>
</nav>
</header>
<style>
.links a {
text-decoration: none;
}
</style>

View File

@ -0,0 +1,14 @@
---
import { Code } from "astro:components"
import quickstart from "../assets/quickstart.sh?raw"
---
<div class="quickstart">
<center>
<div class="qstart"> /|\ Astro-GhostCMS Quickstart /|\ </div>
</center>
<Code lang={'sh'} code={quickstart}/>
</div>

View File

@ -0,0 +1,87 @@
---
import type { ImageMetadata } from 'astro';
type Image = {
src: string | ImageMetadata;
alt: string;
};
type SEOMetadata = {
name: string;
title: string;
description: string;
image?: Image | undefined;
canonicalURL?: URL | string | undefined;
locale?: string;
};
type OpenGraph = Partial<SEOMetadata> & {
type?: string;
};
type Twitter = Partial<SEOMetadata> & {
handle?: string;
card?: 'summary' | 'summary_large_image';
};
export type Props = SEOMetadata & {
og?: OpenGraph;
twitter?: Twitter;
};
const {
name,
title,
description,
image,
locale = 'en',
canonicalURL = new URL(Astro.url.pathname, Astro.site),
} = Astro.props;
const og = {
name,
title,
description,
canonicalURL,
image,
locale,
type: 'website',
...(Astro.props.og ?? {}),
} satisfies OpenGraph;
const twitter = {
name,
title,
description,
canonicalURL,
image,
locale,
card: 'summary_large_image',
...Astro.props.twitter,
};
function normalizeImageUrl(image: string | ImageMetadata) {
return typeof image === 'string' ? image : image.src;
}
---
<!-- Page Metadata -->
<link rel="canonical" href={canonicalURL} />
<meta name="description" content={description} />
<!-- OpenGraph Tags -->
<meta property="og:title" content={og.title} />
<meta property="og:type" content={og.type} />
<meta property="og:url" content={canonicalURL} />
<meta property="og:locale" content={og.locale} />
<meta property="og:description" content={og.description} />
<meta property="og:site_name" content={og.name} />
{og.image && <meta property="og:image" content={normalizeImageUrl(og.image.src)} />}
{og.image && <meta property="og:image:alt" content={og.image.alt} />}
<!-- Twitter Tags -->
<meta name="twitter:card" content={twitter.card} />
<meta name="twitter:site" content={twitter.handle} />
<meta name="twitter:title" content={twitter.title} />
<meta name="twitter:description" content={twitter.description} />
{twitter.image && <meta name="twitter:image" content={normalizeImageUrl(twitter.image.src)} />}
{twitter.image && <meta name="twitter:image:alt" content={twitter.image.alt} />}

5
www/src/consts.ts Normal file
View File

@ -0,0 +1,5 @@
// Place any global data in this file.
// You can import this data from anywhere in your site by using the `import` keyword.
export const SiteTitle = 'Astro-GhostCMS';
export const SiteDescription = 'Astro-GhostCMS Integration & API';

View File

@ -0,0 +1,48 @@
---
title: 'Introducing Astro-GhostCMS.xyz!'
date: '01-17-2024'
versionNumber: '2.0.5'
description: 'This is the First Release posted to our new website!'
#image:
# src: '../../assets/starlog-placeholder-2.jpg'
# alt: 'The full Astro logo.'
---
## Introducing Astro-GhostCMS.xyz!
Greetings, Astro-GhostCMS users! We're happy to announce the launch of our new website astro-ghostcms.xyz a central location to get all your relevent updates regarding our Astro-GhostCMS integration!
### Welcome to Astro-GhostCMS
- [Live Demo](https://demo.astro-ghostcms.xyz/) of the Astro-GhostCMS integration in action!
- [Live Demo's Repo](https://github.com/MatthiesenXYZ/astro-ghostcms-demo) for an example of how the setup looks.
Astro minimum Version: **Astro v4.0**
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.
- *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.
### Quick Start : Astro Integration Mode
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
```sh
# 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
```
#### Dont forget to set your environment Variables!
You must also create 2 environment variables in a `.env` file with the following(*Below info is for DEMO Purposes. Please generate your own API_KEY for your Ghost install.*):
```ansi frame="code" title=".env"
CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48
CONTENT_API_URL=https://ghostdemo.matthiesen.xyz
```

View File

@ -0,0 +1,13 @@
---
title: 'New Feature: Theming (BETA)'
date: '01-18-2024'
versionNumber: '2.0.8'
description: 'New Feature Alert! Theming!'
#image:
# src: '../../assets/starlog-placeholder-2.jpg'
# alt: 'The full Astro logo.'
---
## New Feature: Themes (BETA)!
As of posting this there is now a new undocumented feature. Themes! this feature will allow the end-user the option of changing how their website's astro-ghostcms install looks and functons! I will be building a Theme Skeleton and then documentation for this new feature. Stay tuned for more updates as this is a beta feature!

Some files were not shown because too many files have changed in this diff Show More