From f097c6a18b24b13e94fa90c97985281af1f2ea99 Mon Sep 17 00:00:00 2001 From: "create-issue-branch[bot]" <53036503+create-issue-branch[bot]@users.noreply.github.com> Date: Tue, 12 Mar 2024 23:22:39 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20bug:=20ultrahtml=20does?= =?UTF-8?q?=20not=20handle=20all=20html=20strings.=20=20add=20switch=20to?= =?UTF-8?q?=20enable=20standard=20html=20fragment=20tag=20instead.=20(#115?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com> Co-authored-by: Adam Matthiesen --- .changeset/mean-drinks-heal.md | 8 ++++++ .../src/components/blog/FeatureImage.astro | 9 ++++++- .../src/routes/[slug].astro | 7 +++-- .../src/components/FeaturedPost.astro | 19 ++++++++----- .../src/components/Post.astro | 27 +++++++++++-------- .../src/components/Page.astro | 19 ++++++++----- .../src/components/Post.astro | 19 ++++++++----- packages/astro-ghostcms/README.md | 3 +++ .../astro-ghostcms/src/schemas/userconfig.ts | 17 +++++------- playgrounds/astro-playground/astro.config.mjs | 11 +++++--- 10 files changed, 90 insertions(+), 49 deletions(-) create mode 100644 .changeset/mean-drinks-heal.md diff --git a/.changeset/mean-drinks-heal.md b/.changeset/mean-drinks-heal.md new file mode 100644 index 00000000..365d9ac1 --- /dev/null +++ b/.changeset/mean-drinks-heal.md @@ -0,0 +1,8 @@ +--- +"@matthiesenxyz/astro-ghostcms-brutalbyelian": patch +"@matthiesenxyz/astro-ghostcms-theme-default": patch +"@matthiesenxyz/astro-ghostcms-catppuccin": patch +"@matthiesenxyz/astro-ghostcms": patch +--- + +Adds a toggleswitch to allow users to disable astro-remote usage for rendering ghost-content diff --git a/packages/astro-ghostcms-brutalbyelian/src/components/blog/FeatureImage.astro b/packages/astro-ghostcms-brutalbyelian/src/components/blog/FeatureImage.astro index 7639c489..947b56e6 100644 --- a/packages/astro-ghostcms-brutalbyelian/src/components/blog/FeatureImage.astro +++ b/packages/astro-ghostcms-brutalbyelian/src/components/blog/FeatureImage.astro @@ -2,6 +2,10 @@ import { getGhostImgPath } from "../../utils"; 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 = { image: string; alt?: string; @@ -23,5 +27,8 @@ const { image, alt, caption = "", settings, transitionName } = Astro.props as Pr alt={alt} transition:name={transitionName} /> - {caption &&
} + {caption && ( +
+ {useRemote ? : } +
)} diff --git a/packages/astro-ghostcms-brutalbyelian/src/routes/[slug].astro b/packages/astro-ghostcms-brutalbyelian/src/routes/[slug].astro index 99546cef..0cbb2bbd 100644 --- a/packages/astro-ghostcms-brutalbyelian/src/routes/[slug].astro +++ b/packages/astro-ghostcms-brutalbyelian/src/routes/[slug].astro @@ -7,6 +7,9 @@ import BlogPostHeader from "../components/blog/BlogPostHeader.astro"; import { Markup } from 'astro-remote'; import * as C from "../components/ghostrender"; import { Card } from "@eliancodes/brutal-ui"; +import config from "virtual:@matthiesenxyz/astro-ghostcms/config"; + +const useRemote = config.ThemeProvider.astroRemote.enable; export async function getStaticPaths() { const [posts, pages, settings] = await Promise.all([getAllPosts(), await getAllPages(), await getSettings()]); @@ -30,7 +33,7 @@ invariant(settings, "Settings are required");
- + /> : }
diff --git a/packages/astro-ghostcms-catppuccin/src/components/FeaturedPost.astro b/packages/astro-ghostcms-catppuccin/src/components/FeaturedPost.astro index 9d505cfb..47d9b2ff 100644 --- a/packages/astro-ghostcms-catppuccin/src/components/FeaturedPost.astro +++ b/packages/astro-ghostcms-catppuccin/src/components/FeaturedPost.astro @@ -4,6 +4,9 @@ import FeatureImage from "./FeatureImage.astro"; import AuthorList from "./AuthorList.astro"; 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 = { posts: Post[]; @@ -61,13 +64,15 @@ const latestFeatured = posts[0]
- {latestFeatured && } + + + {useRemote ? (latestFeatured && ) : (latestFeatured && ) }
diff --git a/packages/astro-ghostcms-catppuccin/src/components/Post.astro b/packages/astro-ghostcms-catppuccin/src/components/Post.astro index 3f268b18..5faf79a4 100644 --- a/packages/astro-ghostcms-catppuccin/src/components/Post.astro +++ b/packages/astro-ghostcms-catppuccin/src/components/Post.astro @@ -3,6 +3,9 @@ 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 config from "virtual:@matthiesenxyz/astro-ghostcms/config"; + +const useRemote = config.ThemeProvider.astroRemote.enable; export type Props = { post: Post; @@ -16,10 +19,10 @@ async function getPostsSet(){ const featuredPosts = await getFeaturedPosts(); const fposts = posts; if(featuredPosts.posts.length === 0){ return fposts } - else { - const featured = featuredPosts.posts[0] - return fposts.filter((p: Post)=>p.id !== featured.id) - } + + const featured = featuredPosts.posts[0] + return fposts.filter((p: Post)=>p.id !== featured.id) + } const mPosts = await getPostsSet() @@ -29,13 +32,15 @@ invariant(settings, "Settings not found");
- + {useRemote ? ( + + ) : }
diff --git a/packages/astro-ghostcms-theme-default/src/components/Page.astro b/packages/astro-ghostcms-theme-default/src/components/Page.astro index 97e169e5..60db725b 100644 --- a/packages/astro-ghostcms-theme-default/src/components/Page.astro +++ b/packages/astro-ghostcms-theme-default/src/components/Page.astro @@ -2,6 +2,9 @@ import FeatureImage from "../components/FeatureImage.astro"; 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 = { page: Page; @@ -26,13 +29,15 @@ const { page, settings, pageClass } = Astro.props as Props;

{page.title}

- + {useRemote ? ( + + ) : }
diff --git a/packages/astro-ghostcms-theme-default/src/components/Post.astro b/packages/astro-ghostcms-theme-default/src/components/Post.astro index ddaa51f7..0eea7644 100644 --- a/packages/astro-ghostcms-theme-default/src/components/Post.astro +++ b/packages/astro-ghostcms-theme-default/src/components/Post.astro @@ -3,6 +3,9 @@ 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 config from "virtual:@matthiesenxyz/astro-ghostcms/config"; + +const useRemote = config.ThemeProvider.astroRemote.enable; export type Props = { post: Post; @@ -18,13 +21,15 @@ invariant(settings, "Settings not found");
- + {useRemote ? ( + + ) : }
diff --git a/packages/astro-ghostcms/README.md b/packages/astro-ghostcms/README.md index cba98a86..519a4ae9 100644 --- a/packages/astro-ghostcms/README.md +++ b/packages/astro-ghostcms/README.md @@ -66,6 +66,9 @@ export default defineConfig({ ThemeProvider: { // Allows you to pass config options to our ThemeProvider if enabled. disableThemeProvider: false, // OPTIONAL - Default False theme: "@matthiesenxyz/astro-ghostcms-theme-default", // OPTIONAL - Default Theme shown. + astroRemote: { + enable: true // OPTIONAL - Default True, Allows the user to switch to standard 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`. enableRSSFeed: true, // Allows the user to Enable or disable RSS Feed Generation. Default: true diff --git a/packages/astro-ghostcms/src/schemas/userconfig.ts b/packages/astro-ghostcms/src/schemas/userconfig.ts index 10ad2a75..6455a712 100644 --- a/packages/astro-ghostcms/src/schemas/userconfig.ts +++ b/packages/astro-ghostcms/src/schemas/userconfig.ts @@ -17,22 +17,19 @@ export const GhostUserConfigSchema = z.object({ /** OPTIONAL - Configure the Theme Provider * @ This option allows the user to configure the Theme Provider */ - ThemeProvider: z - .object({ + ThemeProvider: z.object({ /** OPTIONAL - Disable the theme provider * @default false */ - disableThemeProvider: z.coerce.boolean(), + disableThemeProvider: z.coerce.boolean().default(false), /** OPTIONAL - Set the theme you want to use * @default "@matthiesenxyz/astro-ghostcms-theme-default" */ - theme: z.string(), - }) - .optional() - .default({ - disableThemeProvider: false, - theme: "@matthiesenxyz/astro-ghostcms-theme-default" - }), + theme: z.string().default("@matthiesenxyz/astro-ghostcms-theme-default"), + astroRemote: z.object({ + enable: z.boolean().default(true), + }).optional().default({}), + }).optional().default({}), /** Allows the user to disable the provided 404 page */ disableDefault404: z.coerce.boolean().optional(), /** Allows the user to disable the provided RSS Feed */ diff --git a/playgrounds/astro-playground/astro.config.mjs b/playgrounds/astro-playground/astro.config.mjs index 5370b9df..e7734a4f 100644 --- a/playgrounds/astro-playground/astro.config.mjs +++ b/playgrounds/astro-playground/astro.config.mjs @@ -1,18 +1,21 @@ import ghostcms from "@matthiesenxyz/astro-ghostcms"; import { defineConfig } from "astro/config"; -import tailwind from "@astrojs/tailwind"; -//import UnoCSS from "unocss/astro"; +// 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(), + //tailwind(), // UnoCSS({ injectReset: true }), ghostcms({ ghostURL: 'https://ghostdemo.matthiesen.xyz', ThemeProvider: { - theme: "@matthiesenxyz/astro-ghostcms-catppuccin", + theme: "@matthiesenxyz/astro-ghostcms-theme-default", + astroRemote: { + enable: true, + }, }, verbose: true, }),