Skip to content

Commit

Permalink
fix: 🐛 Custom Code Component Swap is causing issues. (#112)
Browse files Browse the repository at this point in the history
Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Adam Matthiesen <[email protected]>
  • Loading branch information
create-issue-branch[bot] and Adammatthiesen authored Mar 13, 2024
1 parent 8074b66 commit b0218e1
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 108 deletions.
11 changes: 11 additions & 0 deletions .changeset/spicy-stingrays-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@matthiesenxyz/astro-ghostcms-brutalbyelian": patch
"@matthiesenxyz/astro-ghostcms-theme-default": patch
"@matthiesenxyz/astro-ghostcms-catppuccin": patch
"@matthiesenxyz/starlight-ghostcms": patch
---

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.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ 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";
export { default as astrocard } from "./astrocard.astro";
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ invariant(settings, "Settings are required");
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={{
h1: C.H1,
Expand All @@ -42,7 +43,6 @@ invariant(settings, "Settings are required");
h4: C.H4,
h5: C.H5,
h6: C.H6,
pre: C.CodeSlot,
p: C.Paragraph,
astrocard: C.astrocard,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import FeatureImage from "./FeatureImage.astro";
import AuthorList from "./AuthorList.astro";
import { formatDate } from "../utils";
import { Markup } from 'astro-remote';
import * as render from '../components/astro-remote';
export type Props = {
posts: Post[];
Expand Down Expand Up @@ -66,10 +65,7 @@ const latestFeatured = posts[0]
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', 'getgist', 'getgistgroup', 'astrocard'],
}}
components={{
pre: render.CodeSlot
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'],
}}
/> }
</section>
Expand Down
5 changes: 1 addition & 4 deletions packages/astro-ghostcms-catppuccin/src/components/Post.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import PostHero from "../components/PostHero.astro";
import PostFooter from "../components/PostFooter.astro";
import { getFeaturedPosts, invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api";
import { Markup } from 'astro-remote';
import * as render from '../components/astro-remote';
export type Props = {
post: Post;
Expand Down Expand Up @@ -34,9 +33,7 @@ invariant(settings, "Settings not found");
content={post.html}
sanitize={{
allowComponents: true,
}}
components={{
pre: render.CodeSlot
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'],
}}
/>
</div>
Expand Down

This file was deleted.

This file was deleted.

15 changes: 7 additions & 8 deletions packages/astro-ghostcms-theme-default/src/components/Page.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import FeatureImage from "../components/FeatureImage.astro";
import type { Settings, Page } from "@matthiesenxyz/astro-ghostcms/api";
import { Markup } from 'astro-remote';
import * as render from '../components/astro-remote';
export type Props = {
page: Page;
settings: Settings;
Expand All @@ -27,13 +27,12 @@ const { page, settings, pageClass } = Astro.props as Props;
<section class="gh-content gh-canvas">
<h1 class="article-title">{page.title}</h1>
<Markup
content={page.html}
sanitize={{
allowComponents: true,
}}
components={{
pre: render.CodeSlot
}} />
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'],
}}
/>
</section>
</article>
</main>
Expand Down
15 changes: 7 additions & 8 deletions packages/astro-ghostcms-theme-default/src/components/Post.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PostHero from "../components/PostHero.astro";
import PostFooter from "../components/PostFooter.astro";
import {invariant, type Post, type Settings } from "@matthiesenxyz/astro-ghostcms/api";
import { Markup } from 'astro-remote';
import * as render from '../components/astro-remote';
export type Props = {
post: Post;
settings: Settings;
Expand All @@ -19,13 +19,12 @@ invariant(settings, "Settings not found");
<PostHero post={post} settings={settings} />
<section class="gh-content gh-canvas">
<Markup
content={post.html}
sanitize={{
allowComponents: true,
}}
components={{
pre: render.CodeSlot
}} />
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'],
}}
/>
</section>
</article>
<PostFooter post={post} settings={settings} posts={posts} />
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions packages/starlight-ghostcms/src/routes/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getPageProps } from '../utils/page';
import { getAllPosts } from '../utils/api';
import Metadata from '../components/Metadata.astro';
import { Markup } from 'astro-remote';
import * as render from '../components/astro-remote';
import * as Gists from '@matthiesenxyz/astro-gists/components';
export async function getStaticPaths() {
Expand Down Expand Up @@ -51,7 +50,6 @@ const pageProps = getPageProps(post.title)
allowComponents: true,
}}
components={{
pre: render.CodeSlot,
getgist: Gists.GetGist,
getgistgroup: Gists.GetGistGroup,
}}
Expand Down
5 changes: 1 addition & 4 deletions packages/starlight-ghostcms/src/routes/about.astro
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Page from '../components/Page.astro'
import { getPageProps } from '../utils/page'
import { getSluggedPage } from '../utils/api'
import { Markup } from 'astro-remote'
import * as render from '../components/astro-remote';
const aboutPage = await getSluggedPage("about");
Expand All @@ -26,9 +25,7 @@ const pageProps = getPageProps(aboutPage ? aboutPage.post.title : "")
sanitize={{
allowComponents: true,
}}
components={{
pre: render.CodeSlot
}} />
/>
}
<footer class="not-content">
<!--PrevNextLinks next={nextLink} prev={prevLink} /-->
Expand Down
8 changes: 4 additions & 4 deletions playgrounds/astro-playground/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import ghostcms from "@matthiesenxyz/astro-ghostcms";
import { defineConfig } from "astro/config";
///import tailwind from "@astrojs/tailwind";
import tailwind from "@astrojs/tailwind";
//import UnoCSS from "unocss/astro";

// https://astro.build/config
export default defineConfig({
site: "https://demo.astro-ghostcms.xyz/",
integrations: [
//tailwind(),
//UnoCSS({ injectReset: true }),
tailwind(),
// UnoCSS({ injectReset: true }),
ghostcms({
ghostURL: 'https://ghostdemo.matthiesen.xyz',
ThemeProvider: {
theme: "@matthiesenxyz/astro-ghostcms-theme-default",
theme: "@matthiesenxyz/astro-ghostcms-catppuccin",
},
verbose: true,
}),
Expand Down

0 comments on commit b0218e1

Please sign in to comment.