Create titles as markdown entries.
This commit is contained in:
parent
aa30ceb903
commit
c0964709e1
@ -9,15 +9,19 @@ let convertor = new Convertor("./src/data/markdown-it-example.md");
|
|||||||
|
|
||||||
let mdoc: string = convertor.process();
|
let mdoc: string = convertor.process();
|
||||||
|
|
||||||
// Configure the client
|
let creation = true;
|
||||||
const api = new GhostAdminAPI({
|
|
||||||
url: "http://localhost:2368",
|
|
||||||
// Admin API key goes here
|
|
||||||
key: "62ac6f5ab1479d0001082bd4:73341f843a5be78647c6f7e47d43d6cb09ec323df6d5706915df4685b3d46ce7",
|
|
||||||
version: "v4.0",
|
|
||||||
});
|
|
||||||
|
|
||||||
api.posts
|
if (creation) {
|
||||||
.add(JSON.parse(mdoc))
|
// Configure the client
|
||||||
.then((response: any) => console.log(JSON.stringify(response)))
|
const api = new GhostAdminAPI({
|
||||||
.catch((error: any) => console.error(error));
|
url: "http://localhost:2368",
|
||||||
|
// Admin API key goes here
|
||||||
|
key: "62ac6f5ab1479d0001082bd4:73341f843a5be78647c6f7e47d43d6cb09ec323df6d5706915df4685b3d46ce7",
|
||||||
|
version: "v4.0",
|
||||||
|
});
|
||||||
|
|
||||||
|
api.posts
|
||||||
|
.add(JSON.parse(mdoc))
|
||||||
|
.then((response: any) => console.log(JSON.stringify(response)))
|
||||||
|
.catch((error: any) => console.error(error));
|
||||||
|
}
|
||||||
|
@ -14,6 +14,8 @@ const renderer: any = Renderer;
|
|||||||
|
|
||||||
const predefinedBlocks = ["blockquote", "table", "bullet_list", "ordered_list"];
|
const predefinedBlocks = ["blockquote", "table", "bullet_list", "ordered_list"];
|
||||||
|
|
||||||
|
const headerAsMarkdown = true;
|
||||||
|
|
||||||
export class Convertor {
|
export class Convertor {
|
||||||
markups: Record<string, any> = {};
|
markups: Record<string, any> = {};
|
||||||
markers: Record<string, any> = {};
|
markers: Record<string, any> = {};
|
||||||
@ -171,9 +173,24 @@ export class Convertor {
|
|||||||
|
|
||||||
private processHeader(stack: Stack[], t: Token): any {
|
private processHeader(stack: Stack[], t: Token): any {
|
||||||
console.log("+++++++++++++++++++++++++++++++++++++++++++++");
|
console.log("+++++++++++++++++++++++++++++++++++++++++++++");
|
||||||
console.log(JSON.stringify(t));
|
console.log(JSON.stringify(stack[0].token));
|
||||||
|
|
||||||
let marker = this.builder.createMarker(t.content, []);
|
let result: any = undefined;
|
||||||
return this.builder.createMarkupSection(stack[0].tag, [marker]);
|
|
||||||
|
if (!headerAsMarkdown) {
|
||||||
|
// Build the header as a <Hx /> tag
|
||||||
|
let marker = this.builder.createMarker(t.content, []);
|
||||||
|
result = this.builder.createMarkupSection(stack[0].tag, [marker]);
|
||||||
|
} else {
|
||||||
|
// build the header as a markdown card
|
||||||
|
let tbuf: string[] = [];
|
||||||
|
if (t.map != null)
|
||||||
|
for (let i = t.map[0]; i < t.map[1]; i++) tbuf.push(this.lines[i]);
|
||||||
|
result = this.builder.createCardSection("markdown", {
|
||||||
|
markdown: tbuf.join("\n"),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user