Compare commits

...

40 Commits

Author SHA1 Message Date
Adam Matthiesen ca3e595401
Update package.json 2024-03-19 05:22:27 -07:00
Adam Matthiesen fa276f9d64
Update changeset-main.yml 2024-03-19 05:20:16 -07:00
Adam Matthiesen 5166bdc11f
Update package.json 2024-03-19 05:18:51 -07:00
github-actions[bot] acf9a1def4
👷 [ci]: Ready for Release (#120)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-19 05:16:19 -07:00
dependabot[bot] f82035b813
Bump the prod-dependencies group with 9 updates (#119)
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-19 05:14:59 -07:00
dependabot[bot] a6b2b28843
Bump the dev-dependencies group with 6 updates (#118)
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-19 05:03:24 -07:00
Adam Matthiesen c3b8872706 Update package versions in pnpm-lock.yaml 2024-03-12 23:27:32 -07:00
github-actions[bot] 13d6b551b8
👷 [ci]: Ready for Release (#116)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-12 23:23:30 -07:00
create-issue-branch[bot] f097c6a18b
fix: 🐛 bug: ultrahtml does not handle all html strings. add switch to enable standard html fragment tag instead. (#115)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
2024-03-12 23:22:39 -07:00
github-actions[bot] ec50145786
👷 [ci]: Ready for Release (#113)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-12 17:09:02 -07:00
create-issue-branch[bot] b0218e182b
fix: 🐛 Custom Code Component Swap is causing issues. (#112)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
2024-03-12 17:06:50 -07:00
Adam Matthiesen 8074b66935
Update coauthor.yml 2024-03-12 15:16:10 -07:00
Adam Matthiesen c57ff7d370
Update README.md 2024-03-11 16:30:54 -07:00
Adam Matthiesen 2854ad8a33
Update gitlab-sync.yml 2024-03-11 15:17:08 -07:00
Adam Matthiesen cfc6c88a8f Update @matthiesenxyz/astro-ghostcms version specifier to ^3.3.3 2024-03-11 10:22:18 -07:00
github-actions[bot] e532e1471e
👷 [ci]: Ready for Release (#110)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-11 10:19:45 -07:00
create-issue-branch[bot] b685e6617d
chore: ♻️ Fix: Some Deps should be Peer not dev/main (#109)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
2024-03-11 10:18:12 -07:00
dependabot[bot] 62829e268a
Bump the dev-dependencies group with 2 updates (#105)
Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-03-11 08:44:46 -07:00
Adam Matthiesen 6f1139f038 update pnpm-lock 2024-03-09 21:05:19 -08:00
github-actions[bot] f1ee69c8b7
👷 [ci]: Ready for Release (#102)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-09 21:03:00 -08:00
create-issue-branch[bot] 4c1002a733
fix: 🐛 Tag slug page returns 404 in development environment (#101)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Jungley <yejing@live.cn>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
2024-03-09 21:02:03 -08:00
github-actions[bot] 10bcac444b
👷 [ci]: Ready for Release (#98)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-09 08:49:52 -08:00
create-issue-branch[bot] a02c78b323
feat: bump starlight-ghostcms (#97)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <30383579+Adammatthiesen@users.noreply.github.com>
2024-03-09 08:49:00 -08:00
github-actions[bot] 6fee8bab1d
👷 [ci]: Ready for Release (#95)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-09 08:44:55 -08:00
Adam Matthiesen 209e99b8c7
update deps (#94) 2024-03-09 08:43:42 -08:00
github-actions[bot] b0ebb96783
👷 [ci]: Ready for Release (#93)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-09 05:11:38 -08:00
create-issue-branch[bot] 746fcc5858
fix: 🐛 bug: `starlight-ghostcms` markup allowElements list breaks `astro-gists` (#92)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
2024-03-09 05:09:43 -08:00
github-actions[bot] 110c5a973a
👷 [ci]: Ready for Release (#90)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-09 04:12:50 -08:00
create-issue-branch[bot] 205738c288
fix: 🐛 Bug: `Starlight-GhostCMS` on line 113 of `ghostAPI.ts` (#89)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
2024-03-09 04:11:54 -08:00
Adam Matthiesen fa93f54b68
Update changeset-main.yml 2024-03-07 23:53:14 -08:00
github-actions[bot] 81095d78b5
Chore: Ready for Release (#87)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-03-07 23:31:10 -08:00
create-issue-branch[bot] 27241192af
feat: Chore: Migrate from Render content Util and `<Fragment set:html />` to `astro-remote` (#86)
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <30383579+Adammatthiesen@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
2024-03-07 23:29:02 -08:00
Adam Matthiesen b606fac02d
Update issue-branch.yml 2024-03-07 20:25:42 -08:00
Adam Matthiesen 827be67b2d
Update issue-branch.yml 2024-03-07 20:23:17 -08:00
Adam Matthiesen 5709e8706e
Create issue-branch.yml 2024-03-07 20:00:28 -08:00
Adam Matthiesen 18f99e9b58
Update new_chore.md 2024-03-07 16:24:01 -08:00
Adam Matthiesen f57800a911
Rename new_chore.yml to new_chore.md 2024-03-07 16:19:18 -08:00
Adam Matthiesen 08561b74ca
Update new_chore.yml 2024-03-07 16:17:29 -08:00
Adam Matthiesen 78c0a72040
Update new_chore.yml 2024-03-07 16:17:01 -08:00
Adam Matthiesen 487d6e49fd
Create new_chore.yml 2024-03-07 16:13:01 -08:00
74 changed files with 2481 additions and 1519 deletions

18
.github/ISSUE_TEMPLATE/new_chore.md vendored Normal file
View File

@ -0,0 +1,18 @@
---
name: New Chore
about: Used to create a new Chore for a needed task
title: "Chore: [NAME]"
labels: chore
---
**Is your chore related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

38
.github/issue-branch.yml vendored Normal file
View File

@ -0,0 +1,38 @@
branchName: 'issue-${issue.number}-${issue.title[0,32]}'
gitReplaceChars: '/<>'
autoLinkIssue: true
openDraftPR: true
prSkipCI: true
copyIssueDescriptionToPR: true
copyIssueLabelsToPR: true
copyIssueAssigneeToPR: true
copyIssueProjectsToPR: true
copyIssueMilestoneToPR: true
conventionalPrTitles: true
conventionalLabels:
fix:
bug: '🐛'
dependencies: '⬆️'
security: '🔒'
feat:
enhancement: '✨'
new-stuff: '🚀'
build:
build: '🔧'
chore:
chore: '♻️'
ci:
ci: '👷'
docs:
documentation: '📝'
style:
style: '💎'
refactor:
refactor: '♻️'
perf:
performance: '⚡️'
test:
test: '✅'
breaking:
breaking-change: '💥'
breaking change: '💥'

View File

@ -26,13 +26,13 @@ jobs:
- name: Setup npmrc - name: Setup npmrc
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
- name: install dependencies - name: install dependencies
run: pnpm install run: pnpm install --no-frozen-lockfile
- name: create and publish versions - name: create and publish versions
uses: matthiesenxyz/changeset@v1 uses: matthiesenxyz/changeset@v1
with: with:
version: pnpm ci:version version: pnpm ci:version
commit: "chore: update versions" commit: "chore: update versions"
title: "Chore: Ready for Release" title: "👷 [ci]: Ready for Release"
publish: pnpm ci:publish publish: pnpm ci:publish
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@ -14,4 +14,4 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: kevinzunigacuellar/coauthor-action@v0.1.1 - uses: kevinzunigacuellar/coauthor-action@v0.1.2

View File

@ -12,7 +12,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: jauderho/git-repo-sync@63782025e80e84c48b25a1ee6bb9a22a3bd570d3 - uses: MatthiesenXYZ/git-sync-action@v1.1
with: with:
# Such as https://github.com/wangchucheng/git-repo-sync.git # Such as https://github.com/wangchucheng/git-repo-sync.git
target-url: ${{ secrets.GITLAB_URL }} target-url: ${{ secrets.GITLAB_URL }}

View File

@ -36,7 +36,6 @@ In this Repo you will find the Following:
- `packages/`: - `packages/`:
- [`create-astro-ghostcms`](./packages/create-astro-ghostcms/): CLI Utility to quickly deploy new Astro-GhostCMS projects. - [`create-astro-ghostcms`](./packages/create-astro-ghostcms/): CLI Utility to quickly deploy new Astro-GhostCMS projects.
- [`astro-ghostcms`](./packages/astro-ghostcms/): The main Integration! - [`astro-ghostcms`](./packages/astro-ghostcms/): The main Integration!
- [`astro-ghostcms-rendercontent`](./packages/astro-ghostcms-rendercontent/): Allows rendering of remote GhostCMS HTML with Custom Astro Components
- [`astro-ghostcms-theme-default`](./packages/astro-ghostcms-theme-default/): The Default theme in integration mode. - [`astro-ghostcms-theme-default`](./packages/astro-ghostcms-theme-default/): The Default theme in integration mode.
- [`astro-ghostcms-catppuccin`](./packages/astro-ghostcms-catppuccin/): A dark theme made with Catppuccin and TailwindCSS for Astro-GhostCMS Integration Mode. - [`astro-ghostcms-catppuccin`](./packages/astro-ghostcms-catppuccin/): A dark theme made with Catppuccin and TailwindCSS for Astro-GhostCMS Integration Mode.
- [`astro-ghostcms-brutalbyelian`](./packages/astro-ghostcms-brutalbyelian/): [ElianCodes](https://www.elian.codes/) Brutal theme modified to work with Astro-GhostCMS - [`astro-ghostcms-brutalbyelian`](./packages/astro-ghostcms-brutalbyelian/): [ElianCodes](https://www.elian.codes/) Brutal theme modified to work with Astro-GhostCMS

View File

@ -22,10 +22,10 @@
"test:starlight:coverage": "pnpm --filter starlight-ghostcms test:coverage" "test:starlight:coverage": "pnpm --filter starlight-ghostcms test:coverage"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "1.5.3", "@biomejs/biome": "1.6.1",
"@changesets/cli": "^2.27.1", "@changesets/cli": "^2.27.1",
"@vitest/ui": "^1.3.1", "@vitest/ui": "^1.4.0",
"vitest": "^1.3.1", "vitest": "^1.4.0",
"vitest-fetch-mock": "^0.2.2" "vitest-fetch-mock": "^0.2.2"
} }
} }

View File

@ -1,5 +1,61 @@
# @matthiesenxyz/astro-ghostcms-brutalbyelian # @matthiesenxyz/astro-ghostcms-brutalbyelian
## 0.0.18
### Patch Changes
- f82035b: Bump dependencies:
- astro-integration-kit from to
- @unocss/astro from to
- @unocss/reset from to
- astro-font from to
- unocss from to
- sass from to
- @matthiesenxyz/astro-gists from to
- vite-tsconfig-paths from to
- astro from to
- Updated dependencies [f82035b]
- @matthiesenxyz/astro-ghostcms@3.3.5
## 0.0.17
### Patch Changes
- f097c6a: Adds a toggleswitch to allow users to disable astro-remote usage for rendering ghost-content
- Updated dependencies [f097c6a]
- @matthiesenxyz/astro-ghostcms@3.3.4
## 0.0.16
### Patch Changes
- b0218e1: fix:
- Removed CodeSlot Component that sometimes would break with some <pre> components
- Will be adding at a latter time a custom component to replace this, but at this time this is now fixed.
## 0.0.15
### Patch Changes
- 4c1002a: fix getAllTags bug for themes and bump other packages deps
- Updated dependencies [4c1002a]
- @matthiesenxyz/astro-ghostcms@3.3.2
## 0.0.14
### Patch Changes
- 746fcc5: Fix html rendering to allow custom components
## 0.0.13
### Patch Changes
- 2724119: Migrate from `astro-ghostcms-rendercontent` to `astro-remote` for internal processing of GhostCMS HTML. no user changes required.
## 0.0.12 ## 0.0.12
### Patch Changes ### Patch Changes

View File

@ -1,7 +1,7 @@
{ {
"name": "@matthiesenxyz/astro-ghostcms-brutalbyelian", "name": "@matthiesenxyz/astro-ghostcms-brutalbyelian",
"description": "ElianCodes Brutal theme modified to work with Astro-GhostCMS", "description": "ElianCodes Brutal theme modified to work with Astro-GhostCMS",
"version": "0.0.12", "version": "0.0.18",
"homepage": "https://astro-ghostcms.xyz/", "homepage": "https://astro-ghostcms.xyz/",
"type": "module", "type": "module",
"license": "MIT", "license": "MIT",
@ -42,29 +42,27 @@
}, },
"scripts": {}, "scripts": {},
"peerDependencies": { "peerDependencies": {
"astro": "^4.2.0" "@matthiesenxyz/astro-ghostcms": ">=3.3.5",
"astro": ">=4.4.1"
}, },
"devDependencies": { "devDependencies": {
"@typescript-eslint/parser": "^7.1.1", "@typescript-eslint/parser": "^7.2.0",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-plugin-astro": "^0.31.4", "eslint-plugin-astro": "^0.31.4",
"eslint-plugin-jsx-a11y": "^6.8.0", "eslint-plugin-jsx-a11y": "^6.8.0",
"prettier-plugin-astro": "^0.13.0", "prettier-plugin-astro": "^0.13.0",
"prettier": "^3.2.5", "prettier": "^3.2.5"
"@matthiesenxyz/astro-ghostcms": "workspace:*",
"@matthiesenxyz/astro-ghostcms-rendercontent": "workspace:*"
}, },
"dependencies": { "dependencies": {
"@eliancodes/brutal-ui": "^0.2.6",
"@iconify-json/logos": "^1.1.41", "@iconify-json/logos": "^1.1.41",
"@iconify-json/uil": "^1.1.8", "@iconify-json/uil": "^1.1.8",
"@matthiesenxyz/astro-ghostcms": "^3.3.1", "@unocss/astro": "^0.58.6",
"@matthiesenxyz/astro-ghostcms-rendercontent": "^0.0.8", "@unocss/reset": "^0.58.6",
"@unocss/astro": "^0.58.5", "astro-font": "^0.0.78",
"@unocss/reset": "^0.58.5", "astro-remote": "0.3.2",
"unocss": "^0.58.5",
"@eliancodes/brutal-ui": "^0.2.6",
"astro-font": "^0.0.77",
"typescript": "^5.4.2", "typescript": "^5.4.2",
"ultrahtml": "^1.5.3" "ultrahtml": "^1.5.3",
"unocss": "^0.58.6"
} }
} }

View File

@ -1,6 +1,11 @@
--- ---
import { getGhostImgPath } from "../../utils"; import { getGhostImgPath } from "../../utils";
import type { Settings } from "@matthiesenxyz/astro-ghostcms/api"; import type { Settings } from "@matthiesenxyz/astro-ghostcms/api";
import { Markup } from 'astro-remote';
import config from "virtual:@matthiesenxyz/astro-ghostcms/config";
const useRemote = config.ThemeProvider.astroRemote.enable;
export type Props = { export type Props = {
image: string; image: string;
alt?: string; alt?: string;
@ -22,5 +27,8 @@ const { image, alt, caption = "", settings, transitionName } = Astro.props as Pr
alt={alt} alt={alt}
transition:name={transitionName} transition:name={transitionName}
/> />
{caption && <figcaption class="text-ctp-overlay2"><Fragment set:html={caption}></figcaption>} {caption && (
<figcaption class="text-ctp-overlay2">
{useRemote ? <Markup content={caption} /> : <Fragment set:html={caption} />}
</figcaption>)}
</figure> </figure>

View File

@ -1,12 +0,0 @@
---
import { Code } from "astro/components"
import { parse } from "ultrahtml"
import { querySelector } from "ultrahtml/selector"
const html = await Astro.slots.render("default")
const ast = await parse(html)
const codetag = querySelector(ast,'code')
const { children } = codetag
const code = children[0].value
---
<Code code={code} lang={"sh"} theme={"monokai"}/>

View File

@ -4,6 +4,5 @@ export { default as H3 } from "./H3.astro";
export { default as H4 } from "./H4.astro"; export { default as H4 } from "./H4.astro";
export { default as H5 } from "./H5.astro"; export { default as H5 } from "./H5.astro";
export { default as H6 } from "./H6.astro"; export { default as H6 } from "./H6.astro";
export { default as CodeSlot } from "./CodeSlot.astro";
export { default as Paragraph } from "./Paragraph.astro"; export { default as Paragraph } from "./Paragraph.astro";
export { default as astrocard } from "./astrocard.astro"; export { default as astrocard } from "./astrocard.astro";

View File

@ -4,9 +4,12 @@ import { getAllPosts, getAllPages, getSettings, invariant } from "@matthiesenxyz
import type { InferGetStaticPropsType } from "astro"; import type { InferGetStaticPropsType } from "astro";
import RecentBlogPosts from "../components/generic/RecentBlogPosts.astro"; import RecentBlogPosts from "../components/generic/RecentBlogPosts.astro";
import BlogPostHeader from "../components/blog/BlogPostHeader.astro"; import BlogPostHeader from "../components/blog/BlogPostHeader.astro";
import { GhostRender } from "@matthiesenxyz/astro-ghostcms-rendercontent"; import { Markup } from 'astro-remote';
import * as C from "../components/ghostrender"; import * as C from "../components/ghostrender";
import { Card } from "@eliancodes/brutal-ui"; import { Card } from "@eliancodes/brutal-ui";
import config from "virtual:@matthiesenxyz/astro-ghostcms/config";
const useRemote = config.ThemeProvider.astroRemote.enable;
export async function getStaticPaths() { export async function getStaticPaths() {
const [posts, pages, settings] = await Promise.all([getAllPosts(), await getAllPages(), await getSettings()]); const [posts, pages, settings] = await Promise.all([getAllPosts(), await getAllPages(), await getSettings()]);
@ -30,8 +33,12 @@ invariant(settings, "Settings are required");
<div class="my-5"/> <div class="my-5"/>
<div id="ghost"> <div id="ghost">
<GhostRender {useRemote ? <Markup
content={post.html} content={post.html}
sanitize={{
allowComponents: true,
allowElements: ['a', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img', 'figure', 'figcaption', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'em', 'strong', 'del', 'hr', 'br', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'caption', 'div', 'span', 'script', 'astrocard'],
}}
components={{ components={{
h1: C.H1, h1: C.H1,
h2: C.H2, h2: C.H2,
@ -39,11 +46,10 @@ invariant(settings, "Settings are required");
h4: C.H4, h4: C.H4,
h5: C.H5, h5: C.H5,
h6: C.H6, h6: C.H6,
pre: C.CodeSlot,
p: C.Paragraph, p: C.Paragraph,
astrocard: C.astrocard, astrocard: C.astrocard,
}} }}
/> /> : <Fragment set:html={post.html} />}
</div> </div>
</article> </article>

View File

@ -8,7 +8,7 @@ import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {

View File

@ -2,7 +2,7 @@
import Layout from '../layouts/Default.astro'; import Layout from '../layouts/Default.astro';
import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
import TagSummaryCard from '../components/generic/TagSummaryCard.astro'; import TagSummaryCard from '../components/generic/TagSummaryCard.astro';
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, 'Settings not found'); invariant(settings, 'Settings not found');
const title = settings.title; const title = settings.title;
@ -16,7 +16,7 @@ const description = settings.description;
description={description} description={description}
> >
<main class='bg-pink p-6'> <main class='bg-pink p-6'>
{ {
tags tags
.filter((tag) => tag.slug && !tag.slug.startsWith("hash-")) .filter((tag) => tag.slug && !tag.slug.startsWith("hash-"))
.map((tag) => ( .map((tag) => (

View File

@ -1,5 +1,42 @@
# @matthiesenxyz/astro-ghostcms-catppuccin # @matthiesenxyz/astro-ghostcms-catppuccin
## 0.0.14
### Patch Changes
- f097c6a: Adds a toggleswitch to allow users to disable astro-remote usage for rendering ghost-content
- Updated dependencies [f097c6a]
- @matthiesenxyz/astro-ghostcms@3.3.4
## 0.0.13
### Patch Changes
- b0218e1: fix:
- Removed CodeSlot Component that sometimes would break with some <pre> components
- Will be adding at a latter time a custom component to replace this, but at this time this is now fixed.
## 0.0.12
### Patch Changes
- 4c1002a: fix getAllTags bug for themes and bump other packages deps
- Updated dependencies [4c1002a]
- @matthiesenxyz/astro-ghostcms@3.3.2
## 0.0.11
### Patch Changes
- 746fcc5: Fix html rendering to allow custom components
## 0.0.10
### Patch Changes
- 2724119: Migrate to `astro-remote` for internal processing of GhostCMS HTML. No user changes required.
## 0.0.9 ## 0.0.9
### Patch Changes ### Patch Changes

View File

@ -1,7 +1,7 @@
{ {
"name": "@matthiesenxyz/astro-ghostcms-catppuccin", "name": "@matthiesenxyz/astro-ghostcms-catppuccin",
"description": "A dark theme made with Catppuccin and TailwindCSS for Astro-GhostCMS", "description": "A dark theme made with Catppuccin and TailwindCSS for Astro-GhostCMS",
"version": "0.0.9", "version": "0.0.14",
"homepage": "https://astro-ghostcms.xyz/", "homepage": "https://astro-ghostcms.xyz/",
"type": "module", "type": "module",
"license": "MIT", "license": "MIT",
@ -50,7 +50,8 @@
}, },
"scripts": {}, "scripts": {},
"peerDependencies": { "peerDependencies": {
"astro": "^4.2.1" "@matthiesenxyz/astro-ghostcms": ">=3.3.5",
"astro": ">=4.4.0"
}, },
"devDependencies": { "devDependencies": {
"@matthiesenxyz/astro-ghostcms": "workspace:*" "@matthiesenxyz/astro-ghostcms": "workspace:*"
@ -59,10 +60,12 @@
"@astrojs/tailwind": "^5.1.0", "@astrojs/tailwind": "^5.1.0",
"@catppuccin/tailwindcss": "0.1.6", "@catppuccin/tailwindcss": "0.1.6",
"@fontsource-variable/inter": "^5.0.17", "@fontsource-variable/inter": "^5.0.17",
"@matthiesenxyz/astro-ghostcms": "^3.3.1", "@matthiesenxyz/astro-ghostcms": "^3.3.5",
"@tailwindcss/typography": "^0.5.10", "@tailwindcss/typography": "^0.5.10",
"tailwindcss": "^3.3.5",
"astro-navbar": "^2.3.1", "astro-navbar": "^2.3.1",
"astro-seo": "^0.8.3" "astro-remote": "^0.3.2",
"astro-seo": "^0.8.3",
"tailwindcss": "^3.3.5",
"ultrahtml": "1.5.3"
} }
} }

View File

@ -3,6 +3,11 @@ import type { Settings, Post } from "@matthiesenxyz/astro-ghostcms/api";
import FeatureImage from "./FeatureImage.astro"; import FeatureImage from "./FeatureImage.astro";
import AuthorList from "./AuthorList.astro"; import AuthorList from "./AuthorList.astro";
import { formatDate } from "../utils"; import { formatDate } from "../utils";
import { Markup } from 'astro-remote';
import config from "virtual:@matthiesenxyz/astro-ghostcms/config";
const useRemote = config.ThemeProvider.astroRemote.enable;
export type Props = { export type Props = {
posts: Post[]; posts: Post[];
settings: Settings; settings: Settings;
@ -59,7 +64,15 @@ const latestFeatured = posts[0]
</div> </div>
<div class="divider my-4"/> <div class="divider my-4"/>
<section id="ghostimport" class="text-ctp-subtext1"> <section id="ghostimport" class="text-ctp-subtext1">
{latestFeatured && <Fragment set:html={latestFeatured.html} />}
{useRemote ? (latestFeatured && <Markup
content={latestFeatured.html}
sanitize={{
allowComponents: true,
allowElements: ['a', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img', 'figure', 'figcaption', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'em', 'strong', 'del', 'hr', 'br', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'caption', 'div', 'span', 'script', 'astrocard'],
}}
/>) : (latestFeatured && <Fragment set:html={latestFeatured.html} />) }
</section> </section>
</div> </div>
</main> </main>

View File

@ -2,6 +2,11 @@
import PostHero from "../components/PostHero.astro"; import PostHero from "../components/PostHero.astro";
import PostFooter from "../components/PostFooter.astro"; import PostFooter from "../components/PostFooter.astro";
import { getFeaturedPosts, invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api"; import { getFeaturedPosts, invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api";
import { Markup } from 'astro-remote';
import config from "virtual:@matthiesenxyz/astro-ghostcms/config";
const useRemote = config.ThemeProvider.astroRemote.enable;
export type Props = { export type Props = {
post: Post; post: Post;
settings: Settings; settings: Settings;
@ -14,10 +19,10 @@ async function getPostsSet(){
const featuredPosts = await getFeaturedPosts(); const featuredPosts = await getFeaturedPosts();
const fposts = posts; const fposts = posts;
if(featuredPosts.posts.length === 0){ return fposts } if(featuredPosts.posts.length === 0){ return fposts }
else {
const featured = featuredPosts.posts[0] const featured = featuredPosts.posts[0]
return fposts.filter((p: Post)=>p.id !== featured.id) return fposts.filter((p: Post)=>p.id !== featured.id)
}
} }
const mPosts = await getPostsSet() const mPosts = await getPostsSet()
@ -27,7 +32,15 @@ invariant(settings, "Settings not found");
<PostHero post={post} settings={settings} /> <PostHero post={post} settings={settings} />
<div id="ghostimport" class="mt-4 text-ctp-subtext1"> <div id="ghostimport" class="mt-4 text-ctp-subtext1">
<Fragment set:html={post.html} /> {useRemote ? (
<Markup
content={post.html}
sanitize={{
allowComponents: true,
allowElements: ['a', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img', 'figure', 'figcaption', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'em', 'strong', 'del', 'hr', 'br', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'caption', 'div', 'span', 'script', 'astrocard'],
}}
/>
) : <Fragment set:html={post.html} /> }
</div> </div>
<PostFooter post={post} settings={settings} posts={mPosts} /> <PostFooter post={post} settings={settings} posts={mPosts} />

View File

@ -7,7 +7,7 @@ import PostPreview from '../../components/PostPreview.astro';
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {
@ -37,7 +37,7 @@ const description = `All of the articles we've posted and linked so far under th
<Layout title={title} description={description} settings={settings}> <Layout title={title} description={description} settings={settings}>
<Container> <Container>
<section class="post-card post-card-large"> <section class="post-card post-card-large">
<div class="post-card-content"> <div class="post-card-content">
<div class="post-card-content-link"> <div class="post-card-content-link">
<header class="post-card-header"> <header class="post-card-header">

View File

@ -6,7 +6,7 @@ import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcm
let title = "All Tags"; let title = "All Tags";
let description = "All the tags used so far..."; let description = "All the tags used so far...";
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, 'Settings not found'); invariant(settings, 'Settings not found');

View File

@ -1,54 +0,0 @@
# @matthiesenxyz/astro-ghostcms-rendercontent
## 0.0.8
### Patch Changes
- f921005: Bump dependencies:
- vite from to
- @eliancodes/brutal-ui from to
- typescript from to
- ultrahtml from to
- @fontsource-variable/inter from to
- astro-seo from to
- astro from to
- sass from to
- @astrojs/starlight from to
- sharp from to
## 0.0.7
### Patch Changes
- 1f850db: Bump dependencies:
- astro from to
- vite from to
- astro-seo from to
- sass from to
## 0.0.6
### Patch Changes
- 3a5aea9: Updated Tests and Linted packages
## 0.0.5
### Patch Changes
- 455ad3f: Bump astro from 4.0.0 to 4.3.7
- 12be739: Depencency updates
## 0.0.4
### Patch Changes
- Fix License File
## 0.0.3
### Patch Changes
- Initialization of changeset cli

View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2024 MatthiesenXYZ - Astro-GhostCMS
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.

View File

@ -1,33 +0,0 @@
# Astro GhostCMS Content API HTML Processor
Render remote GhostCMS HTML in Astro with full control over the output.
Powered by [`ultrahtml`](https://github.com/natemoo-re/ultrahtml).
## Rendering Remote Content
The most basic function of `astro-ghostcms-rendercontent` is to convert a string of HTML to Astro friendly HTML. Use the `GhostRender` component.
```astro
---
import { GhostRender } from "@matthiesenxyz/astro-ghostcms-rendercontent";
---
<GhostRender content={post.html} />
```
### Customization
`GhostRender` allows full control over the rendering of output. The `components` option allows you to replace a standard HTML element with a custom component.
```astro
---
import { GhostRender } from "@matthiesenxyz/astro-ghostcms-rendercontent";
import Title from '../components/Title.astro';
---
<!-- Render <h1> as custom <Title> component -->
<GhostRender content={post.html} components={{ h1: Title }} />
```
For examples on how to setup custom components check [examples](./examples/)

View File

@ -1,12 +0,0 @@
---
import { Code } from "astro/components"
import { parse } from "ultrahtml"
import { querySelector } from "ultrahtml/selector"
const html = await Astro.slots.render("default")
const ast = await parse(html)
const codetag = querySelector(ast,'code')
const { children } = codetag
const code = children[0].value
---
<Code code={code} lang={"sh"} theme={"monokai"}/>

View File

@ -1,5 +0,0 @@
---
---
<h1 class="righteous">
<slot />
</h1>

View File

@ -1,5 +0,0 @@
---
---
<h2 class="righteous">
<slot />
</h2>

View File

@ -1,5 +0,0 @@
---
---
<h3 class="righteous">
<slot />
</h3>

View File

@ -1,5 +0,0 @@
---
---
<h4 class="righteous">
<slot />
</h4>

View File

@ -1,5 +0,0 @@
---
---
<h5 class="righteous">
<slot />
</h5>

View File

@ -1,5 +0,0 @@
---
---
<h6 class="righteous">
<slot />
</h6>

View File

@ -1,21 +0,0 @@
---
---
<p class="my-5"><slot /></p>
<style is:inline>
#ghost p a {
color: rgb(0, 123, 247);
}
#ghost ul li a {
color: rgb(0, 123, 247);
}
#ghost ul li {
padding-top: 0.5rem;
margin-left: 2rem;
list-style: circle;
}
#ghost ul {
margin-top: 1rem;
margin-bottom: 1rem;
}
</style>

View File

@ -1,8 +0,0 @@
export { default as H1 } from "./H1.astro";
export { default as H2 } from "./H2.astro";
export { default as H3 } from "./H3.astro";
export { default as H4 } from "./H4.astro";
export { default as H5 } from "./H5.astro";
export { default as H6 } from "./H6.astro";
export { default as CodeSlot } from "./CodeSlot.astro";
export { default as Paragraph } from "./Paragraph.astro";

View File

@ -1 +0,0 @@
export { default as GhostRender } from "./lib/GhostRender.astro";

View File

@ -1,18 +0,0 @@
---
import { createComponentProxy, html } from './utils';
export interface Props {
content?: string;
components?: Record<string, any>;
}
const input = Astro.props.content ?? await Astro.slots.render('default');
if (!input) {
throw new Error('Unable to render <GhostRender> without a content prop or children')
}
// @ts-ignore
const components = createComponentProxy($$result, Astro.props.components);
const content = await html(input, { components });
---
<Fragment set:html={content} />

View File

@ -1 +0,0 @@
/// <reference types="astro/client" />

View File

@ -1,59 +0,0 @@
import { jsx as h } from "astro/jsx-runtime";
import { renderJSX } from "astro/runtime/server/jsx";
import * as entities from "entities";
import { transform } from "ultrahtml";
import { __unsafeHTML } from "ultrahtml";
import swap from "ultrahtml/transformers/swap";
export function createComponentProxy(
result,
_components: Record<string, any> = {},
) {
const components = {};
for (const [key, value] of Object.entries(_components)) {
if (typeof value === "string") {
components[key] = value;
} else {
components[key] = async (props, children) => {
if (key === "CodeBlock" || key === "CodeSpan") {
props.code = entities.decode(JSON.parse(`"${props.code}"`));
}
const output = await renderJSX(
result,
h(value, { ...props, "set:html": children.value }),
);
return __unsafeHTML(output);
};
}
}
return components;
}
function getIndent(ln: string): string {
if (ln.trim() === ln) return "";
return ln.slice(0, ln.length - ln.trim().length);
}
export function dedent(str: string): string {
const lns = str.replace(/^[\r\n]+/, "").split("\n");
let indent = getIndent(lns[0]);
if (indent.length === 0 && lns.length > 1) {
indent = getIndent(lns[1]);
}
return lns
.map((ln) => (ln.startsWith(indent) ? ln.slice(indent.length) : ln))
.map((ln, i, { length }) => (i === length - 1 ? ln.trim() : ln))
.join("\n");
}
export interface HTMLOptions {
// biome-ignore lint/complexity/noBannedTypes: <explanation>
components?: {};
}
export async function html(
input: string,
opts: HTMLOptions = {},
): Promise<string> {
return transform(dedent(input), [swap(opts.components)]);
}

View File

@ -1,47 +0,0 @@
{
"name": "@matthiesenxyz/astro-ghostcms-rendercontent",
"type": "module",
"version": "0.0.8",
"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"
},
"publishConfig": {
"access": "public"
},
"sideEffects": false,
"homepage": "https://astro-ghostcms.xyz",
"files": [
"examples",
"lib",
"index.ts",
"CHANGELOG.md"
],
"types": "./index.ts",
"exports": {
".": "./index.ts",
"./lib/*": "./lib/*",
"./examples/*": "./examples/*",
"./package.json": "./package.json"
},
"keywords": [
"astro-ghostcms"
],
"author": {
"email": "adam@matthiesen.xyz",
"name": "Adam Matthiesen - MatthiesenXYZ",
"url": "https://matthiesen.xyz"
},
"license": "MIT",
"dependencies": {
"entities": "^4.5.0",
"ultrahtml": "^1.5.3"
},
"devDependencies": {
"astro": "4.4.13"
}
}

View File

@ -1,5 +1,61 @@
# @matthiesenxyz/astro-ghostcms-theme-default # @matthiesenxyz/astro-ghostcms-theme-default
## 0.1.20
### Patch Changes
- f82035b: Bump dependencies:
- astro-integration-kit from to
- @unocss/astro from to
- @unocss/reset from to
- astro-font from to
- unocss from to
- sass from to
- @matthiesenxyz/astro-gists from to
- vite-tsconfig-paths from to
- astro from to
- Updated dependencies [f82035b]
- @matthiesenxyz/astro-ghostcms@3.3.5
## 0.1.19
### Patch Changes
- f097c6a: Adds a toggleswitch to allow users to disable astro-remote usage for rendering ghost-content
- Updated dependencies [f097c6a]
- @matthiesenxyz/astro-ghostcms@3.3.4
## 0.1.18
### Patch Changes
- b0218e1: fix:
- Removed CodeSlot Component that sometimes would break with some <pre> components
- Will be adding at a latter time a custom component to replace this, but at this time this is now fixed.
## 0.1.17
### Patch Changes
- 4c1002a: fix getAllTags bug for themes and bump other packages deps
- Updated dependencies [4c1002a]
- @matthiesenxyz/astro-ghostcms@3.3.2
## 0.1.16
### Patch Changes
- 746fcc5: Fix html rendering to allow custom components
## 0.1.15
### Patch Changes
- 2724119: Migrate to `astro-remote` for internal processing of GhostCMS HTML. No user changes required.
## 0.1.14 ## 0.1.14
### Patch Changes ### Patch Changes

View File

@ -1,7 +1,7 @@
{ {
"name": "@matthiesenxyz/astro-ghostcms-theme-default", "name": "@matthiesenxyz/astro-ghostcms-theme-default",
"description": "Default Theme for astro-ghostcms", "description": "Default Theme for astro-ghostcms",
"version": "0.1.14", "version": "0.1.20",
"homepage": "https://astro-ghostcms.xyz/", "homepage": "https://astro-ghostcms.xyz/",
"type": "module", "type": "module",
"license": "MIT", "license": "MIT",
@ -43,15 +43,17 @@
"scripts": {}, "scripts": {},
"devDependencies": { "devDependencies": {
"@matthiesenxyz/astro-ghostcms": "*", "@matthiesenxyz/astro-ghostcms": "*",
"@astrojs/check": "^0.5.6", "@astrojs/check": "^0.5.9",
"typescript": "^5.4.2" "typescript": "^5.4.2"
}, },
"peerDependencies": { "peerDependencies": {
"astro": "^4.2.1" "@matthiesenxyz/astro-ghostcms": ">=3.3.5",
"astro": ">=4.4.0"
}, },
"dependencies": { "dependencies": {
"@matthiesenxyz/astro-ghostcms": "^3.3.1", "astro-font": "^0.0.78",
"astro-font": "^0.0.77", "astro-remote": "^0.3.2",
"sass": "^1.71.1" "sass": "^1.72.0",
"ultrahtml": "^1.5.3"
} }
} }

View File

@ -1,6 +1,11 @@
--- ---
import FeatureImage from "../components/FeatureImage.astro"; import FeatureImage from "../components/FeatureImage.astro";
import type { Settings, Page } from "@matthiesenxyz/astro-ghostcms/api"; import type { Settings, Page } from "@matthiesenxyz/astro-ghostcms/api";
import { Markup } from 'astro-remote';
import config from "virtual:@matthiesenxyz/astro-ghostcms/config";
const useRemote = config.ThemeProvider.astroRemote.enable;
export type Props = { export type Props = {
page: Page; page: Page;
settings: Settings; settings: Settings;
@ -24,7 +29,15 @@ const { page, settings, pageClass } = Astro.props as Props;
<section class="gh-content gh-canvas"> <section class="gh-content gh-canvas">
<h1 class="article-title">{page.title}</h1> <h1 class="article-title">{page.title}</h1>
<Fragment set:html={page.html} /> {useRemote ? (
<Markup
content={page.html}
sanitize={{
allowComponents: true,
allowElements: ['a', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img', 'figure', 'figcaption', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'em', 'strong', 'del', 'hr', 'br', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'caption', 'div', 'span', 'script', 'astrocard'],
}}
/>
) : <Fragment set:html={page.html} /> }
</section> </section>
</article> </article>
</main> </main>

View File

@ -2,6 +2,11 @@
import PostHero from "../components/PostHero.astro"; import PostHero from "../components/PostHero.astro";
import PostFooter from "../components/PostFooter.astro"; import PostFooter from "../components/PostFooter.astro";
import {invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api"; import {invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api";
import { Markup } from 'astro-remote';
import config from "virtual:@matthiesenxyz/astro-ghostcms/config";
const useRemote = config.ThemeProvider.astroRemote.enable;
export type Props = { export type Props = {
post: Post; post: Post;
settings: Settings; settings: Settings;
@ -16,7 +21,15 @@ invariant(settings, "Settings not found");
<article class={`article post ${postClass}`}> <article class={`article post ${postClass}`}>
<PostHero post={post} settings={settings} /> <PostHero post={post} settings={settings} />
<section class="gh-content gh-canvas"> <section class="gh-content gh-canvas">
<Fragment set:html={post.html} /> {useRemote ? (
<Markup
content={post.html}
sanitize={{
allowComponents: true,
allowElements: ['a', 'p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'img', 'figure', 'figcaption', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'em', 'strong', 'del', 'hr', 'br', 'table', 'thead', 'tbody', 'tr', 'th', 'td', 'caption', 'div', 'span', 'script', 'astrocard'],
}}
/>
) : <Fragment set:html={post.html} /> }
</section> </section>
</article> </article>
<PostFooter post={post} settings={settings} posts={posts} /> <PostFooter post={post} settings={settings} posts={posts} />

View File

@ -1,13 +1,13 @@
--- ---
import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro';
import DefaultPageLayout from "../../layouts/default.astro";
import PostPreview from "../../components/PostPreview.astro";
import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro';
import PostPreview from "../../components/PostPreview.astro";
import DefaultPageLayout from "../../layouts/default.astro";
import { getGhostImgPath } from "../../utils"; import { getGhostImgPath } from "../../utils";
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {

View File

@ -1,13 +1,13 @@
--- ---
import DefaultPageLayout from "../layouts/default.astro"; import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
import TagCard from "../components/TagCard.astro"; import TagCard from "../components/TagCard.astro";
import { getSettings, getAllTags, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import DefaultPageLayout from "../layouts/default.astro";
let title = "All Tags"; let title = "All Tags";
let description = "All the tags used so far..."; let description = "All the tags used so far...";
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, "Settings not found"); invariant(settings, "Settings not found");
--- ---

View File

@ -1,5 +1,46 @@
# @matthiesenxyz/astro-ghostcms # @matthiesenxyz/astro-ghostcms
## 3.3.5
### Patch Changes
- f82035b: Bump dependencies:
- astro-integration-kit from to
- @unocss/astro from to
- @unocss/reset from to
- astro-font from to
- unocss from to
- sass from to
- @matthiesenxyz/astro-gists from to
- vite-tsconfig-paths from to
- astro from to
- Updated dependencies [f82035b]
- @matthiesenxyz/astro-ghostcms-theme-default@0.1.20
## 3.3.4
### Patch Changes
- f097c6a: Adds a toggleswitch to allow users to disable astro-remote usage for rendering ghost-content
- Updated dependencies [f097c6a]
- @matthiesenxyz/astro-ghostcms-theme-default@0.1.19
## 3.3.3
### Patch Changes
- b685e66: Update Deps
## 3.3.2
### Patch Changes
- 4c1002a: fix getAllTags bug for themes and bump other packages deps
- Updated dependencies [4c1002a]
- @matthiesenxyz/astro-ghostcms-theme-default@0.1.17
## 3.3.1 ## 3.3.1
### Patch Changes ### Patch Changes

View File

@ -66,6 +66,9 @@ export default defineConfig({
ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled. ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled.
disableThemeProvider: false, // OPTIONAL - Default False disableThemeProvider: false, // OPTIONAL - Default False
theme: "@matthiesenxyz/astro-ghostcms-theme-default", // OPTIONAL - Default Theme shown. theme: "@matthiesenxyz/astro-ghostcms-theme-default", // OPTIONAL - Default Theme shown.
astroRemote: {
enable: true // OPTIONAL - Default True, Allows the user to switch to standard <Fragment> html rendering if they are having issues with Astro-remote
}
}; };
disableDefault404: false, // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`. disableDefault404: false, // Allows the user to disable the default `/404 page, to be able to create their own under `/src/pages/404.astro`.
enableRSSFeed: true, // Allows the user to Enable or disable RSS Feed Generation. Default: true enableRSSFeed: true, // Allows the user to Enable or disable RSS Feed Generation. Default: true

View File

@ -1,7 +1,7 @@
{ {
"name": "@matthiesenxyz/astro-ghostcms", "name": "@matthiesenxyz/astro-ghostcms",
"description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content", "description": "Astro GhostCMS integration to allow easier importing of GhostCMS Content",
"version": "3.3.1", "version": "3.3.5",
"homepage": "https://astro-ghostcms.xyz/", "homepage": "https://astro-ghostcms.xyz/",
"type": "module", "type": "module",
"license": "MIT", "license": "MIT",
@ -61,24 +61,24 @@
}, },
"devDependencies": { "devDependencies": {
"@types/fs-extra": "^11.0.4", "@types/fs-extra": "^11.0.4",
"@types/node": "^20.11.25", "@types/node": "^20.11.28",
"vitest": "^1.3.1", "vitest": "^1.4.0",
"vitest-fetch-mock": "^0.2.2" "vitest-fetch-mock": "^0.2.2"
}, },
"dependencies": { "dependencies": {
"@astrojs/rss": "^4.0.5", "@astrojs/rss": "^4.0.5",
"@astrojs/sitemap": "^3.1.1", "@astrojs/sitemap": "^3.1.1",
"@matthiesenxyz/astro-ghostcms-theme-default": "^0.1.14", "@matthiesenxyz/astro-ghostcms-theme-default": "^0.1.20",
"@resvg/resvg-js": "^2.6.0", "@resvg/resvg-js": "^2.6.0",
"@ts-ghost/core-api": "^6.0.0", "@ts-ghost/core-api": "^6.0.0",
"@ts-ghost/content-api": "^4.0.12", "@ts-ghost/content-api": "^4.0.12",
"astro-integration-kit": "^0.5.1", "astro-integration-kit": "^0.6.0",
"astro-robots-txt": "^1.0.0", "astro-robots-txt": "^1.0.0",
"fs-extra": "^11.2.0", "fs-extra": "^11.2.0",
"package-json": "^10.0.0", "package-json": "^10.0.0",
"picocolors": "^1.0.0", "picocolors": "^1.0.0",
"satori": "^0.10.13", "satori": "^0.10.13",
"satori-html": "^0.3.2", "satori-html": "^0.3.2",
"vite": "^5.1.5" "vite": "^5.1.6"
} }
} }

View File

@ -1,5 +1,5 @@
import { TSGhostContentAPI } from "@ts-ghost/content-api"; import { TSGhostContentAPI } from "@ts-ghost/content-api";
import type { Page, Post } from "../schemas/api"; import type { Page, Post, Tag } from "../schemas/api";
// LOAD ENVIRONMENT VARIABLES // LOAD ENVIRONMENT VARIABLES
import { loadEnv } from "vite"; import { loadEnv } from "vite";
@ -94,17 +94,20 @@ export const getSettings = async () => {
}; };
export const getAllTags = async () => { export const getAllTags = async () => {
const results = await api.tags const tags: Tag[] = [];
.browse() let cursor = await api.tags
.browse({
limit: 'all'
})
.include({ "count.posts": true }) .include({ "count.posts": true })
.fetch(); .paginate();
if (!results.success) {
throw new Error(results.errors.map((e) => e.message).join(", ")); if (cursor.current.success) tags.push(...cursor.current.data);
while (cursor.next) {
cursor = await cursor.next.paginate();
if (cursor.current.success) tags.push(...cursor.current.data);
} }
return { return tags;
tags: results.data,
meta: results.meta,
};
}; };
export const getFeaturedPosts = async () => { export const getFeaturedPosts = async () => {

View File

@ -16,7 +16,7 @@ import satoriOG from "../../satori";
export const getStaticPaths: GetStaticPaths = async () => { export const getStaticPaths: GetStaticPaths = async () => {
const result: GetStaticPathsItem[] = []; const result: GetStaticPathsItem[] = [];
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, "Settings are required"); invariant(settings, "Settings are required");

View File

@ -17,22 +17,19 @@ export const GhostUserConfigSchema = z.object({
/** OPTIONAL - Configure the Theme Provider /** OPTIONAL - Configure the Theme Provider
* @ This option allows the user to configure the Theme Provider * @ This option allows the user to configure the Theme Provider
*/ */
ThemeProvider: z ThemeProvider: z.object({
.object({
/** OPTIONAL - Disable the theme provider /** OPTIONAL - Disable the theme provider
* @default false * @default false
*/ */
disableThemeProvider: z.coerce.boolean(), disableThemeProvider: z.coerce.boolean().default(false),
/** OPTIONAL - Set the theme you want to use /** OPTIONAL - Set the theme you want to use
* @default "@matthiesenxyz/astro-ghostcms-theme-default" * @default "@matthiesenxyz/astro-ghostcms-theme-default"
*/ */
theme: z.string(), theme: z.string().default("@matthiesenxyz/astro-ghostcms-theme-default"),
}) astroRemote: z.object({
.optional() enable: z.boolean().default(true),
.default({ }).optional().default({}),
disableThemeProvider: false, }).optional().default({}),
theme: "@matthiesenxyz/astro-ghostcms-theme-default"
}),
/** Allows the user to disable the provided 404 page */ /** Allows the user to disable the provided 404 page */
disableDefault404: z.coerce.boolean().optional(), disableDefault404: z.coerce.boolean().optional(),
/** Allows the user to disable the provided RSS Feed */ /** Allows the user to disable the provided RSS Feed */

View File

@ -1,5 +1,11 @@
# @matthiesenxyz/create-astro-ghostcms # @matthiesenxyz/create-astro-ghostcms
## 0.1.2
### Patch Changes
- 4c1002a: fix getAllTags bug for themes and bump other packages deps
## 0.1.1 ## 0.1.1
### Patch Changes ### Patch Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@matthiesenxyz/create-astro-ghostcms", "name": "@matthiesenxyz/create-astro-ghostcms",
"version": "0.1.1", "version": "0.1.2",
"description": "Utility to quickly get started with our Integration and astro", "description": "Utility to quickly get started with our Integration and astro",
"type": "module", "type": "module",
"main": "./create-astro-ghostcms.mjs", "main": "./create-astro-ghostcms.mjs",
@ -44,7 +44,7 @@
"devDependencies": { "devDependencies": {
"@types/fs-extra": "^11.0.1", "@types/fs-extra": "^11.0.1",
"@types/gunzip-maybe": "^1.4.0", "@types/gunzip-maybe": "^1.4.0",
"@types/node": "^20.11.25", "@types/node": "^20.11.28",
"@types/tar-fs": "^2.0.1", "@types/tar-fs": "^2.0.1",
"typescript": "^5.4.2" "typescript": "^5.4.2"
}, },

View File

@ -1,13 +1,13 @@
--- ---
import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro';
import DefaultPageLayout from "../../layouts/default.astro";
import PostPreview from "../../components/PostPreview.astro";
import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro';
import PostPreview from "../../components/PostPreview.astro";
import DefaultPageLayout from "../../layouts/default.astro";
import { getGhostImgPath } from "../../utils"; import { getGhostImgPath } from "../../utils";
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {

View File

@ -1,13 +1,13 @@
--- ---
import DefaultPageLayout from "../layouts/default.astro"; import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
import TagCard from "../components/TagCard.astro"; import TagCard from "../components/TagCard.astro";
import { getSettings, getAllTags, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import DefaultPageLayout from "../layouts/default.astro";
let title = "All Tags"; let title = "All Tags";
let description = "All the tags used so far..."; let description = "All the tags used so far...";
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, "Settings not found"); invariant(settings, "Settings not found");
--- ---

View File

@ -1,5 +1,72 @@
# @matthiesenxyz/starlight-ghostcms # @matthiesenxyz/starlight-ghostcms
## 0.1.9
### Patch Changes
- f82035b: Bump dependencies:
- astro-integration-kit from to
- @unocss/astro from to
- @unocss/reset from to
- astro-font from to
- unocss from to
- sass from to
- @matthiesenxyz/astro-gists from to
- vite-tsconfig-paths from to
- astro from to
## 0.1.8
### Patch Changes
- b0218e1: fix:
- Removed CodeSlot Component that sometimes would break with some <pre> components
- Will be adding at a latter time a custom component to replace this, but at this time this is now fixed.
## 0.1.7
### Patch Changes
- b685e66: Update Deps
## 0.1.6
### Patch Changes
- 4c1002a: fix getAllTags bug for themes and bump other packages deps
## 0.1.5
### Patch Changes
- a02c78b: bump starlight-ghostcms
## 0.1.4
### Patch Changes
- 209e99b: update deps
## 0.1.4
### Patch Changes
- 746fcc5: Fix html rendering to allow custom components
## 0.1.3
### Patch Changes
- 205738c: fix bug, and resolved config issue that was now will allow users to pass the ghostURL within their `astro.config.mjs`
## 0.1.2
### Patch Changes
- 2724119: Migrate to `astro-remote` for internal processing of GhostCMS HTML. No user changes required.
## 0.1.1 ## 0.1.1
### Patch Changes ### Patch Changes

View File

@ -49,7 +49,9 @@ export default defineConfig({
integrations: [ integrations: [
starlight({ starlight({
plugins: [ plugins: [
starlightGhostCMS() starlightGhostCMS({
ghostURL: "https://ghostdemo.matthiesen.xyz"
})
], ],
title: 'My Docs', title: 'My Docs',
}), }),
@ -63,7 +65,8 @@ You must also create 2 environment variables in a `.env` file with the following
```env ```env
CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48 CONTENT_API_KEY=a33da3965a3a9fb2c6b3f63b48
CONTENT_API_URL=https://ghostdemo.matthiesen.xyz CONTENT_API_URL=https://ghostdemo.matthiesen.xyz // ghostURL option in `astro.config.mjs` will take priority. (This is fallback option)
GITHUB_PERSONAL_TOKEN=ghp_ //OPTIONAL - This is for Astro-Gists if you choose to use it!
``` ```
**When you deploy your install dont forget to set the above ENVIRONMENT VARIABLES on your provider!** **When you deploy your install dont forget to set the above ENVIRONMENT VARIABLES on your provider!**

View File

@ -1,24 +1,14 @@
import type { import type { StarlightPlugin, StarlightUserConfig } from "@astrojs/starlight/types";
StarlightPlugin,
StarlightUserConfig,
} from "@astrojs/starlight/types";
import type { AstroIntegrationLogger } from "astro"; import type { AstroIntegrationLogger } from "astro";
import { import { type StarlightGhostConfig, validateConfig } from "./src/schemas/config";
type StarlightGhostConfig,
validateConfig,
} from "./src/schemas/config";
import { facebook, getSettings, invariant, twitter } from "./src/utils/api";
import starlightGhostcms from "./src/integrations/starlight-ghostcms"; import starlightGhostcms from "./src/integrations/starlight-ghostcms";
const settings = await getSettings();
export type { StarlightGhostConfig }; export type { StarlightGhostConfig };
export default function starlightGhostCMS( export default function starlightGhostCMS(
userConfig?: StarlightGhostConfig, userConfig?: StarlightGhostConfig,
): StarlightPlugin { ): StarlightPlugin {
const config: StarlightGhostConfig = validateConfig(userConfig); const config: StarlightGhostConfig = validateConfig(userConfig);
invariant(settings, "Settings not available... check your api key/url");
return { return {
name: "@matthiesenxyz/starlight-ghostcms-plugin", name: "@matthiesenxyz/starlight-ghostcms-plugin",
@ -32,14 +22,12 @@ export default function starlightGhostCMS(
}) { }) {
// Add the Starlight-GhostCMS integration // Add the Starlight-GhostCMS integration
addIntegration(starlightGhostcms(config)); addIntegration(starlightGhostcms(config));
// Update the Starlight config with the GhostCMS config // Update the Starlight config with the GhostCMS config
updateStarlightConfig({ updateStarlightConfig({
social: { social: {
...starlightConfig.social, ...starlightConfig.social,
...overrideRSS(starlightConfig.social, astroConfig.site), ...overrideRSS(starlightConfig.social, astroConfig.site),
...overrideTwitter(starlightConfig.social),
...overrideFacebook(starlightConfig.social),
}, },
components: { components: {
...starlightConfig.components, ...starlightConfig.components,
@ -65,6 +53,7 @@ export default function starlightGhostCMS(
}; };
} }
function overrideRSS( function overrideRSS(
socials: StarlightUserConfig["social"], socials: StarlightUserConfig["social"],
url: string | undefined url: string | undefined
@ -74,26 +63,6 @@ function overrideRSS(
return { rss: `${url}/rss.xml` }; return { rss: `${url}/rss.xml` };
} }
function overrideTwitter(
socials: StarlightUserConfig["social"],
) {
if (socials?.twitter) { return {}; }
if (settings?.twitter) {
return { twitter: twitter(settings.twitter), }
}
return undefined;
}
function overrideFacebook(
socials: StarlightUserConfig["social"],
) {
if (socials?.facebook) { return {}; }
if (settings?.facebook) {
return { facebook: facebook(settings.facebook), }
}
return undefined;
}
function overrideStarlightComponent( function overrideStarlightComponent(
components: StarlightUserConfig["components"], components: StarlightUserConfig["components"],
logger: AstroIntegrationLogger, logger: AstroIntegrationLogger,

View File

@ -1,7 +1,7 @@
{ {
"name": "@matthiesenxyz/starlight-ghostcms", "name": "@matthiesenxyz/starlight-ghostcms",
"description": "Starlight GhostCMS plugin to allow easier importing of GhostCMS Content into your starlight website", "description": "Starlight GhostCMS plugin to allow easier importing of GhostCMS Content into your starlight website",
"version": "0.1.1", "version": "0.1.9",
"homepage": "https://astro-ghostcms.xyz/", "homepage": "https://astro-ghostcms.xyz/",
"type": "module", "type": "module",
"license": "MIT", "license": "MIT",
@ -54,17 +54,19 @@
}, },
"devDependencies": { "devDependencies": {
"@astrojs/starlight": "^0.21.1", "@astrojs/starlight": "^0.21.1",
"astro": "^4.4.13", "vitest": "^1.4.0",
"vitest": "^1.3.1",
"vitest-fetch-mock": "^0.2.2" "vitest-fetch-mock": "^0.2.2"
}, },
"dependencies": { "dependencies": {
"@astrojs/rss": "^4.0.5", "@astrojs/rss": "^4.0.5",
"@matthiesenxyz/astro-gists": "^0.2.11",
"@ts-ghost/core-api": "^6.0.0", "@ts-ghost/core-api": "^6.0.0",
"@ts-ghost/content-api": "^4.0.12", "@ts-ghost/content-api": "^4.0.12",
"astro-integration-kit": "^0.5.1", "astro-integration-kit": "^0.6.0",
"vite": "^5.1.5", "astro-remote": "^0.3.2",
"vite-tsconfig-paths": "^4.3.1" "ultrahtml": "^1.5.3",
"vite": "^5.1.6",
"vite-tsconfig-paths": "^4.3.2"
}, },
"peerDependencies": { "peerDependencies": {
"@astrojs/starlight": ">=0.19.0", "@astrojs/starlight": ">=0.19.0",

View File

@ -64,7 +64,7 @@ const { author } = Astro.props
img { img {
border: 1px solid var(--sl-color-gray-2); border: 1px solid var(--sl-color-gray-2);
border-radius: 9999px; border-radius: 9999px;
height: 10rem; height: 6rem;
width: 10rem; width: 6rem;
} }
</style> </style>

View File

@ -1,5 +1,6 @@
--- ---
import type { Author } from '../schemas/authors' import type { Author } from '../schemas/authors'
import config from 'virtual:starlight-ghostcms/config';
interface Props { interface Props {
author: Author author: Author
@ -11,7 +12,7 @@ const isLink = author.slug !== undefined
const Element = isLink ? 'a' : 'div' const Element = isLink ? 'a' : 'div'
--- ---
<Element href={isLink ? '/blog/authors' : undefined} class="author"> <Element href={isLink ? `/${config.route}/authors` : undefined} class="author">
{author.profile_image && <img alt={author.name} src={author.profile_image} />} {author.profile_image && <img alt={author.name} src={author.profile_image} />}
<div class="text"> <div class="text">
<div class="name">{author.name}</div> <div class="name">{author.name}</div>

View File

@ -1,6 +1,7 @@
--- ---
import type { Post } from '../schemas/posts' import type { Post } from '../schemas/posts'
import Metadata from './Metadata.astro' import Metadata from './Metadata.astro'
import config from 'virtual:starlight-ghostcms/config';
interface Props { interface Props {
entry: Post entry: Post
@ -14,7 +15,7 @@ const Excerpt = entry.excerpt
<article class="preview"> <article class="preview">
<header> <header>
<h2> <h2>
<a href={`/blog/${entry.slug}`}>{entry.title}</a> <a href={`/${config.route}/${entry.slug}`}>{entry.title}</a>
</h2> </h2>
<Metadata entry={entry} /> <Metadata entry={entry} />
</header> </header>

View File

@ -5,22 +5,52 @@ import {
import { corePlugins } from "astro-integration-kit/plugins"; import { corePlugins } from "astro-integration-kit/plugins";
import { z } from "astro/zod"; import { z } from "astro/zod";
import { type StarlightGhostConfig } from "../schemas/config"; import { type StarlightGhostConfig } from "../schemas/config";
import astroGists from "@matthiesenxyz/astro-gists";
import { AstroError } from "astro/errors";
import { loadEnv } from "vite";
// Load environment variables
const ENV = loadEnv("all", process.cwd(), "CONTENT_API");
export default defineIntegration({ export default defineIntegration({
name: "@matthiesenxyz/starlight-ghostcms", name: "@matthiesenxyz/starlight-ghostcms",
optionsSchema: z.custom<StarlightGhostConfig>(), optionsSchema: z.custom<StarlightGhostConfig>(),
plugins: [...corePlugins], plugins: [...corePlugins],
setup({ options }) { setup({ options, name }) {
const { resolve } = createResolver(import.meta.url); const { resolve } = createResolver(import.meta.url);
return { return {
"astro:config:setup": ({ "astro:config:setup": ({
watchIntegration, watchIntegration,
addVirtualImports, addVirtualImports,
injectRoute injectRoute,
logger,
addIntegration,
}) => { }) => {
watchIntegration(resolve()); watchIntegration(resolve());
// Check for GhostCMS API Key
if (ENV.CONTENT_API_KEY === undefined) {
throw new AstroError(
`${name} CONTENT_API_KEY is not set in environment variables`,
);
}
// Check for GhostCMS URL
if (options.ghostURL === undefined) {
logger.warn("ghostURL is not set in user configuration falling back to environment variable");
if (ENV.CONTENT_API_URL === undefined) {
throw new AstroError(
`${name} CONTENT_API_URL is not set in environment variables`,
);
}
}
// Add the AstroGist integration if enabled
logger.info("Adding @matthiesenxyz/astro-gists integration ...");
addIntegration(astroGists());
logger.info("Note: If you are using Astro-Gists with GhostCMS Make sure to set the `GITHUB_PERSONAL_TOKEN` in your `.env` file. \n Otherwise, you can ignore any error messages related to Astro-Gists.")
addVirtualImports({ addVirtualImports({
'virtual:starlight-ghostcms/config': `export default ${JSON.stringify(options)}`, 'virtual:starlight-ghostcms/config': `export default ${JSON.stringify(options)}`,
}); });

View File

@ -2,7 +2,6 @@
import StarlightMarkdownContent from '@astrojs/starlight/components/MarkdownContent.astro' import StarlightMarkdownContent from '@astrojs/starlight/components/MarkdownContent.astro'
import type { Props } from '@astrojs/starlight/props' import type { Props } from '@astrojs/starlight/props'
import config from 'virtual:starlight-ghostcms/config' import config from 'virtual:starlight-ghostcms/config'
import { isAnyBlogPostPage } from '../utils/page'
import Metadata from '../components/Metadata.astro' import Metadata from '../components/Metadata.astro'
import type { Post } from '../schemas/posts' import type { Post } from '../schemas/posts'
@ -11,7 +10,6 @@ export function checkpath(path: string){
} }
const isBlog = checkpath(Astro.url.pathname) const isBlog = checkpath(Astro.url.pathname)
const isBlogPost = isAnyBlogPostPage(Astro.props.slug)
let blogEntry: Post | undefined = undefined let blogEntry: Post | undefined = undefined
--- ---

View File

@ -1,11 +1,12 @@
--- ---
import config from 'virtual:starlight-ghostcms/config' import config from 'virtual:starlight-ghostcms/config';
import { Image } from "astro:assets"; import { Image } from "astro:assets";
import Page from '../components/Page.astro' import Page from '../components/Page.astro';
import { getPageProps } from '../utils/page' import { getPageProps } from '../utils/page';
import { getAllPosts } from '../utils/api' import { getAllPosts } from '../utils/api';
import Metadata from '../components/Metadata.astro' import Metadata from '../components/Metadata.astro';
import { Markup } from 'astro-remote';
import * as Gists from '@matthiesenxyz/astro-gists/components';
export async function getStaticPaths() { export async function getStaticPaths() {
const entries = await getAllPosts(); const entries = await getAllPosts();
@ -36,13 +37,23 @@ const pageProps = getPageProps(post.title)
height={800} height={800}
/> />
<figcaption> <figcaption>
<Fragment set:html={post.feature_image_caption} /> <Markup content={post.feature_image_caption? post.feature_image_caption : "<div />"} />
</figcaption> </figcaption>
</figure> </figure>
)} )}
</header> </header>
<br /> <br />
<Fragment set:html={post.html} />
<Markup
content={post.html}
sanitize={{
allowComponents: true,
}}
components={{
getgist: Gists.GetGist,
getgistgroup: Gists.GetGistGroup,
}}
/>
<footer class="not-content"> <footer class="not-content">
</footer> </footer>

View File

@ -5,20 +5,28 @@ import Page from '../components/Page.astro'
//import PrevNextLinks from '../components/PrevNextLinks.astro' //import PrevNextLinks from '../components/PrevNextLinks.astro'
import { getPageProps } from '../utils/page' import { getPageProps } from '../utils/page'
import { getSluggedPage } from '../utils/api' import { getSluggedPage } from '../utils/api'
import { Markup } from 'astro-remote'
const aboutPage = await getSluggedPage("about"); const aboutPage = await getSluggedPage("about");
//const { entries, nextLink, prevLink } = Astro.props //const { entries, nextLink, prevLink } = Astro.props
const pageProps = getPageProps(aboutPage?.post?.title) const pageProps = getPageProps(aboutPage ? aboutPage.post.title : "")
--- ---
<Page {...pageProps}> <Page {...pageProps}>
{config.supportGhost && ( {config.supportGhost && (
<div id="pghost">Powered by <a href="https://ghost.org">Ghost</a></div> <div id="pghost">Powered by <a href="https://ghost.org">Ghost</a></div>
)} )}
{aboutPage &&
<Metadata entry={aboutPage.post} /> <Metadata entry={aboutPage.post} />
<Fragment set:html={aboutPage.post.html} /> <Markup
content={aboutPage.post.html}
sanitize={{
allowComponents: true,
}}
/>
}
<footer class="not-content"> <footer class="not-content">
<!--PrevNextLinks next={nextLink} prev={prevLink} /--> <!--PrevNextLinks next={nextLink} prev={prevLink} /-->
</footer> </footer>

View File

@ -3,6 +3,10 @@ import { z } from "astro/zod";
const configSchema = z const configSchema = z
.object({ .object({
/**
* The URL of the GhostCMS instance.
*/
ghostURL: z.string().url().optional(),
/** /**
* The number of blog posts to display per page in the blog post list. * The number of blog posts to display per page in the blog post list.
*/ */
@ -31,8 +35,8 @@ const configSchema = z
* Turn on and off "Powered by Ghost" * Turn on and off "Powered by Ghost"
*/ */
supportGhost: z.boolean().default(true), supportGhost: z.boolean().default(true),
}) verbose: z.boolean().default(false),
.default({ postCount: 5, recentPostCount: 10, route: "blog", title: "Blog", rssDescription: "My Awesome Starlight-GhostCMS Blog", supportGhost: true}); });
export function validateConfig(userConfig: unknown): StarlightGhostConfig { export function validateConfig(userConfig: unknown): StarlightGhostConfig {
const config = configSchema.safeParse(userConfig); const config = configSchema.safeParse(userConfig);

View File

@ -3,7 +3,7 @@ import type { Page, Post } from "./schemas";
// LOAD ENVIRONMENT VARIABLES // LOAD ENVIRONMENT VARIABLES
import { loadEnv } from "vite"; import { loadEnv } from "vite";
//import StarlightGhostConfig from "virtual:starlight-ghostcms/config"; import config from "virtual:starlight-ghostcms/config";
const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv( const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv(
"all", "all",
@ -11,12 +11,9 @@ const { CONTENT_API_KEY, CONTENT_API_URL } = loadEnv(
"CONTENT_", "CONTENT_",
); );
//const ConfURL = StarlightGhostConfig.ghostURL || "";
// SETUP GHOST API // SETUP GHOST API
const ghostApiKey = CONTENT_API_KEY || ""; const ghostApiKey = CONTENT_API_KEY || "";
const ghostUrl = CONTENT_API_URL || ""; const ghostUrl = config.ghostURL || CONTENT_API_URL || "";
const version = "v5.0"; const version = "v5.0";
const api = new TSGhostContentAPI(ghostUrl, ghostApiKey, version); const api = new TSGhostContentAPI(ghostUrl, ghostApiKey, version);
@ -101,6 +98,15 @@ export const getAllPages = async () => {
return pages; return pages;
}; };
export const getSettings = async () => {
const res = await api.settings.fetch();
if (res.success) {
return res.data;
}
return null;
};
export const getSluggedPage = async (slug:string) => { export const getSluggedPage = async (slug:string) => {
const results = await api.pages const results = await api.pages
.read({slug: slug}) .read({slug: slug})
@ -110,21 +116,16 @@ export const getSluggedPage = async (slug:string) => {
}).fetch() }).fetch()
if (!results.success) { if (!results.success) {
throw new Error(results.errors.map((e) => e.message).join(", ")); if (config.verbose === true){
console.log(`[Starlight-GhostCMS]: ${results.errors.map((e) => e.message).join(", ")}Resource: (${slug})`);
}
return null;
} }
return { return {
post: results.data, post: results.data,
}; };
}; };
export const getSettings = async () => {
const res = await api.settings.fetch();
if (res.success) {
return res.data;
}
return null;
};
export const getAllTags = async () => { export const getAllTags = async () => {
const results = await api.tags const results = await api.tags
.browse() .browse()

View File

@ -1,7 +1,7 @@
import config from 'virtual:starlight-ghostcms/config' import config from 'virtual:starlight-ghostcms/config'
export function isBlogRoot(slug: string) { export function isBlogRoot(slug: string) {
return slug === "blog"; return slug === `${config.route}`;
} }
export function isAnyBlogPostPage(slug: string) { export function isAnyBlogPostPage(slug: string) {
@ -15,7 +15,7 @@ export function isBlogPostPage(slug: string, postSlug: string) {
} }
export function isBlogTagsPage(slug: string, tag: string) { export function isBlogTagsPage(slug: string, tag: string) {
return slug === `blog/tags/${tag}`; return slug === `${config.route}/tags/${tag}`;
} }
export function getPageProps(title: string): StarlightPageProps { export function getPageProps(title: string): StarlightPageProps {

View File

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

View File

@ -1,18 +1,21 @@
import ghostcms from "@matthiesenxyz/astro-ghostcms"; import ghostcms from "@matthiesenxyz/astro-ghostcms";
import { defineConfig } from "astro/config"; import { defineConfig } from "astro/config";
//import tailwind from "@astrojs/tailwind"; // import tailwind from "@astrojs/tailwind";
import UnoCSS from "unocss/astro"; // import UnoCSS from "unocss/astro";
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
site: "https://demo.astro-ghostcms.xyz/", site: "https://demo.astro-ghostcms.xyz/",
integrations: [ integrations: [
//tailwind(), //tailwind(),
UnoCSS({ injectReset: true }), // UnoCSS({ injectReset: true }),
ghostcms({ ghostcms({
ghostURL: 'https://ghostdemo.matthiesen.xyz', ghostURL: 'https://ghostdemo.matthiesen.xyz',
ThemeProvider: { ThemeProvider: {
theme: "@matthiesenxyz/astro-ghostcms-brutalbyelian", theme: "@matthiesenxyz/astro-ghostcms-theme-default",
astroRemote: {
enable: true,
},
}, },
verbose: true, verbose: true,
}), }),

View File

@ -11,17 +11,18 @@
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"astro": "^4.4.13", "astro": "^4.5.6",
"@matthiesenxyz/astro-ghostcms": "workspace:*", "@matthiesenxyz/astro-ghostcms": "workspace:*",
"@matthiesenxyz/astro-ghostcms-theme-default": "workspace:*", "@matthiesenxyz/astro-ghostcms-theme-default": "workspace:*",
"@matthiesenxyz/astro-ghostcms-catppuccin": "workspace:*",
"@matthiesenxyz/astro-ghostcms-brutalbyelian": "workspace:*", "@matthiesenxyz/astro-ghostcms-brutalbyelian": "workspace:*",
"@astrojs/tailwind": "^5.1.0", "@astrojs/tailwind": "^5.1.0",
"@unocss/astro": "^0.58.5", "@unocss/astro": "^0.58.6",
"tailwindcss": "^3.3.5" "tailwindcss": "^3.3.5"
}, },
"devDependencies": { "devDependencies": {
"@unocss/reset": "^0.58.5", "@unocss/reset": "^0.58.6",
"typescript": "^5.4.2", "typescript": "^5.4.2",
"unocss": "^0.58.5" "unocss": "^0.58.6"
} }
} }

View File

@ -10,6 +10,7 @@ export default defineConfig({
title: "My Docs", title: "My Docs",
plugins: [ plugins: [
starlightGhostCMS({ starlightGhostCMS({
ghostURL: "https://ghostdemo.matthiesen.xyz",
title: "Demo Blog", title: "Demo Blog",
rssDescription: "Starlight Playground", rssDescription: "Starlight Playground",
route: "blog", route: "blog",

View File

@ -11,11 +11,14 @@
"preview": "astro preview", "preview": "astro preview",
"astro": "astro" "astro": "astro"
}, },
"devDependencies": {}, "devDependencies": {
"@types/node": "^20.11.28"
},
"dependencies": { "dependencies": {
"@astrojs/starlight": "^0.21.1", "@astrojs/starlight": "^0.21.1",
"@matthiesenxyz/starlight-ghostcms": "workspace:*", "@matthiesenxyz/starlight-ghostcms": "workspace:*",
"astro": "^4.4.13", "@matthiesenxyz/astro-gists": "^0.2.11",
"astro": "^4.5.6",
"sharp": "^0.33.2" "sharp": "^0.33.2"
} }
} }

File diff suppressed because it is too large Load Diff