Files
les-briques-du-web-website/_includes/shortcodes/inline-css.js
Horacio Gonzalez 286a9d0d93 Initial commit
2021-05-05 11:22:00 +02:00

33 lines
994 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file Defines a shortcode for loading inline stylesheets
* @author Reuben L. Lillie <reubenlillie@gmail.com>
*/
/**
* A JavaScript Template module for the inline CSS `links`
* @module _includes/shortcodes/inline-css
* @param {Object} eleventyConfig 11tys Config API
*/
export default eleventyConfig =>
/**
* HTML `<style>` markup
* @method
* @name inlineCSS
* @param {Object} data 11tys data object
* @return {String} The rendered shortcode
* @example `${this.inlineCSS(data)}`
* @see {@link https://www.11ty.dev/docs/data/ Using data in 11ty}
*/
eleventyConfig.addShortcode('inlineCSS', function (data) {
var root = `${this.cssRoot(data)}`
var css = `${this.fileToString('css/index.css')}`;
(data.page.url === '/')
? css += `${this.fileToString('css/home.css')}`
: '';
(data.form && data.form !== undefined)
? css += `${this.fileToString('css/forms.css')}`
: css += '';
return `${root}\n${css}`
})