-
Notifications
You must be signed in to change notification settings - Fork 6
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
9574033
commit 2992484
Showing
2 changed files
with
42 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,10 @@ | ||
--- | ||
customCatalog: | ||
schemas: | ||
- name: "Job Postings" | ||
fileMatch: ["pages/jointts/positions/*.md"] | ||
location: "_schemas/job-posting.json" | ||
parser: "md" | ||
|
||
plugins: | ||
- "file:./plugins/v8r-plugin-markdown-parser.js" |
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,32 @@ | ||
import { BasePlugin, Document } from "v8r"; | ||
import yaml from "js-yaml"; | ||
import brainmatter from "brainmatter"; | ||
|
||
class MarkdownParser extends BasePlugin { | ||
static name = "v8r-plugin-markdown-parser"; | ||
|
||
registerInputFileParsers() { | ||
console.log("Registering md file parser"); | ||
return ["md"]; | ||
} | ||
|
||
parseInputFile(contents, fileLocation, parser) { | ||
const brainmatter = require('brainmatter'); | ||
const { html, data } = brainmatter(contents); | ||
|
||
console.log("In parseInputFile"); | ||
|
||
if (parser === "md") { | ||
console.log("parser===md"); | ||
return yaml.loadAll(data).map((doc) => new Document(doc)); | ||
} else if (parser == null) { | ||
if (fileLocation.endsWith(".md") { | ||
console.log("endsWith .md"); | ||
return yaml.loadAll(contents).map((doc) => new Document(doc)); | ||
} | ||
} | ||
console.log("fell through tests"); | ||
} | ||
} | ||
|
||
export default MarkdownParser; |