diff --git a/blog-cloudflare/emdash-env.d.ts b/blog-cloudflare/emdash-env.d.ts index abb2626..e1a5a89 100644 --- a/blog-cloudflare/emdash-env.d.ts +++ b/blog-cloudflare/emdash-env.d.ts @@ -3,7 +3,7 @@ /// -import type { ContentBylineCredit, PortableTextBlock } from "emdash"; +import type { ContentBylineCredit, TaxonomyTerm, PortableTextBlock } from "emdash"; export interface Page { id: string; @@ -15,6 +15,7 @@ export interface Page { updatedAt: Date; publishedAt: Date | null; bylines?: ContentBylineCredit[]; + terms?: Record; } export interface Post { @@ -29,6 +30,7 @@ export interface Post { updatedAt: Date; publishedAt: Date | null; bylines?: ContentBylineCredit[]; + terms?: Record; } declare module "emdash" { diff --git a/blog-cloudflare/package.json b/blog-cloudflare/package.json index 2dffcd9..eb4fa42 100644 --- a/blog-cloudflare/package.json +++ b/blog-cloudflare/package.json @@ -16,11 +16,11 @@ "dependencies": { "@astrojs/cloudflare": "^13.5.3", "@astrojs/react": "^5.0.0", - "@emdash-cms/cloudflare": "^0.16.1", + "@emdash-cms/cloudflare": "^0.18.0", "@emdash-cms/plugin-forms": "^0.2.3", "@emdash-cms/plugin-webhook-notifier": "^0.2.0", "astro": "^6.3.0", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/blog-cloudflare/src/pages/posts/[slug].astro b/blog-cloudflare/src/pages/posts/[slug].astro index f30d385..0cc892f 100644 --- a/blog-cloudflare/src/pages/posts/[slug].astro +++ b/blog-cloudflare/src/pages/posts/[slug].astro @@ -2,7 +2,6 @@ import { getEmDashEntry, getEmDashCollection, - getEntryTerms, getTermsForEntries, getSeoMeta, decodeSlug, @@ -72,18 +71,15 @@ const bylines = post.data.bylines ?? []; // Get reading time const readingTime = getReadingTime(post.data.content); -// Fetch this post's tags and the related-posts list in parallel — they're -// independent queries, so running them concurrently halves the round-trip -// cost on remote databases. -// Note: post.id is the slug, post.data.id is the database ULID. -const [tags, { entries: recentPosts }] = await Promise.all([ - getEntryTerms("posts", post.data.id, "tag"), - // Fetch a few extra in case the current post is among them - getEmDashCollection("posts", { - orderBy: { published_at: "desc" }, - limit: 4, - }), -]); +// This post's tags are already hydrated onto the entry by getEmDashEntry — +// no extra query needed. +const tags = post.data.terms?.tag ?? []; + +// Fetch a few extra recent posts in case the current post is among them. +const { entries: recentPosts } = await getEmDashCollection("posts", { + orderBy: { published_at: "desc" }, + limit: 4, +}); const otherPosts = recentPosts.filter((p) => p.id !== post.id).slice(0, 3); // Single batched query for related-posts tags, rather than one diff --git a/blog/emdash-env.d.ts b/blog/emdash-env.d.ts index abb2626..e1a5a89 100644 --- a/blog/emdash-env.d.ts +++ b/blog/emdash-env.d.ts @@ -3,7 +3,7 @@ /// -import type { ContentBylineCredit, PortableTextBlock } from "emdash"; +import type { ContentBylineCredit, TaxonomyTerm, PortableTextBlock } from "emdash"; export interface Page { id: string; @@ -15,6 +15,7 @@ export interface Page { updatedAt: Date; publishedAt: Date | null; bylines?: ContentBylineCredit[]; + terms?: Record; } export interface Post { @@ -29,6 +30,7 @@ export interface Post { updatedAt: Date; publishedAt: Date | null; bylines?: ContentBylineCredit[]; + terms?: Record; } declare module "emdash" { diff --git a/blog/package.json b/blog/package.json index a337d05..71cd8e2 100644 --- a/blog/package.json +++ b/blog/package.json @@ -19,7 +19,7 @@ "@emdash-cms/plugin-audit-log": "^0.2.0", "astro": "^6.3.0", "better-sqlite3": "^12.8.0", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/blog/src/pages/posts/[slug].astro b/blog/src/pages/posts/[slug].astro index f30d385..0cc892f 100644 --- a/blog/src/pages/posts/[slug].astro +++ b/blog/src/pages/posts/[slug].astro @@ -2,7 +2,6 @@ import { getEmDashEntry, getEmDashCollection, - getEntryTerms, getTermsForEntries, getSeoMeta, decodeSlug, @@ -72,18 +71,15 @@ const bylines = post.data.bylines ?? []; // Get reading time const readingTime = getReadingTime(post.data.content); -// Fetch this post's tags and the related-posts list in parallel — they're -// independent queries, so running them concurrently halves the round-trip -// cost on remote databases. -// Note: post.id is the slug, post.data.id is the database ULID. -const [tags, { entries: recentPosts }] = await Promise.all([ - getEntryTerms("posts", post.data.id, "tag"), - // Fetch a few extra in case the current post is among them - getEmDashCollection("posts", { - orderBy: { published_at: "desc" }, - limit: 4, - }), -]); +// This post's tags are already hydrated onto the entry by getEmDashEntry — +// no extra query needed. +const tags = post.data.terms?.tag ?? []; + +// Fetch a few extra recent posts in case the current post is among them. +const { entries: recentPosts } = await getEmDashCollection("posts", { + orderBy: { published_at: "desc" }, + limit: 4, +}); const otherPosts = recentPosts.filter((p) => p.id !== post.id).slice(0, 3); // Single batched query for related-posts tags, rather than one diff --git a/marketing-cloudflare/package.json b/marketing-cloudflare/package.json index 81cacad..add0a01 100644 --- a/marketing-cloudflare/package.json +++ b/marketing-cloudflare/package.json @@ -16,11 +16,11 @@ "dependencies": { "@astrojs/cloudflare": "^13.5.3", "@astrojs/react": "^5.0.0", - "@emdash-cms/cloudflare": "^0.16.1", + "@emdash-cms/cloudflare": "^0.18.0", "@iconify-json/ph": "^1.2.2", "astro": "^6.3.0", "astro-iconset": "^0.0.4", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/marketing/package.json b/marketing/package.json index c8d213b..7d3e947 100644 --- a/marketing/package.json +++ b/marketing/package.json @@ -20,7 +20,7 @@ "astro": "^6.3.0", "astro-iconset": "^0.0.4", "better-sqlite3": "^12.8.0", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/portfolio-cloudflare/package.json b/portfolio-cloudflare/package.json index 98969f2..9e00a34 100644 --- a/portfolio-cloudflare/package.json +++ b/portfolio-cloudflare/package.json @@ -16,9 +16,9 @@ "dependencies": { "@astrojs/cloudflare": "^13.5.3", "@astrojs/react": "^5.0.0", - "@emdash-cms/cloudflare": "^0.16.1", + "@emdash-cms/cloudflare": "^0.18.0", "astro": "^6.3.0", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/portfolio/package.json b/portfolio/package.json index 6576225..c9a4627 100644 --- a/portfolio/package.json +++ b/portfolio/package.json @@ -18,7 +18,7 @@ "@astrojs/react": "^5.0.0", "astro": "^6.3.0", "better-sqlite3": "^12.8.0", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/starter-cloudflare/emdash-env.d.ts b/starter-cloudflare/emdash-env.d.ts index 9dc6de3..2bd6b30 100644 --- a/starter-cloudflare/emdash-env.d.ts +++ b/starter-cloudflare/emdash-env.d.ts @@ -3,7 +3,7 @@ /// -import type { PortableTextBlock } from "emdash"; +import type { ContentBylineCredit, TaxonomyTerm, PortableTextBlock } from "emdash"; export interface Page { id: string; @@ -14,6 +14,8 @@ export interface Page { createdAt: Date; updatedAt: Date; publishedAt: Date | null; + bylines?: ContentBylineCredit[]; + terms?: Record; } export interface Post { @@ -27,6 +29,8 @@ export interface Post { createdAt: Date; updatedAt: Date; publishedAt: Date | null; + bylines?: ContentBylineCredit[]; + terms?: Record; } declare module "emdash" { diff --git a/starter-cloudflare/package.json b/starter-cloudflare/package.json index 5e83c50..26605e1 100644 --- a/starter-cloudflare/package.json +++ b/starter-cloudflare/package.json @@ -16,9 +16,9 @@ "dependencies": { "@astrojs/cloudflare": "^13.5.3", "@astrojs/react": "^5.0.0", - "@emdash-cms/cloudflare": "^0.16.1", + "@emdash-cms/cloudflare": "^0.18.0", "astro": "^6.3.0", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/starter-cloudflare/src/pages/posts/[slug].astro b/starter-cloudflare/src/pages/posts/[slug].astro index dd8b7fb..8218682 100644 --- a/starter-cloudflare/src/pages/posts/[slug].astro +++ b/starter-cloudflare/src/pages/posts/[slug].astro @@ -1,5 +1,5 @@ --- -import { getEmDashEntry, getEntryTerms, getSeoMeta, decodeSlug, getSiteSettings } from "emdash"; +import { getEmDashEntry, getSeoMeta, decodeSlug, getSiteSettings } from "emdash"; import { Image, PortableText, WidgetArea } from "emdash/ui"; import Base from "../../layouts/Base.astro"; import { resolveStarterSiteIdentity } from "../../utils/site-identity"; @@ -26,9 +26,9 @@ const seo = getSeoMeta(post, { path: `/posts/${slug}`, }); -// Taxonomy terms for this post (use post.data.id, not post.id) -const tags = await getEntryTerms("posts", post.data.id, "tag"); -const categories = await getEntryTerms("posts", post.data.id, "category"); +// Taxonomy terms are already hydrated onto the entry by getEmDashEntry. +const tags = post.data.terms?.tag ?? []; +const categories = post.data.terms?.category ?? []; --- -import type { PortableTextBlock } from "emdash"; +import type { ContentBylineCredit, TaxonomyTerm, PortableTextBlock } from "emdash"; export interface Page { id: string; @@ -14,6 +14,8 @@ export interface Page { createdAt: Date; updatedAt: Date; publishedAt: Date | null; + bylines?: ContentBylineCredit[]; + terms?: Record; } export interface Post { @@ -27,6 +29,8 @@ export interface Post { createdAt: Date; updatedAt: Date; publishedAt: Date | null; + bylines?: ContentBylineCredit[]; + terms?: Record; } declare module "emdash" { diff --git a/starter/package.json b/starter/package.json index e19d7f0..7ac3059 100644 --- a/starter/package.json +++ b/starter/package.json @@ -18,7 +18,7 @@ "@astrojs/react": "^5.0.0", "astro": "^6.3.0", "better-sqlite3": "^12.8.0", - "emdash": "^0.16.1", + "emdash": "^0.18.0", "react": "19.2.4", "react-dom": "19.2.4" }, diff --git a/starter/src/pages/posts/[slug].astro b/starter/src/pages/posts/[slug].astro index dd8b7fb..8218682 100644 --- a/starter/src/pages/posts/[slug].astro +++ b/starter/src/pages/posts/[slug].astro @@ -1,5 +1,5 @@ --- -import { getEmDashEntry, getEntryTerms, getSeoMeta, decodeSlug, getSiteSettings } from "emdash"; +import { getEmDashEntry, getSeoMeta, decodeSlug, getSiteSettings } from "emdash"; import { Image, PortableText, WidgetArea } from "emdash/ui"; import Base from "../../layouts/Base.astro"; import { resolveStarterSiteIdentity } from "../../utils/site-identity"; @@ -26,9 +26,9 @@ const seo = getSeoMeta(post, { path: `/posts/${slug}`, }); -// Taxonomy terms for this post (use post.data.id, not post.id) -const tags = await getEntryTerms("posts", post.data.id, "tag"); -const categories = await getEntryTerms("posts", post.data.id, "category"); +// Taxonomy terms are already hydrated onto the entry by getEmDashEntry. +const tags = post.data.terms?.tag ?? []; +const categories = post.data.terms?.category ?? []; ---