From 6464de28f88b418ce81c05fd10e6f365afd0ffef Mon Sep 17 00:00:00 2001 From: "create-issue-branch[bot]" <53036503+create-issue-branch[bot]@users.noreply.github.com> Date: Sat, 16 Mar 2024 11:05:57 -0700 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20need=20new=20fallback=20f?= =?UTF-8?q?or=20ogImage=20(#25)?= 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/spotty-lizards-hope.md | 5 +++++ package/src/hn-gql/client.ts | 3 +++ package/src/hn-gql/schema.ts | 3 +++ package/src/layouts/Layout.astro | 2 +- 4 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/spotty-lizards-hope.md diff --git a/.changeset/spotty-lizards-hope.md b/.changeset/spotty-lizards-hope.md new file mode 100644 index 0000000..38c72fa --- /dev/null +++ b/.changeset/spotty-lizards-hope.md @@ -0,0 +1,5 @@ +--- +"@matthiesenxyz/astro-hashnode": patch +--- + +[fix] add extra fallback option for ogImage diff --git a/package/src/hn-gql/client.ts b/package/src/hn-gql/client.ts index d7ba74a..ce8c35c 100644 --- a/package/src/hn-gql/client.ts +++ b/package/src/hn-gql/client.ts @@ -129,6 +129,9 @@ export const getPublication = async () => { displayTitle descriptionSEO favicon + author { + profilePicture + } preferences { logo disableFooterBranding diff --git a/package/src/hn-gql/schema.ts b/package/src/hn-gql/schema.ts index 5974dcd..5d83a88 100644 --- a/package/src/hn-gql/schema.ts +++ b/package/src/hn-gql/schema.ts @@ -60,6 +60,9 @@ export const PublicationDataSchema = z.object({ displayTitle: z.string(), descriptionSEO: z.string(), favicon: z.string(), + author: z.object({ + profilePicture: z.string(), + }), preferences: z.object({ logo: z.string(), disableFooterBranding: z.boolean(), diff --git a/package/src/layouts/Layout.astro b/package/src/layouts/Layout.astro index dd00a18..d41e43c 100644 --- a/package/src/layouts/Layout.astro +++ b/package/src/layouts/Layout.astro @@ -41,7 +41,7 @@ const { pageTitle, hideFooter, hideHeader, ogImage } = Astro.props as AstroHashn basic: { title: pageTitle ? pageTitle + " | " + pubHeader : pubHeader, type: 'text', - image: ogImage || pubData.favicon, + image: ogImage || pubData.favicon || pubData.author.profilePicture, }, optional: { description: pubData.descriptionSEO,