Epub: Basics for epub generation (use of an internal bootstrap copy, fixed minor html errors, added dependencies, added step in build)
This commit is contained in:
parent
4d7aab58da
commit
10b2f9e290
6 changed files with 61 additions and 12 deletions
44
build.js
44
build.js
|
@ -91,6 +91,7 @@ metalsmith(__dirname)
|
|||
.use(tags(require('./config/tags')))
|
||||
.use(layouts(require('./config/layouts')))
|
||||
.use(copyVendor())
|
||||
.use(epubGen())
|
||||
.destination('build')
|
||||
.build(function (err) {
|
||||
if (err) {
|
||||
|
@ -98,8 +99,40 @@ metalsmith(__dirname)
|
|||
}
|
||||
})
|
||||
|
||||
function addCategory() {
|
||||
function epubGen() {
|
||||
var fs = require('fs');
|
||||
var epubGenerator = require('epub-generator');
|
||||
|
||||
return function(files, metalsmith, done) {
|
||||
var epubStream = epubGenerator({
|
||||
title: 'Hello World',
|
||||
author: 'LastLeaf'
|
||||
});
|
||||
|
||||
for (var f in files) {
|
||||
if (files[f].type == 'recette') {
|
||||
epubStream.add(f, files[f].contents, {
|
||||
title: files[f].data.title,
|
||||
toc: true
|
||||
});
|
||||
} else if (files[f].type == 'style') {
|
||||
epubStream.add(f, files[f].contents, {
|
||||
toc: false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
epubStream.end()
|
||||
.pipe( fs.createWriteStream('basic.epub') )
|
||||
.on('error', function(err){
|
||||
console.trace(err);
|
||||
});
|
||||
|
||||
return done();
|
||||
}
|
||||
}
|
||||
|
||||
function addCategory() {
|
||||
return function(files, metalsmith, done) {
|
||||
|
||||
for (var f in files) {
|
||||
|
@ -141,9 +174,14 @@ function copyVendor() {
|
|||
|
||||
return function(files, metalsmith, done){
|
||||
|
||||
var bufferMoment = fs.readFileSync('styles/customHighlight.css');
|
||||
files['styles/customHighlight.css'] = {
|
||||
contents: bufferMoment
|
||||
contents: fs.readFileSync('styles/customHighlight.css'),
|
||||
type: 'style'
|
||||
};
|
||||
|
||||
files['styles/bootstrap.min.css'] = {
|
||||
contents: fs.readFileSync('styles/bootstrap.min.css'),
|
||||
type: 'style'
|
||||
};
|
||||
|
||||
return done();
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
"private": true,
|
||||
"dependencies": {
|
||||
"bower": "^1.5.2",
|
||||
"epub-generator": "^1.0.1",
|
||||
"handlebars": "^3.0.3",
|
||||
"handlebars-layouts": "^3.1.0",
|
||||
"highlight.js": "^9.4.0",
|
||||
|
|
6
styles/bootstrap.min.css
vendored
Normal file
6
styles/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -28,9 +28,12 @@
|
|||
|
||||
.content-title {
|
||||
border-bottom: solid 1px;
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
|
||||
.header-metadata {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.header-container {
|
||||
font-size: smaller;
|
||||
}
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
||||
<script src="http://localhost:35729/livereload.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/default.min.css">
|
||||
<link rel="stylesheet" href="/styles/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="/styles/customHighlight.css">
|
||||
|
||||
<link rel="stylesheet" href="../styles/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="../styles/customHighlight.css">
|
||||
|
||||
<title>{{#block "title"}} {{/block}}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<h1 class="content-title">
|
||||
Recette {{ data.title }}
|
||||
</h1>
|
||||
<small class="header-container row">
|
||||
<div class="header-container row">
|
||||
<div class="header-category col-sm-4">
|
||||
<a href="/tags/{{ category }}/">{{ category }}</a>
|
||||
</div>
|
||||
|
@ -30,7 +30,7 @@
|
|||
{{ data.portion }}
|
||||
{{#if data.time }} • {{ data.time }}{{/if }}
|
||||
</div>
|
||||
</small>
|
||||
</div>
|
||||
</header>
|
||||
<section class="content">
|
||||
{{#each data.steps }}
|
||||
|
@ -58,7 +58,7 @@
|
|||
{{{ contents }}}
|
||||
</section>
|
||||
|
||||
<comments>
|
||||
<section class="comments">
|
||||
<h2>Commentaires</h2>
|
||||
<div id="disqus_thread"></div>
|
||||
<script>
|
||||
|
@ -72,7 +72,7 @@
|
|||
})();
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
|
||||
</comments>
|
||||
</section>
|
||||
{{/ content}}
|
||||
|
||||
{{/ extend}}
|
||||
|
|
Loading…
Add table
Reference in a new issue