Description
Both LiveSearch (the live search dropdown, exported from emdash/ui/search) and the RecentPosts widget construct result links by hardcoding the collection name into the path /${collection}/${slug} and /posts/${post.id} respectively.
Sites using a catch-all route like src/pages/[...slug].astro (so URLs are /{slug} without the /posts/ segment the common SEO pattern for content sites and news publishers) have no way to override this.
The <slot name="result"> in LiveSearch doesn't help because the JS overwrites link.href on every cloned template after the slot renders.
Proposed fix: add an optional urlBuilder?: (entry) => string prop to both components, defaulting to the current /${collection}/${slug} behaviour so existing sites are unaffected. For LiveSearch (client-side), the builder could be serialised via the existing data-config JSON, or accept a template string like "/${slug}" if a function attribute is too costly.
Steps to reproduce
- Scaffold a site with
pnpm create emdash@latest my-site --template cloudflare:blog
-
- Replace
src/pages/posts/[slug].astro and src/pages/pages/[slug].astro with a single catch-all src/pages/[...slug].astro that resolves the slug across both posts and pages collections
- Update internal
href references throughout src/ from /posts/${id} to /${id} (e.g. in index.astro, posts/index.astro, category/[slug].astro, tag/[slug].astro, search.astro, rss.xml.ts)
- Deploy. Direct navigation to
/{slug} works correctly content renders via the catch-all
- On any page rendering
<LiveSearch />, type a query, click any dropdown result -> browser navigates to /posts/{slug} and hits /404 because that path no longer exists
- Same outcome if a widget area renders
RecentPosts its links also point to /posts/{slug}
Environment
emdash version: 0.16.1
@emdash-cms/cloudflare version: 0.16.1
Astro version: 6.4.3
Node.js version: 22.x (via pnpm 11)
Runtime: Cloudflare Workers
OS: Windows 11
Logs / error output
Expected: dropdown result link href = `/${slug}`
Actual: dropdown result link href = `/${collection}/${slug}` → 404 on catch-all sites
Description
Both
LiveSearch(the live search dropdown, exported fromemdash/ui/search) and theRecentPostswidget construct result links by hardcoding the collection name into the path/${collection}/${slug}and/posts/${post.id}respectively.Sites using a catch-all route like
src/pages/[...slug].astro(so URLs are/{slug}without the/posts/segment the common SEO pattern for content sites and news publishers) have no way to override this.The
<slot name="result">in LiveSearch doesn't help because the JS overwriteslink.hrefon every cloned template after the slot renders.Proposed fix: add an optional
urlBuilder?: (entry) => stringprop to both components, defaulting to the current/${collection}/${slug}behaviour so existing sites are unaffected. For LiveSearch (client-side), the builder could be serialised via the existingdata-configJSON, or accept a template string like"/${slug}"if a function attribute is too costly.Steps to reproduce
pnpm create emdash@latest my-site --template cloudflare:blogsrc/pages/posts/[slug].astroandsrc/pages/pages/[slug].astrowith a single catch-allsrc/pages/[...slug].astrothat resolves the slug across bothpostsandpagescollectionshrefreferences throughoutsrc/from/posts/${id}to/${id}(e.g. inindex.astro,posts/index.astro,category/[slug].astro,tag/[slug].astro,search.astro,rss.xml.ts)/{slug}works correctly content renders via the catch-all<LiveSearch />, type a query, click any dropdown result -> browser navigates to/posts/{slug}and hits/404because that path no longer existsRecentPostsits links also point to/posts/{slug}Environment
emdash version: 0.16.1
@emdash-cms/cloudflare version: 0.16.1
Astro version: 6.4.3
Node.js version: 22.x (via pnpm 11)
Runtime: Cloudflare Workers
OS: Windows 11
Logs / error output