packages/cli/src/lib/types.ts 3.0 K raw
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
	coverImage?: string; // Field name for cover image (default: "ogImage")
6
	tags?: string; // Field name for tags (default: "tags")
7
	draft?: string; // Field name for draft status (default: "draft")
8
	slugField?: string; // Frontmatter field to use for slug (if set, uses frontmatter value; otherwise uses filepath)
9
}
10
11
// Strong reference for Bluesky post (com.atproto.repo.strongRef)
12
export interface StrongRef {
13
	uri: string; // at:// URI format
14
	cid: string; // Content ID
15
}
16
17
// Bluesky posting configuration
18
export interface BlueskyConfig {
19
	enabled: boolean;
20
	maxAgeDays?: number; // Only post if published within N days (default: 7)
21
}
22
23
export interface PublisherConfig {
24
	siteUrl: string;
25
	contentDir: string;
26
	imagesDir?: string; // Directory containing cover images
27
	publicDir?: string; // Static/public folder for .well-known files (default: public)
28
	outputDir?: string; // Built output directory for inject command
29
	pathPrefix?: string; // URL path prefix for posts (default: /posts)
30
	publicationUri: string;
31
	pdsUrl?: string;
32
	identity?: string; // Which stored identity to use (matches identifier)
33
	frontmatter?: FrontmatterMapping; // Custom frontmatter field mappings
34
	ignore?: string[]; // Glob patterns for files to ignore (e.g., ["_index.md", "**/drafts/**"])
35
	removeIndexFromSlug?: boolean; // Remove "/index" or "/_index" suffix from paths (default: false)
36
	textContentField?: string; // Frontmatter field to use for textContent instead of markdown body
37
	bluesky?: BlueskyConfig; // Optional Bluesky posting configuration
38
}
39
40
export interface Credentials {
41
	pdsUrl: string;
42
	identifier: string;
43
	password: string;
44
}
45
46
export interface PostFrontmatter {
47
	title: string;
48
	description?: string;
49
	publishDate: string;
50
	tags?: string[];
51
	ogImage?: string;
52
	atUri?: string;
53
	draft?: boolean;
54
}
55
56
export interface BlogPost {
57
	filePath: string;
58
	slug: string;
59
	frontmatter: PostFrontmatter;
60
	content: string;
61
	rawContent: string;
62
	rawFrontmatter: Record<string, unknown>; // For accessing custom fields like textContentField
63
}
64
65
export interface BlobRef {
66
	$link: string;
67
}
68
69
export interface BlobObject {
70
	$type: "blob";
71
	ref: BlobRef;
72
	mimeType: string;
73
	size: number;
74
}
75
76
export interface PublisherState {
77
	posts: Record<string, PostState>;
78
}
79
80
export interface PostState {
81
	contentHash: string;
82
	atUri?: string;
83
	lastPublished?: string;
84
	slug?: string; // The generated slug for this post (used by inject command)
85
	bskyPostRef?: StrongRef; // Reference to corresponding Bluesky post
86
}
87
88
export interface PublicationRecord {
89
	$type: "site.standard.publication";
90
	url: string;
91
	name: string;
92
	description?: string;
93
	icon?: BlobObject;
94
	createdAt: string;
95
	preferences?: {
96
		showInDiscover?: boolean;
97
	};
98
}