Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 🐛 bug: starlight-ghostcms markup allowElements list breaks astro-gists #92

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/wicked-months-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@matthiesenxyz/astro-ghostcms-brutalbyelian": patch
"@matthiesenxyz/astro-ghostcms-theme-default": patch
"@matthiesenxyz/astro-ghostcms-catppuccin": patch
"@matthiesenxyz/starlight-ghostcms": patch
---

Fix html rendering to allow custom components
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ invariant(settings, "Settings are required");
<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'],
allowComponents: true,
}}
components={{
h1: C.H1,
Expand Down
3 changes: 1 addition & 2 deletions packages/astro-ghostcms-catppuccin/src/components/Post.astro
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ invariant(settings, "Settings not found");
<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', 'getgist', 'getgistgroup', 'astrocard'],
allowComponents: true,
}}
components={{
pre: render.CodeSlot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const { page, settings, pageClass } = Astro.props as Props;
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', 'getgist', 'getgistgroup', 'astrocard'],
}}
components={{
pre: render.CodeSlot
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ invariant(settings, "Settings not found");
<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', 'getgist', 'getgistgroup', 'astrocard'],
allowComponents: true,
}}
components={{
pre: render.CodeSlot
Expand Down
3 changes: 1 addition & 2 deletions packages/starlight-ghostcms/src/routes/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ const pageProps = getPageProps(post.title)
<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', 'getgist', 'getgistgroup', 'astrocard'],
allowComponents: true,
}}
components={{
pre: render.CodeSlot,
Expand Down
5 changes: 3 additions & 2 deletions packages/starlight-ghostcms/src/routes/about.astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,24 @@ const aboutPage = await getSluggedPage("about");

//const { entries, nextLink, prevLink } = Astro.props

const pageProps = getPageProps(aboutPage?.post?.title)
const pageProps = getPageProps(aboutPage ? aboutPage.post.title : "")
---

<Page {...pageProps}>
{config.supportGhost && (
<div id="pghost">Powered by <a href="https://ghost.org">Ghost</a></div>
)}
{aboutPage &&
<Metadata entry={aboutPage.post} />
<Markup
content={aboutPage.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'],
}}
components={{
pre: render.CodeSlot
}} />
}
<footer class="not-content">
<!--PrevNextLinks next={nextLink} prev={prevLink} /-->
</footer>
Expand Down