mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-07-29 18:19:42 +02:00
Page creation basics (#7)
* Page cration basics * remove unused code * add client-side Header validation * remove static method * rm await duplication
This commit is contained in:
parent
5c0560a2ed
commit
073772c047
17 changed files with 476 additions and 93 deletions
|
@ -67,10 +67,10 @@ class Page {
|
|||
* @param {PageData} pageData
|
||||
*/
|
||||
set data(pageData) {
|
||||
const {title, body, parent} = pageData;
|
||||
const {body, parent} = pageData;
|
||||
|
||||
this.title = title || this.title;
|
||||
this.body = body || this.body;
|
||||
this.title = this.extractTitleFromBody();
|
||||
this._parent = parent || this._parent;
|
||||
}
|
||||
|
||||
|
@ -88,6 +88,16 @@ class Page {
|
|||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract first header from editor data
|
||||
* @return {string}
|
||||
*/
|
||||
extractTitleFromBody() {
|
||||
const headerBlock = this.body ? this.body.blocks.find(block => block.type === 'header') : '';
|
||||
|
||||
return headerBlock ? headerBlock.data.text : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Link given page as parent
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue