generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Kevin Haube
committed
May 26, 2022
1 parent
43d1a5d
commit 05b017c
Showing
6 changed files
with
64 additions
and
110 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
frontend-react/src/components/Markdown/MarkdownDirectory.test.ts
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,20 @@ | ||
import { MarkdownDirectory } from "./MarkdownDirectory"; | ||
|
||
describe("MarkdownDirectory", () => { | ||
const testDir = new MarkdownDirectory({ | ||
title: "Test Dir", | ||
root: "/test/dir", | ||
files: ["testFile.md"], | ||
}); | ||
|
||
test("renders with params", () => { | ||
expect(testDir.title).toEqual("Test Dir"); | ||
expect(testDir.root).toEqual("/test/dir"); | ||
expect(testDir.files).toEqual(["testFile.md"]); | ||
}); | ||
|
||
test("getUrl", () => { | ||
expect(testDir.getUrl("testFile.md")).toEqual("/test/dir/testFile.md"); | ||
expect(testDir.getUrl("noFile.md")).toEqual(undefined); | ||
}); | ||
}); |
34 changes: 34 additions & 0 deletions
34
frontend-react/src/components/Markdown/MarkdownDirectory.ts
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,34 @@ | ||
export interface MarkdownPageProps { | ||
directories: MarkdownDirectory[]; | ||
} | ||
|
||
interface MarkdownDirectoryInit { | ||
title: string; | ||
root: string; | ||
files: string[]; | ||
} | ||
|
||
export class MarkdownDirectory { | ||
title: string; | ||
root: string; | ||
files: string[]; | ||
|
||
constructor({ title, root, files }: MarkdownDirectoryInit) { | ||
this.title = title; | ||
this.root = root; | ||
this.files = files; | ||
} | ||
|
||
getUrl(item: string) { | ||
if (!this.files.includes(item)) return undefined; | ||
return `${this.root}/${item}`; | ||
} | ||
} | ||
|
||
export const MadeForYouDirectories = [ | ||
new MarkdownDirectory({ | ||
title: "March 2022", | ||
root: "/content/made-for-you/2022-march", | ||
files: ["update-2022-03-01.md, update-2022-03-15.md"], | ||
}), | ||
]; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
import { MarkdownPageProps } from "../../components/Markdown/MarkdownDirectory"; | ||
import { MarkdownContent } from "../../components/Markdown/MarkdownContent"; | ||
|
||
const MadeForYou = ({ directories }: MarkdownPageProps) => { | ||
return directories.forEach((dir) => { | ||
dir.files.map((file) => ( | ||
<MarkdownContent markdownUrl={dir.getUrl(file)} /> | ||
)); | ||
}); | ||
}; |