Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Markdown parsing error due to line breaks in generated HTML #4

Merged
merged 2 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = false
trim_trailing_whitespace = true
charset = utf-8

[*.js]
insert_final_newline = true
35 changes: 13 additions & 22 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
module.exports = function( eleventyConfig, pluginNamespace ) {
eleventyConfig.namespace( pluginNamespace, () => {

eleventyConfig.addShortcode( 'respimg', function( src, alt, sizes ) {

const fetchBase = `https://res.cloudinary.com/${ eleventyConfig.cloudinaryCloudName }/image/fetch/`;

return `<img
srcset="${
eleventyConfig.srcsetWidths.map( ( w ) => {
return `${ fetchBase }q_auto,f_auto,w_${ w }/${ src } ${ w }w`
} ).join( ', ' )
}"
sizes="${ sizes ? sizes : '100vw' }"
src="${ fetchBase }q_auto,f_auto,w_${ eleventyConfig.fallbackWidth }/${ src }"
${ alt ? `alt="${ alt }"` : '' }
/>`;

} );

} );
};
module.exports = function (eleventyConfig, pluginNamespace) {
eleventyConfig.namespace(pluginNamespace, () => {
eleventyConfig.addShortcode('respimg', (path, alt, sizes) => {
const fetchBase = `https://res.cloudinary.com/${eleventyConfig.cloudinaryCloudName}/image/fetch/`;
const src = `${fetchBase}q_auto,f_auto,w_${eleventyConfig.fallbackWidth}/${path}`;
const srcset = eleventyConfig.srcsetWidths.map(w => {
return `${fetchBase}q_auto,f_auto,w_${w}/${path} ${w}w`;
}).join(', ');

return `<img src="${src}" srcset="${srcset}" sizes="${sizes ? sizes : '100vw'}" alt="${alt ? alt : ''}">`;
});
});
};