Skip to content

Commit

Permalink
Duplicated add-classes.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanM04 committed Feb 4, 2022
1 parent 7b6eb59 commit 12e2aee
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"@types/yargs-parser": "^20.2.1",
"chai": "^4.3.4",
"cheerio": "^1.0.0-rc.10",
"hast-util-select": "^5.0.1",
"mocha": "^9.1.3",
"vite": "~2.6.10"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/test/astro-markdown-plugins.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { expect } from 'chai';
import cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
import markdownRemark from '@astrojs/markdown-remark';
import addClasses from '../../../examples/with-markdown-plugins/add-classes.mjs';
import addClasses from './fixtures/astro-markdown-plugins/add-classes.mjs';

describe('Astro Markdown plugins', () => {
let fixture;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { selectAll } from 'hast-util-select';

export default (additions) => {
const adders = Object.entries(additions).map(adder);
return (node) => adders.forEach((a) => a(node));
};

const adder = ([selector, className]) => {
const writer = write(className);
return (node) => selectAll(selector, node).forEach(writer);
};

const write =
(className) =>
({ properties }) => {
if (!properties.className) properties.className = className;
else properties.className += ` ${className}`;
};
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4978,7 +4978,7 @@ hast-util-raw@^7.2.0:
web-namespaces "^2.0.0"
zwitch "^2.0.0"

[email protected]:
[email protected], hast-util-select@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/hast-util-select/-/hast-util-select-5.0.1.tgz#ed3788ad1a8d2d7f16a6bf8153ce9378edbe9d6d"
integrity sha512-cxnImmR/tN/ipvbwGrKtEErmy83K1xWx8Bu7nImiwTOJ7X/fW1X6L1241ux+MYUXDwx8GxrE4LVmXRlEnbQsQA==
Expand Down

0 comments on commit 12e2aee

Please sign in to comment.