| 1 | export interface FrontmatterMapping { |
| 2 | title?: string; // Field name for title (default: "title") |
| 3 | description?: string; // Field name for description (default: "description") |
| 4 | publishDate?: string; // Field name for publish date (default: "publishDate", also checks "pubDate", "date", "createdAt", "created_at") |
| 5 | updatedAt?: string; // Field name for updated date (default: "updatedAt", also checks "updated_at", "modifiedAt", "modified_at") |
| 6 | coverImage?: string; // Field name for cover image (default: "ogImage") |
| 7 | tags?: string; // Field name for tags (default: "tags") |
| 8 | draft?: string; // Field name for draft status (default: "draft") |
| 9 | slugField?: string; // Frontmatter field to use for slug (if set, uses frontmatter value; otherwise uses filepath) |
| 10 | } |
| 11 | |
| 12 | // Strong reference for Bluesky post (com.atproto.repo.strongRef) |
| 13 | export interface StrongRef { |
| 14 | uri: string; // at:// URI format |
| 15 | cid: string; // Content ID |
| 16 | } |
| 17 | |
| 18 | // Bluesky posting configuration |
| 19 | export interface BlueskyConfig { |
| 20 | enabled: boolean; |
| 21 | maxAgeDays?: number; // Only post if published within N days (default: 7) |
| 22 | } |
| 23 | |
| 24 | // UI components configuration |
| 25 | export interface UIConfig { |
| 26 | components: string; // Directory to install UI components (default: src/components) |
| 27 | } |
| 28 | |
| 29 | export interface PublisherConfig { |
| 30 | siteUrl: string; |
| 31 | contentDir: string; |
| 32 | imagesDir?: string; // Directory containing cover images |
| 33 | publicDir?: string; // Static/public folder for .well-known files (default: public) |
| 34 | outputDir?: string; // Built output directory for inject command |
| 35 | pathPrefix?: string; // URL path prefix for posts (default: /posts) |
| 36 | publicationUri: string; |
| 37 | pdsUrl?: string; |
| 38 | identity?: string; // Which stored identity to use (matches identifier) |
| 39 | frontmatter?: FrontmatterMapping; // Custom frontmatter field mappings |
| 40 | ignore?: string[]; // Glob patterns for files to ignore (e.g., ["_index.md", "**/drafts/**"]) |
| 41 | removeIndexFromSlug?: boolean; // Remove "/index" or "/_index" suffix from paths (default: false) |
| 42 | stripDatePrefix?: boolean; // Remove YYYY-MM-DD- prefix from filenames (Jekyll-style, default: false) |
| 43 | pathTemplate?: string; // URL path template with tokens like {year}/{month}/{day}/{slug} (overrides pathPrefix + slug) |
| 44 | textContentField?: string; // Frontmatter field to use for textContent instead of markdown body |
| 45 | publishContent?: boolean; // Whether or not to publish the documents content on the standard.site document (default: true) |
| 46 | bluesky?: BlueskyConfig; // Optional Bluesky posting configuration |
| 47 | ui?: UIConfig; // Optional UI components configuration |
| 48 | } |
| 49 | |
| 50 | // Legacy credentials format (for backward compatibility during migration) |
| 51 | export interface LegacyCredentials { |
| 52 | pdsUrl: string; |
| 53 | identifier: string; |
| 54 | password: string; |
| 55 | } |
| 56 | |
| 57 | // App password credentials (explicit type) |
| 58 | export interface AppPasswordCredentials { |
| 59 | type: "app-password"; |
| 60 | pdsUrl: string; |
| 61 | identifier: string; |
| 62 | password: string; |
| 63 | } |
| 64 | |
| 65 | // OAuth credentials (references stored OAuth session) |
| 66 | // Note: pdsUrl is not needed for OAuth - the OAuth client resolves PDS from the DID |
| 67 | export interface OAuthCredentials { |
| 68 | type: "oauth"; |
| 69 | did: string; |
| 70 | handle: string; |
| 71 | } |
| 72 | |
| 73 | // Union type for all credential types |
| 74 | export type Credentials = AppPasswordCredentials | OAuthCredentials; |
| 75 | |
| 76 | // Helper to check credential type |
| 77 | export function isOAuthCredentials( |
| 78 | creds: Credentials, |
| 79 | ): creds is OAuthCredentials { |
| 80 | return creds.type === "oauth"; |
| 81 | } |
| 82 | |
| 83 | export function isAppPasswordCredentials( |
| 84 | creds: Credentials, |
| 85 | ): creds is AppPasswordCredentials { |
| 86 | return creds.type === "app-password"; |
| 87 | } |
| 88 | |
| 89 | export interface PostFrontmatter { |
| 90 | title: string; |
| 91 | description?: string; |
| 92 | bskyPost?: string; |
| 93 | publishDate: string; |
| 94 | updatedAt?: string; |
| 95 | tags?: string[]; |
| 96 | ogImage?: string; |
| 97 | atUri?: string; |
| 98 | draft?: boolean; |
| 99 | } |
| 100 | |
| 101 | export interface BlogPost { |
| 102 | filePath: string; |
| 103 | slug: string; |
| 104 | frontmatter: PostFrontmatter; |
| 105 | content: string; |
| 106 | rawContent: string; |
| 107 | rawFrontmatter: Record<string, unknown>; // For accessing custom fields like textContentField |
| 108 | } |
| 109 | |
| 110 | export interface BlobRef { |
| 111 | $link: string; |
| 112 | } |
| 113 | |
| 114 | export interface BlobObject { |
| 115 | $type: "blob"; |
| 116 | ref: BlobRef; |
| 117 | mimeType: string; |
| 118 | size: number; |
| 119 | } |
| 120 | |
| 121 | export interface PublisherState { |
| 122 | posts: Record<string, PostState>; |
| 123 | } |
| 124 | |
| 125 | export interface PostState { |
| 126 | contentHash: string; |
| 127 | atUri?: string; |
| 128 | lastPublished?: string; |
| 129 | slug?: string; // The generated slug for this post (used by inject command) |
| 130 | bskyPostRef?: StrongRef; // Reference to corresponding Bluesky post |
| 131 | } |
| 132 | |
| 133 | export interface PublicationRecord { |
| 134 | $type: "site.standard.publication"; |
| 135 | url: string; |
| 136 | name: string; |
| 137 | description?: string; |
| 138 | icon?: BlobObject; |
| 139 | createdAt: string; |
| 140 | preferences?: { |
| 141 | showInDiscover?: boolean; |
| 142 | }; |
| 143 | } |