CLI tool to sync your Markdown to Leaflet
leafletpub atproto cli markdown
30
fork

Configure Feed

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

Ability to change theme of the code block

SharpMars 286b3bac f5e50ebe

+28 -6
+9
src/commands/config-cmd.ts
··· 77 77 if (config.frontmatter.uploadDateKey) 78 78 printConfigLine("Upload Date Key", wrap(config.frontmatter.uploadDateKey, '"'), 2); 79 79 } 80 + if (config.codeblockTheme) { 81 + printConfigLine( 82 + "Code Block Theme", 83 + config.codeblockTheme 84 + .split("-") 85 + .map((val) => val.charAt(0).toLocaleUpperCase() + val.slice(1)) 86 + .join(" ") 87 + ); 88 + } 80 89 if (config.prependDoc) { 81 90 printConfigLine( 82 91 "Prepend doc",
+5 -3
src/commands/sync-cmd.ts
··· 154 154 consola.error(error); 155 155 } 156 156 157 + const codeblockTheme = config.codeblockTheme ? config.codeblockTheme : undefined; 158 + 157 159 for (const file of files) { 158 160 const path = config.glob.base ? join(config.glob.base, file) : "./" + file; 159 161 if (config.prependDoc && resolve(config.prependDoc.path) == resolve(path)) continue; ··· 199 201 }); 200 202 } 201 203 202 - prependBlocks = generateBlocks(ast.children, uploadedImages); 204 + prependBlocks = generateBlocks(ast.children, uploadedImages, codeblockTheme); 203 205 } 204 206 205 207 if (config.appendDoc) { ··· 238 240 }); 239 241 } 240 242 241 - appendBlocks = generateBlocks(ast.children, uploadedImages); 243 + appendBlocks = generateBlocks(ast.children, uploadedImages, codeblockTheme); 242 244 } 243 245 244 246 const md = (await readFile(config.glob.base ? join(config.glob.base, file) : file)).toString(); ··· 311 313 const doc = generateDoc( 312 314 miniDoc.did, 313 315 publicationUri, 314 - [...prependBlocks, ...generateBlocks(ast.children, uploadedImages), ...appendBlocks], 316 + [...prependBlocks, ...generateBlocks(ast.children, uploadedImages, codeblockTheme), ...appendBlocks], 315 317 title, 316 318 description, 317 319 new Date(uploadDate)
+10 -1
src/config.ts
··· 7 7 8 8 export interface Config { 9 9 glob: { pattern: string; base?: string }; 10 - frontmatter?: { type: "yaml"; titleKey: string; descriptionKey?: string; uploadDateKey?: string }; 10 + frontmatter?: { 11 + type: "yaml"; 12 + titleKey: string; 13 + descriptionKey?: string; 14 + uploadDateKey?: string; 15 + }; 11 16 publicationUri?: ResourceUri; 12 17 prependDoc?: { path: string; replacement?: Replacement }; 13 18 appendDoc?: { path: string; replacement?: Replacement }; 19 + /** 20 + * All available themes can be found at {@link https://shiki.matsu.io/themes} under the ID column 21 + */ 22 + codeblockTheme?: string; 14 23 } 15 24 16 25 export function defineConfig(config: Config) {
+4 -2
src/conversion.ts
··· 10 10 11 11 export function generateBlocks( 12 12 children: RootContent[], 13 - uploadedImages: Map<string, { blob: Blob; width: number; height: number }> 13 + uploadedImages: Map<string, { blob: Blob; width: number; height: number }>, 14 + codeblockTheme?: string 14 15 ) { 16 + codeblockTheme ??= "catppuccin-mocha"; 15 17 return children 16 18 .flatMap((val): PubLeafletPagesLinearDocument.Block | PubLeafletPagesLinearDocument.Block[] | null => { 17 19 if (val.type == "heading") { ··· 53 55 $type: "pub.leaflet.blocks.code", 54 56 plaintext: val.value, 55 57 language: val.lang == null ? undefined : val.lang, 56 - syntaxHighlightingTheme: "catppuccin-mocha", 58 + syntaxHighlightingTheme: codeblockTheme, 57 59 }, 58 60 }; 59 61 } else if (val.type == "blockquote") {