summaryrefslogtreecommitdiffstats
path: root/lib/output/modifiers/inlineAssets.js
blob: 7cd874b54126b558beead051a4ec3668d5735fbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
var svgToImg = require('./svgToImg');
var svgToPng = require('./svgToPng');
var inlinePng = require('./inlinePng');
var resolveImages = require('./resolveImages');
var fetchRemoteImages = require('./fetchRemoteImages');

var Promise = require('../../utils/promise');

/**
    Inline all assets in a page

    @param {String} rootFolder
*/
function inlineAssets(rootFolder, currentFile) {
    return function($) {
        return Promise()

        // Resolving images and fetching external images should be
        // done before svg conversion
        .then(resolveImages.bind(null, currentFile, $))
        .then(fetchRemoteImages.bind(null, rootFolder, currentFile, $))

        .then(svgToImg.bind(null, rootFolder, currentFile, $))
        .then(svgToPng.bind(null, rootFolder, currentFile, $))
        .then(inlinePng.bind(null, rootFolder, currentFile, $));
    };
}

module.exports = inlineAssets;