this repo has no description
0
fork

Configure Feed

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

refactor: shuffle things around

+54 -46
+9
cli/dev.ts
··· 1 + import { Command } from "@cliffy/command"; 2 + import { startDevServer } from "../server/dev.ts"; 3 + 4 + export const dev = new Command() 5 + .arguments("<source:string>") 6 + .description("Serve, watch, and rebuild") 7 + .action(async (_opts: unknown, source: string) => { 8 + await startDevServer(source); 9 + });
+7 -11
commands/dev.ts server/dev.ts
··· 1 - import { Command } from "@cliffy/command"; 2 1 import { Eta } from "@eta-dev/eta"; 3 - import { renderBody } from "../parse/render.ts"; 2 + import { renderBody } from "../core/renderer.ts"; 4 3 5 4 const eta = new Eta({ views: Deno.cwd() + "/templates" }); 6 5 7 - export const dev = new Command() 8 - .arguments("<source:string>") 9 - .description("Serve, watch, and rebuild ") 10 - .action(async (_opts: unknown, source: string) => { 11 - await Promise.all([ 12 - watchFile(source), 13 - Deno.serve(makeHandler(source)), 14 - ]); 15 - }); 6 + export async function startDevServer(source: string) { 7 + await Promise.all([ 8 + watchFile(source), 9 + Deno.serve(makeHandler(source)), 10 + ]); 11 + } 16 12 17 13 async function watchFile(path: string) { 18 14 const channel = openChannel();
+35
core/renderer.ts
··· 1 + import Markdoc, { Node } from "@markdoc/markdoc"; 2 + import { createMarkdocConfig } from "./markdoc-config.ts"; 3 + 4 + export async function renderBody(path: string) { 5 + const file = await Deno.readTextFile(path); 6 + const ast = Markdoc.parse(file); 7 + 8 + const groups: Node[][] = []; 9 + let currentGroup: Node[] = []; 10 + 11 + for (const child of ast.children) { 12 + if (child.type !== "hr") { 13 + currentGroup.push(child); 14 + } else { 15 + groups.push(currentGroup); 16 + currentGroup = []; 17 + } 18 + } 19 + 20 + groups.push(currentGroup); 21 + 22 + ast.children = groups.map((children) => 23 + new Node("tag", undefined, [ 24 + new Node("tag", undefined, children, "content"), 25 + ], "slide") 26 + ); 27 + 28 + const { config, scripts } = createMarkdocConfig(); 29 + const tree = Markdoc.transform(ast, config); 30 + 31 + return { 32 + scripts, 33 + body: Markdoc.renderers.html(await Promise.resolve(tree)), 34 + }; 35 + }
+1 -1
main.ts
··· 1 1 import { Command } from "@cliffy/command"; 2 - import { dev } from "./commands/dev.ts"; 2 + import { dev } from "./cli/dev.ts"; 3 3 4 4 await new Command() 5 5 .name("morkdeck")
+2 -34
parse/render.ts core/markdoc-config.ts
··· 33 33 return tag; 34 34 } 35 35 36 - function createConfig() { 36 + export function createMarkdocConfig() { 37 37 const scripts = new Set<string>(); 38 + 38 39 const config: Config = { 39 40 tags: { 40 41 slide: { ··· 78 79 79 80 return { scripts, config }; 80 81 } 81 - 82 - export async function renderBody(path: string) { 83 - const file = await Deno.readTextFile(path); 84 - const ast = Markdoc.parse(file); 85 - 86 - const groups: Node[][] = []; 87 - let currentGroup: Node[] = []; 88 - 89 - for (const child of ast.children) { 90 - if (child.type !== "hr") { 91 - currentGroup.push(child); 92 - } else { 93 - groups.push(currentGroup); 94 - currentGroup = []; 95 - } 96 - } 97 - 98 - groups.push(currentGroup); 99 - 100 - ast.children = groups.map((children) => 101 - new Node("tag", undefined, [ 102 - new Node("tag", undefined, children, "content"), 103 - ], "slide") 104 - ); 105 - 106 - const { config, scripts } = createConfig(); 107 - const tree = Markdoc.transform(ast, config); 108 - 109 - return { 110 - scripts, 111 - body: Markdoc.renderers.html(await Promise.resolve(tree)), 112 - }; 113 - }