-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d858ed
commit 2f99cd0
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// TODO: Parse links from JSON file. | ||
// TODO: Add `test` helper function to check if a URL or URL map is valid. | ||
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { extract, test } from "#/deps.ts"; | ||
|
||
export interface WorkshopAttrs { | ||
title?: string; | ||
description?: string; | ||
participants?: string[]; | ||
labels?: string[]; | ||
resources?: string[]; | ||
} | ||
|
||
export interface Workshop { | ||
id: string; | ||
md: string; | ||
attrs?: WorkshopAttrs; | ||
} | ||
|
||
export function parseWorkshop(filename: string, md: string): Workshop { | ||
const id = filename.replace(/\.md$/, ""); | ||
if (!test(md)) { | ||
return { id, md }; | ||
} | ||
|
||
const extracted = extract<WorkshopAttrs>(md); | ||
return { | ||
id, | ||
md: extracted.body, | ||
attrs: extracted.attrs, | ||
}; | ||
} |