Skip to content

Commit

Permalink
fix: šŸ› bug: starlight-ghostcms markup allowElements list breaks `asā€¦
Browse files Browse the repository at this point in the history
ā€¦tro-gists` (#92)

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
1 parent 110c5a9 commit 746fcc5
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 11 deletions.
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

0 comments on commit 746fcc5

Please sign in to comment.