Skip to content

Commit

Permalink
Ensure tags aren't incorrectly split (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
zephraph authored Dec 16, 2024
1 parent 26711b0 commit 4f459ff
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 4f459ff

Please sign in to comment.