Skip to content

Commit

Permalink
Ensure tags aren't incorrectly split
Browse files Browse the repository at this point in the history
I published a meta tag and it was showing up as `/m/` instead of `/meta/`.
  • Loading branch information
zephraph committed Nov 25, 2024
1 parent 26711b0 commit ba5b2a7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/pages/api/[...path].ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ const app = new Hono<{ Bindings: AstroContext }>()
throw new Error("Title and H1s should not be a ULID");
}

const primaryTag = props.tags?.split(",")[0];
const tags = props.tags?.split(",").filter(Boolean) ?? [];
const primaryTag = tags[0];
// Set the prefix URL to the first tag (or its mapped value) if it exists
if (primaryTag && primaryTag !== slug) {
slug = `${
tagMap[primaryTag as keyof typeof tagMap] ?? props.tags[0]
tagMap[primaryTag as keyof typeof tagMap] ?? primaryTag
}/${slug}`;
}

Expand Down

0 comments on commit ba5b2a7

Please sign in to comment.