A CLI for publishing standard.site documents to ATProto sequoia.pub
standard site lexicon cli publishing
55
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: corrected behavior for empty string in pathPrefix

authored by

Steve and committed by tangled.org be2bd60c a9a8e15d

+37 -7
+1 -1
packages/cli/src/commands/init.ts
··· 341 341 imagesDir: siteConfig.imagesDir || undefined, 342 342 publicDir: siteConfig.publicDir || "./public", 343 343 outputDir: siteConfig.outputDir || "./dist", 344 - pathPrefix: siteConfig.pathPrefix || "/posts", 344 + pathPrefix: siteConfig.pathPrefix ?? "/posts", 345 345 publicationUri, 346 346 pdsUrl, 347 347 frontmatter: frontmatterMapping,
+3 -3
packages/cli/src/commands/update.ts
··· 70 70 const configSummary = [ 71 71 `Site URL: ${config.siteUrl}`, 72 72 `Content Dir: ${config.contentDir}`, 73 - `Path Prefix: ${config.pathPrefix || "/posts"}`, 73 + `Path Prefix: ${config.pathPrefix ?? "/posts"}`, 74 74 `Publication URI: ${config.publicationUri}`, 75 75 config.imagesDir ? `Images Dir: ${config.imagesDir}` : null, 76 76 config.outputDir ? `Output Dir: ${config.outputDir}` : null, ··· 194 194 const pathPrefix = exitOnCancel( 195 195 await text({ 196 196 message: "URL path prefix for posts:", 197 - initialValue: config.pathPrefix || "/posts", 197 + initialValue: config.pathPrefix ?? "/posts", 198 198 }), 199 199 ); 200 200 201 201 return { 202 202 ...config, 203 203 siteUrl, 204 - pathPrefix: pathPrefix || undefined, 204 + pathPrefix, 205 205 }; 206 206 } 207 207
+2 -2
packages/cli/src/lib/markdown.ts
··· 231 231 if (pathTemplate) { 232 232 return resolvePathTemplate(pathTemplate, post); 233 233 } 234 - const prefix = pathPrefix || "/posts"; 235 - return `${prefix}/${post.slug}`; 234 + const prefix = pathPrefix ?? "/posts"; 235 + return prefix ? `${prefix}/${post.slug}` : `/${post.slug}`; 236 236 } 237 237 238 238 export async function getContentHash(content: string): Promise<string> {
+31 -1
packages/cli/test/markdown.test.ts
··· 1 1 import { describe, expect, it } from "bun:test"; 2 - import { parseFrontmatter } from "../src/lib/markdown"; 2 + import { parseFrontmatter, resolvePostPath } from "../src/lib/markdown"; 3 + import type { BlogPost } from "../src/lib/types"; 3 4 4 5 describe("parseFrontmatter", () => { 5 6 describe("delimiters", () => { ··· 385 386 }); 386 387 }); 387 388 }); 389 + 390 + describe("resolvePostPath", () => { 391 + const post: BlogPost = { 392 + filePath: "/tmp/hello.md", 393 + slug: "hello-world", 394 + frontmatter: { title: "Hello" } as BlogPost["frontmatter"], 395 + content: "", 396 + rawContent: "", 397 + rawFrontmatter: {}, 398 + }; 399 + 400 + it("defaults to /posts when pathPrefix is undefined", () => { 401 + expect(resolvePostPath(post)).toBe("/posts/hello-world"); 402 + }); 403 + 404 + it("uses custom prefix when provided", () => { 405 + expect(resolvePostPath(post, "/blog")).toBe("/blog/hello-world"); 406 + }); 407 + 408 + it("omits prefix when pathPrefix is an empty string", () => { 409 + expect(resolvePostPath(post, "")).toBe("/hello-world"); 410 + }); 411 + 412 + it("pathTemplate overrides pathPrefix", () => { 413 + expect(resolvePostPath(post, "", "/custom/{slug}")).toBe( 414 + "/custom/hello-world", 415 + ); 416 + }); 417 + });