From 4c1002a733d25d6a9e80cbdb0883a437ae98ca48 Mon Sep 17 00:00:00 2001 From: "create-issue-branch[bot]" <53036503+create-issue-branch[bot]@users.noreply.github.com> Date: Sat, 9 Mar 2024 21:02:03 -0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Tag=20slug=20page=20retur?= =?UTF-8?q?ns=20404=20in=20development=20environment=20(#101)?= 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: Jungley Co-authored-by: Adam Matthiesen --- .changeset/young-ties-attack.md | 10 ++++++++ .../src/routes/tag/[slug].astro | 2 +- .../src/routes/tags.astro | 4 ++-- .../src/routes/tag/[slug].astro | 4 ++-- .../src/routes/tags.astro | 2 +- .../src/routes/tag/[slug].astro | 8 +++---- .../src/routes/tags.astro | 6 ++--- packages/astro-ghostcms/src/api/ghostAPI.ts | 23 +++++++++++-------- .../satoriog/routes/tag/[slug].png.ts | 2 +- .../starterkit/src/pages/tag/[slug].astro | 8 +++---- .../templates/starterkit/src/pages/tags.astro | 6 ++--- 11 files changed, 44 insertions(+), 31 deletions(-) create mode 100644 .changeset/young-ties-attack.md diff --git a/.changeset/young-ties-attack.md b/.changeset/young-ties-attack.md new file mode 100644 index 00000000..59f086a4 --- /dev/null +++ b/.changeset/young-ties-attack.md @@ -0,0 +1,10 @@ +--- +"@matthiesenxyz/astro-ghostcms-brutalbyelian": patch +"@matthiesenxyz/astro-ghostcms-theme-default": patch +"@matthiesenxyz/astro-ghostcms-catppuccin": patch +"@matthiesenxyz/create-astro-ghostcms": patch +"@matthiesenxyz/starlight-ghostcms": patch +"@matthiesenxyz/astro-ghostcms": patch +--- + +fix getAllTags bug for themes and bump other packages deps diff --git a/packages/astro-ghostcms-brutalbyelian/src/routes/tag/[slug].astro b/packages/astro-ghostcms-brutalbyelian/src/routes/tag/[slug].astro index 2c00dba0..5494e4c7 100644 --- a/packages/astro-ghostcms-brutalbyelian/src/routes/tag/[slug].astro +++ b/packages/astro-ghostcms-brutalbyelian/src/routes/tag/[slug].astro @@ -8,7 +8,7 @@ import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/ export async function getStaticPaths() { const posts = await getAllPosts(); - const { tags } = await getAllTags(); + const tags = await getAllTags(); const settings = await getSettings(); return tags.map((tag) => { diff --git a/packages/astro-ghostcms-brutalbyelian/src/routes/tags.astro b/packages/astro-ghostcms-brutalbyelian/src/routes/tags.astro index c8669a37..72639286 100644 --- a/packages/astro-ghostcms-brutalbyelian/src/routes/tags.astro +++ b/packages/astro-ghostcms-brutalbyelian/src/routes/tags.astro @@ -2,7 +2,7 @@ import Layout from '../layouts/Default.astro'; import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import TagSummaryCard from '../components/generic/TagSummaryCard.astro'; -const { tags } = await getAllTags(); +const tags = await getAllTags(); const settings = await getSettings(); invariant(settings, 'Settings not found'); const title = settings.title; @@ -16,7 +16,7 @@ const description = settings.description; description={description} >
- { + { tags .filter((tag) => tag.slug && !tag.slug.startsWith("hash-")) .map((tag) => ( diff --git a/packages/astro-ghostcms-catppuccin/src/routes/tag/[slug].astro b/packages/astro-ghostcms-catppuccin/src/routes/tag/[slug].astro index 41538b83..1c52cad7 100644 --- a/packages/astro-ghostcms-catppuccin/src/routes/tag/[slug].astro +++ b/packages/astro-ghostcms-catppuccin/src/routes/tag/[slug].astro @@ -7,7 +7,7 @@ import PostPreview from '../../components/PostPreview.astro'; export async function getStaticPaths() { const posts = await getAllPosts(); - const { tags } = await getAllTags(); + const tags = await getAllTags(); const settings = await getSettings(); return tags.map((tag) => { @@ -37,7 +37,7 @@ const description = `All of the articles we've posted and linked so far under th
- +
diff --git a/packages/astro-ghostcms-catppuccin/src/routes/tags.astro b/packages/astro-ghostcms-catppuccin/src/routes/tags.astro index cc5c6e11..83a6e624 100644 --- a/packages/astro-ghostcms-catppuccin/src/routes/tags.astro +++ b/packages/astro-ghostcms-catppuccin/src/routes/tags.astro @@ -6,7 +6,7 @@ import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcm let title = "All Tags"; let description = "All the tags used so far..."; -const { tags } = await getAllTags(); +const tags = await getAllTags(); const settings = await getSettings(); invariant(settings, 'Settings not found'); diff --git a/packages/astro-ghostcms-theme-default/src/routes/tag/[slug].astro b/packages/astro-ghostcms-theme-default/src/routes/tag/[slug].astro index 4a52c26b..bc86d24e 100644 --- a/packages/astro-ghostcms-theme-default/src/routes/tag/[slug].astro +++ b/packages/astro-ghostcms-theme-default/src/routes/tag/[slug].astro @@ -1,13 +1,13 @@ --- -import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro'; -import DefaultPageLayout from "../../layouts/default.astro"; -import PostPreview from "../../components/PostPreview.astro"; import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; +import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro'; +import PostPreview from "../../components/PostPreview.astro"; +import DefaultPageLayout from "../../layouts/default.astro"; import { getGhostImgPath } from "../../utils"; export async function getStaticPaths() { const posts = await getAllPosts(); - const { tags } = await getAllTags(); + const tags = await getAllTags(); const settings = await getSettings(); return tags.map((tag) => { diff --git a/packages/astro-ghostcms-theme-default/src/routes/tags.astro b/packages/astro-ghostcms-theme-default/src/routes/tags.astro index 2d62fdba..becca4d9 100644 --- a/packages/astro-ghostcms-theme-default/src/routes/tags.astro +++ b/packages/astro-ghostcms-theme-default/src/routes/tags.astro @@ -1,13 +1,13 @@ --- -import DefaultPageLayout from "../layouts/default.astro"; +import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import TagCard from "../components/TagCard.astro"; -import { getSettings, getAllTags, invariant } from "@matthiesenxyz/astro-ghostcms/api"; +import DefaultPageLayout from "../layouts/default.astro"; let title = "All Tags"; let description = "All the tags used so far..."; -const { tags } = await getAllTags(); +const tags = await getAllTags(); const settings = await getSettings(); invariant(settings, "Settings not found"); --- diff --git a/packages/astro-ghostcms/src/api/ghostAPI.ts b/packages/astro-ghostcms/src/api/ghostAPI.ts index ce46cecc..9fdfc472 100644 --- a/packages/astro-ghostcms/src/api/ghostAPI.ts +++ b/packages/astro-ghostcms/src/api/ghostAPI.ts @@ -1,5 +1,5 @@ import { TSGhostContentAPI } from "@ts-ghost/content-api"; -import type { Page, Post } from "../schemas/api"; +import type { Page, Post, Tag } from "../schemas/api"; // LOAD ENVIRONMENT VARIABLES import { loadEnv } from "vite"; @@ -94,17 +94,20 @@ export const getSettings = async () => { }; export const getAllTags = async () => { - const results = await api.tags - .browse() + const tags: Tag[] = []; + let cursor = await api.tags + .browse({ + limit: 'all' + }) .include({ "count.posts": true }) - .fetch(); - if (!results.success) { - throw new Error(results.errors.map((e) => e.message).join(", ")); + .paginate(); + + if (cursor.current.success) tags.push(...cursor.current.data); + while (cursor.next) { + cursor = await cursor.next.paginate(); + if (cursor.current.success) tags.push(...cursor.current.data); } - return { - tags: results.data, - meta: results.meta, - }; + return tags; }; export const getFeaturedPosts = async () => { diff --git a/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts b/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts index 9076f235..7dc7ee55 100644 --- a/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts +++ b/packages/astro-ghostcms/src/integrations/satoriog/routes/tag/[slug].png.ts @@ -16,7 +16,7 @@ import satoriOG from "../../satori"; export const getStaticPaths: GetStaticPaths = async () => { const result: GetStaticPathsItem[] = []; const posts = await getAllPosts(); - const { tags } = await getAllTags(); + const tags = await getAllTags(); const settings = await getSettings(); invariant(settings, "Settings are required"); diff --git a/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tag/[slug].astro b/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tag/[slug].astro index 4a52c26b..bc86d24e 100644 --- a/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tag/[slug].astro +++ b/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tag/[slug].astro @@ -1,13 +1,13 @@ --- -import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro'; -import DefaultPageLayout from "../../layouts/default.astro"; -import PostPreview from "../../components/PostPreview.astro"; import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; +import type { InferGetStaticParamsType, InferGetStaticPropsType } from 'astro'; +import PostPreview from "../../components/PostPreview.astro"; +import DefaultPageLayout from "../../layouts/default.astro"; import { getGhostImgPath } from "../../utils"; export async function getStaticPaths() { const posts = await getAllPosts(); - const { tags } = await getAllTags(); + const tags = await getAllTags(); const settings = await getSettings(); return tags.map((tag) => { diff --git a/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tags.astro b/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tags.astro index 2d62fdba..becca4d9 100644 --- a/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tags.astro +++ b/packages/create-astro-ghostcms/src/templates/starterkit/src/pages/tags.astro @@ -1,13 +1,13 @@ --- -import DefaultPageLayout from "../layouts/default.astro"; +import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import TagCard from "../components/TagCard.astro"; -import { getSettings, getAllTags, invariant } from "@matthiesenxyz/astro-ghostcms/api"; +import DefaultPageLayout from "../layouts/default.astro"; let title = "All Tags"; let description = "All the tags used so far..."; -const { tags } = await getAllTags(); +const tags = await getAllTags(); const settings = await getSettings(); invariant(settings, "Settings not found"); ---