Skip to content
This repository has been archived by the owner on Jul 24, 2023. It is now read-only.

Commit

Permalink
feat: namespace and cleanup remark-wrap-images
Browse files Browse the repository at this point in the history
  • Loading branch information
CanRau committed Mar 16, 2019
1 parent d0cfc11 commit 0cbe57a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ module.exports = {
wrapperStyle: f => `flex:${round(f.aspectRatio, 2)};`,
},
},
`gatsby-remark-wrap-images`,
{ resolve: `@gaiama/gatsby-remark-wrap-images` },
{
resolve: `gatsby-remark-responsive-iframe`,
options: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
"devDependencies": {
"@babel/plugin-proposal-optional-chaining": "^7.0.0",
"@gaiama/gatsby-source-gaiama-donations": "^0.1.2",
"@gaiama/gatsby-remark-wrap-images": "0.2.0",
"all-contributors-cli": "5.4.1",
"babel-plugin-console": "0.2.1",
"babel-plugin-preval": "3.0.1",
Expand All @@ -125,7 +126,6 @@
"gatsby-remark-external-links": "0.0.4",
"gatsby-remark-responsive-iframe": "2.0.9",
"gatsby-remark-smartypants": "2.0.8",
"gatsby-remark-wrap-images": "0.1.0",
"gatsby-source-filesystem": "2.0.22",
"gatsby-source-instagram": "0.2.5",
"gatsby-transformer-javascript-frontmatter": "2.0.8",
Expand Down
25 changes: 12 additions & 13 deletions packages/gatsby-remark-wrap-images/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const cheerio = require(`cheerio`)
// const cheerio = require(`cheerio`)
const modifyChildren = require(`unist-util-modify-children`)
const fs = require(`fs`)

module.exports = ({ markdownAST }, pluginOptions) => {
markdownAST.children
Expand Down Expand Up @@ -28,17 +27,17 @@ function modifier(node, index, parent) {
class: `inline-gallery`,
},
}
parent.children.map(x => {
const $ = cheerio.load(x.value)
const imageWithRatio = $(`[data-ratio]`)
if (imageWithRatio) {
if (parent.children.length > 1) {
imageWithRatio.css(`flex`, imageWithRatio.attr(`data-ratio`))
}
imageWithRatio.attr(`data-ratio`, null)
x.value = $(`body`).html()
}
})
// parent.children.map(x => {
// const $ = cheerio.load(x.value)
// const imageWithRatio = $(`[data-ratio]`)
// if (imageWithRatio) {
// if (parent.children.length > 1) {
// imageWithRatio.css(`flex`, imageWithRatio.attr(`data-ratio`))
// }
// imageWithRatio.attr(`data-ratio`, null)
// x.value = $(`body`).html()
// }
// })
parent.children = whitespaceStripped
}

Expand Down
4 changes: 2 additions & 2 deletions packages/gatsby-remark-wrap-images/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "gatsby-remark-wrap-images",
"version": "0.1.0"
"name": "@gaiama/gatsby-remark-wrap-images",
"version": "0.2.0"
}

0 comments on commit 0cbe57a

Please sign in to comment.