diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts index 3a80ed1..ddd503c 100644 --- a/packages/cli/src/commands/init.ts +++ b/packages/cli/src/commands/init.ts @@ -118,6 +118,12 @@ export const initCommand = command({ placeholder: "ogImage, coverImage, image, hero, etc.", }); + const tagsField = await consola.prompt("Field name for tags:", { + type: "text", + default: "tags", + placeholder: "tags, categories, keywords, etc.", + }); + let frontmatterMapping: FrontmatterMapping | undefined = {}; if (titleField && titleField !== "title") { @@ -132,6 +138,9 @@ export const initCommand = command({ if (coverField && coverField !== "ogImage") { frontmatterMapping.coverImage = coverField as string; } + if (tagsField && tagsField !== "tags") { + frontmatterMapping.tags = tagsField as string; + } // Only keep frontmatterMapping if it has any custom fields if (Object.keys(frontmatterMapping).length === 0) { diff --git a/packages/cli/src/lib/atproto.ts b/packages/cli/src/lib/atproto.ts index 50a9af3..6ffeca3 100644 --- a/packages/cli/src/lib/atproto.ts +++ b/packages/cli/src/lib/atproto.ts @@ -183,6 +183,10 @@ export async function createDocument( record.coverImage = coverImage; } + if (post.frontmatter.tags && post.frontmatter.tags.length > 0) { + record.tags = post.frontmatter.tags; + } + const response = await agent.com.atproto.repo.createRecord({ repo: agent.session!.did, collection: "site.standard.document", @@ -227,6 +231,10 @@ export async function updateDocument( record.coverImage = coverImage; } + if (post.frontmatter.tags && post.frontmatter.tags.length > 0) { + record.tags = post.frontmatter.tags; + } + await agent.com.atproto.repo.putRecord({ repo: agent.session!.did, collection: collection!, @@ -254,6 +262,7 @@ export interface DocumentRecord { publishedAt: string; canonicalUrl?: string; coverImage?: BlobObject; + tags?: string[]; location?: string; }