Created
November 27, 2017 15:27
-
-
Save adamkiss/0ca016c1363162174d529525a7e614a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extends(src='layout.sgr') | |
block(name='styles' type='append') | |
// normal link | |
link(rel='stylesheet' href='/css/home-hero.css') | |
// function for reshape-content | |
style(inline) /css/home-hero.css | |
// reshape custom element plugin | |
// - url via src attribute | |
style-inline(src='/css/home-hero.css') | |
// - url via text content | |
style-inline /css/home-hero.css | |
block(name='content') | |
p Here is my content |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {modifyNodes} = require('reshape-plugin-util') | |
const fs = require('fs') | |
module.exports = function reshapeStyleInline (options = {}) { | |
return function (tree) { | |
return modifyNodes(tree, (node) => { | |
return (node.type === 'tag' && node.name === 'style-inline') | |
}, (node) => { | |
// you obviously need to translate src='/css/home-whatever.css' to actual path | |
const src = magicalGetToFileFunction(node.attrs.src) | |
node.content = [{type:'text', content: [src]}] | |
return node | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment