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

feat: add option to disable publishing (text) content #40

merged opened by willow.sh targeting main from willow.sh/sequoia: disable-text-content

Adds an option to disable publishing the text content since it may not be desired - defaults to true since that's the current behavior.

PR is dependent on #39 because of the json schema changes, so maybe best to look at that first

Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:dfkjiu36xs6ogt7pux7i7o2b/sh.tangled.repo.pull/3mgemcc6tsb22
+40 -10
Diff #2
+6
packages/cli/src/commands/init.ts
··· 98 98 message: "URL path prefix for posts:", 99 99 placeholder: "/posts, /blog, /articles, etc.", 100 100 }), 101 + publishContent: () => 102 + confirm({ 103 + message: "Publish the post content on the standard.site document?", 104 + initialValue: true, 105 + }), 101 106 }, 102 107 { onCancel }, 103 108 ); ··· 341 346 pdsUrl, 342 347 frontmatter: frontmatterMapping, 343 348 bluesky: blueskyConfig, 349 + publishContent: siteConfig.publishContent, 344 350 }); 345 351 346 352 const configPath = path.join(process.cwd(), "sequoia.json");
+9
packages/cli/src/commands/update.ts
··· 162 162 stripDatePrefix: configUpdated.stripDatePrefix, 163 163 pathTemplate: configUpdated.pathTemplate, 164 164 textContentField: configUpdated.textContentField, 165 + publishContent: configUpdated.publishContent, 165 166 bluesky: configUpdated.bluesky, 166 167 }); 167 168 ··· 373 374 }), 374 375 ); 375 376 377 + const publishContent = exitOnCancel( 378 + await confirm({ 379 + message: "Publish the post content on the standard.site document?", 380 + initialValue: config.publishContent ?? true, 381 + }), 382 + ); 383 + 376 384 const textContentField = exitOnCancel( 377 385 await text({ 378 386 message: ··· 397 405 removeIndexFromSlug: removeIndexFromSlug || undefined, 398 406 stripDatePrefix: stripDatePrefix || undefined, 399 407 textContentField: textContentField || undefined, 408 + publishContent: publishContent ?? true, 400 409 }; 401 410 } 402 411
+11 -9
packages/cli/src/lib/atproto.ts
··· 252 252 ); 253 253 const publishDate = new Date(post.frontmatter.publishDate); 254 254 255 - // Determine textContent: use configured field from frontmatter, or fallback to markdown body 256 - let textContent: string; 255 + // Determine textContent (if enabled): use configured field from frontmatter, or fallback to markdown body 256 + let textContent: string | null = null; 257 257 if ( 258 + config.publishContent && 258 259 config.textContentField && 259 260 post.rawFrontmatter?.[config.textContentField] 260 261 ) { 261 262 textContent = String(post.rawFrontmatter[config.textContentField]); 262 - } else { 263 + } else if (config.publishContent) { 263 264 textContent = stripMarkdownForText(post.content); 264 265 } 265 266 ··· 268 269 title: post.frontmatter.title, 269 270 site: config.publicationUri, 270 271 path: postPath, 271 - textContent: textContent.slice(0, 10000), 272 + textContent: textContent?.slice(0, 10000), 272 273 publishedAt: publishDate.toISOString(), 273 274 canonicalUrl: `${config.siteUrl}${postPath}`, 274 275 }; ··· 317 318 ); 318 319 const publishDate = new Date(post.frontmatter.publishDate); 319 320 320 - // Determine textContent: use configured field from frontmatter, or fallback to markdown body 321 - let textContent: string; 321 + // Determine textContent (if enabled): use configured field from frontmatter, or fallback to markdown body 322 + let textContent: string | null = null; 322 323 if ( 324 + config.publishContent && 323 325 config.textContentField && 324 326 post.rawFrontmatter?.[config.textContentField] 325 327 ) { 326 328 textContent = String(post.rawFrontmatter[config.textContentField]); 327 - } else { 329 + } else if (config.publishContent) { 328 330 textContent = stripMarkdownForText(post.content); 329 331 } 330 332 ··· 342 344 title: post.frontmatter.title, 343 345 site: config.publicationUri, 344 346 path: postPath, 345 - textContent: textContent.slice(0, 10000), 347 + textContent: textContent?.slice(0, 10000), 346 348 publishedAt: publishDate.toISOString(), 347 349 canonicalUrl: `${config.siteUrl}${postPath}`, 348 350 }; ··· 384 386 title: string; 385 387 site: string; 386 388 path: string; 387 - textContent: string; 389 + textContent?: string; 388 390 publishedAt: string; 389 391 canonicalUrl?: string; 390 392 description?: string;
+8 -1
packages/cli/src/lib/config.ts
··· 85 85 stripDatePrefix?: boolean; 86 86 pathTemplate?: string; 87 87 textContentField?: string; 88 + publishContent?: boolean; 88 89 bluesky?: BlueskyConfig; 89 90 }): string { 90 91 const config: Record<string, unknown> = { 91 - $schema: 'https://tangled.org/stevedylan.dev/sequoia/raw/main/sequoia.schema.json', 92 + $schema: 93 + "https://tangled.org/stevedylan.dev/sequoia/raw/main/sequoia.schema.json", 92 94 siteUrl: options.siteUrl, 93 95 contentDir: options.contentDir, 94 96 }; ··· 138 140 if (options.textContentField) { 139 141 config.textContentField = options.textContentField; 140 142 } 143 + 144 + if (options.publishContent) { 145 + config.publishContent = options.publishContent; 146 + } 147 + 141 148 if (options.bluesky) { 142 149 config.bluesky = options.bluesky; 143 150 }
+1
packages/cli/src/lib/types.ts
··· 41 41 stripDatePrefix?: boolean; // Remove YYYY-MM-DD- prefix from filenames (Jekyll-style, default: false) 42 42 pathTemplate?: string; // URL path template with tokens like {year}/{month}/{day}/{slug} (overrides pathPrefix + slug) 43 43 textContentField?: string; // Frontmatter field to use for textContent instead of markdown body 44 + publishContent?: boolean; // Whether or not to publish the documents content on the standard.site document (default: true) 44 45 bluesky?: BlueskyConfig; // Optional Bluesky posting configuration 45 46 ui?: UIConfig; // Optional UI components configuration 46 47 }
+5
sequoia.schema.json
··· 116 116 "type": "string", 117 117 "description": "Frontmatter field to use for textContent instead of markdown body" 118 118 }, 119 + "publishContent": { 120 + "type": "boolean", 121 + "description": "Whether or not to publish the documents content on the standard.site document", 122 + "default": true 123 + }, 119 124 "bluesky": { 120 125 "type": "object", 121 126 "additionalProperties": false,

History

3 rounds 5 comments
sign up or login to add to the discussion
1 commit
expand
feat: add option to disable publishing (text) content
expand 2 comments

@stevedylan.dev merged conflicts fixed - the only issue I can foresee is that the diff checking system when you publish isn't aware of this field. We could fix that or I could open a PR that makes the diff system "simpler" by essentially building the site.standard.document for each post and then comparing that with the published site.standard.document for the post to see if there is a difference. That way it should catch any changes that it's currently missing. WDYT?

Good catch! I think a separate PR with your solution would work great. Will go ahead and merge this!

pull request successfully merged
2 commits
expand
feat: add json schema
feat: add option to disable publishing (text) content
expand 1 comment

I鈥檝e had the in the back of my head; thank you for carrying it out! For some reason Tangled is saying there is some merge conflicts due to the last PR, so happy to merge once it gets cleared up!

2 commits
expand
feat: add json schema
feat: add option to disable publishing (text) content
expand 2 comments