mirror of
https://github.com/nature-of-code/noc-book-2
synced 2024-11-17 07:49:05 +01:00
Merge pull request #509 from nature-of-code/dev/add-chapter-opening-only-build
This commit is contained in:
commit
a4ec039e3c
2 changed files with 32 additions and 23 deletions
|
@ -11,10 +11,10 @@
|
|||
"magicbook/plugins/chapter-opening.js",
|
||||
"magicbook/plugins/callout.js"
|
||||
],
|
||||
"destination": "build",
|
||||
"files": [
|
||||
"content/*.html"
|
||||
],
|
||||
"layout": "magicbook/layouts/pdf.html",
|
||||
"images": {
|
||||
"colorspace": "grey16",
|
||||
"files": [
|
||||
|
@ -23,19 +23,24 @@
|
|||
"magicbook/images/**/*.*"
|
||||
]
|
||||
},
|
||||
"stylesheets": {
|
||||
"files": [
|
||||
"magicbook/stylesheets/index.scss"
|
||||
]
|
||||
},
|
||||
"fonts": {
|
||||
"files": "magicbook/fonts/**/*.*",
|
||||
"destination": "assets/fonts/"
|
||||
},
|
||||
"builds": [
|
||||
{
|
||||
"format": "pdf",
|
||||
"layout": "magicbook/layouts/pdf.html",
|
||||
"stylesheets": {
|
||||
"files": [
|
||||
"magicbook/stylesheets/index.scss"
|
||||
]
|
||||
},
|
||||
"fonts": {
|
||||
"files": "magicbook/fonts/**/*.*",
|
||||
"destination": "assets/fonts/"
|
||||
}
|
||||
"destination": "build/chapter-opening-preview",
|
||||
"chapterOpeningPagesOnly": true
|
||||
},
|
||||
{
|
||||
"format": "pdf",
|
||||
"destination": "build/full"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -19,23 +19,27 @@ Plugin.prototype = {
|
|||
|
||||
// match the number and name
|
||||
const match = /(\d+)\.\s([A-Za-z\s]+)/.exec(chapterTitle.text());
|
||||
if (match) {
|
||||
chapterTitle.replaceWith(
|
||||
`<div class="chapter-opening"><div class="chapter-opening-header"><span class="chapter-number">${match[1]}</span><div class="chapter-opening-title"><h1>${match[2]}</h1></div></div></div>`,
|
||||
);
|
||||
|
||||
chapterTitle.replaceWith(
|
||||
`<div class="chapter-opening"><div class="chapter-opening-header"><span class="chapter-number">${match[1]}</span><div class="chapter-opening-title"><h1>${match[2]}</h1></div></div></div>`,
|
||||
);
|
||||
// if chapter-opening-quote exist
|
||||
const chapterOpeningQuote = file.$el('div.chapter-opening-quote');
|
||||
if (chapterOpeningQuote) {
|
||||
file.$el('div.chapter-opening-title').append(chapterOpeningQuote);
|
||||
}
|
||||
|
||||
// if chapter-opening-quote exist
|
||||
const chapterOpeningQuote = file.$el('div.chapter-opening-quote');
|
||||
if (chapterOpeningQuote) {
|
||||
file.$el('div.chapter-opening-title').append(chapterOpeningQuote);
|
||||
// if chapter-opening-figure exist
|
||||
const chapterOpeningFigure = file.$el('div.chapter-opening-figure');
|
||||
if (chapterOpeningFigure) {
|
||||
file.$el('div.chapter-opening').append(chapterOpeningFigure);
|
||||
}
|
||||
}
|
||||
|
||||
// if chapter-opening-figure exist
|
||||
const chapterOpeningFigure = file.$el('div.chapter-opening-figure');
|
||||
if (chapterOpeningFigure) {
|
||||
file.$el('div.chapter-opening').append(chapterOpeningFigure);
|
||||
if (config.chapterOpeningPagesOnly) {
|
||||
file.$el('div.chapter-opening').nextAll().remove();
|
||||
}
|
||||
|
||||
cb(null, file);
|
||||
}),
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue