fix: 🐛 Tag slug page returns 404 in development environment (#101)

Co-authored-by: create-issue-branch[bot] <53036503+create-issue-branch[bot]@users.noreply.github.com>
Co-authored-by: Jungley <yejing@live.cn>
Co-authored-by: Adam Matthiesen <amatthiesen@outlook.com>
This commit is contained in:
create-issue-branch[bot] 2024-03-09 21:02:03 -08:00 committed by GitHub
parent 10bcac444b
commit 4c1002a733
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 44 additions and 31 deletions

View File

@ -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

View File

@ -8,7 +8,7 @@ import { getAllPosts, getAllTags, getSettings, invariant } from "@matthiesenxyz/
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {

View File

@ -2,7 +2,7 @@
import Layout from '../layouts/Default.astro'; import Layout from '../layouts/Default.astro';
import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api"; import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcms/api";
import TagSummaryCard from '../components/generic/TagSummaryCard.astro'; import TagSummaryCard from '../components/generic/TagSummaryCard.astro';
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, 'Settings not found'); invariant(settings, 'Settings not found');
const title = settings.title; const title = settings.title;
@ -16,7 +16,7 @@ const description = settings.description;
description={description} description={description}
> >
<main class='bg-pink p-6'> <main class='bg-pink p-6'>
{ {
tags tags
.filter((tag) => tag.slug && !tag.slug.startsWith("hash-")) .filter((tag) => tag.slug && !tag.slug.startsWith("hash-"))
.map((tag) => ( .map((tag) => (

View File

@ -7,7 +7,7 @@ import PostPreview from '../../components/PostPreview.astro';
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {
@ -37,7 +37,7 @@ const description = `All of the articles we've posted and linked so far under th
<Layout title={title} description={description} settings={settings}> <Layout title={title} description={description} settings={settings}>
<Container> <Container>
<section class="post-card post-card-large"> <section class="post-card post-card-large">
<div class="post-card-content"> <div class="post-card-content">
<div class="post-card-content-link"> <div class="post-card-content-link">
<header class="post-card-header"> <header class="post-card-header">

View File

@ -6,7 +6,7 @@ import { getAllTags, getSettings, invariant } from "@matthiesenxyz/astro-ghostcm
let title = "All Tags"; let title = "All Tags";
let description = "All the tags used so far..."; let description = "All the tags used so far...";
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, 'Settings not found'); invariant(settings, 'Settings not found');

View File

@ -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 { 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"; import { getGhostImgPath } from "../../utils";
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {

View File

@ -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 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 title = "All Tags";
let description = "All the tags used so far..."; let description = "All the tags used so far...";
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, "Settings not found"); invariant(settings, "Settings not found");
--- ---

View File

@ -1,5 +1,5 @@
import { TSGhostContentAPI } from "@ts-ghost/content-api"; 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 // LOAD ENVIRONMENT VARIABLES
import { loadEnv } from "vite"; import { loadEnv } from "vite";
@ -94,17 +94,20 @@ export const getSettings = async () => {
}; };
export const getAllTags = async () => { export const getAllTags = async () => {
const results = await api.tags const tags: Tag[] = [];
.browse() let cursor = await api.tags
.browse({
limit: 'all'
})
.include({ "count.posts": true }) .include({ "count.posts": true })
.fetch(); .paginate();
if (!results.success) {
throw new Error(results.errors.map((e) => e.message).join(", ")); 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 { return tags;
tags: results.data,
meta: results.meta,
};
}; };
export const getFeaturedPosts = async () => { export const getFeaturedPosts = async () => {

View File

@ -16,7 +16,7 @@ import satoriOG from "../../satori";
export const getStaticPaths: GetStaticPaths = async () => { export const getStaticPaths: GetStaticPaths = async () => {
const result: GetStaticPathsItem[] = []; const result: GetStaticPathsItem[] = [];
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, "Settings are required"); invariant(settings, "Settings are required");

View File

@ -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 { 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"; import { getGhostImgPath } from "../../utils";
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await getAllPosts(); const posts = await getAllPosts();
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
return tags.map((tag) => { return tags.map((tag) => {

View File

@ -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 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 title = "All Tags";
let description = "All the tags used so far..."; let description = "All the tags used so far...";
const { tags } = await getAllTags(); const tags = await getAllTags();
const settings = await getSettings(); const settings = await getSettings();
invariant(settings, "Settings not found"); invariant(settings, "Settings not found");
--- ---