Create titles as markdown entries.
This commit is contained in:
parent
aa30ceb903
commit
c0964709e1
@ -9,6 +9,9 @@ let convertor = new Convertor("./src/data/markdown-it-example.md");
|
|||||||
|
|
||||||
let mdoc: string = convertor.process();
|
let mdoc: string = convertor.process();
|
||||||
|
|
||||||
|
let creation = true;
|
||||||
|
|
||||||
|
if (creation) {
|
||||||
// Configure the client
|
// Configure the client
|
||||||
const api = new GhostAdminAPI({
|
const api = new GhostAdminAPI({
|
||||||
url: "http://localhost:2368",
|
url: "http://localhost:2368",
|
||||||
@ -21,3 +24,4 @@ api.posts
|
|||||||
.add(JSON.parse(mdoc))
|
.add(JSON.parse(mdoc))
|
||||||
.then((response: any) => console.log(JSON.stringify(response)))
|
.then((response: any) => console.log(JSON.stringify(response)))
|
||||||
.catch((error: any) => console.error(error));
|
.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 result: any = undefined;
|
||||||
|
|
||||||
|
if (!headerAsMarkdown) {
|
||||||
|
// Build the header as a <Hx /> tag
|
||||||
let marker = this.builder.createMarker(t.content, []);
|
let marker = this.builder.createMarker(t.content, []);
|
||||||
return this.builder.createMarkupSection(stack[0].tag, [marker]);
|
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