-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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: import local plugins into markdown #2534
Conversation
🦋 Changeset detectedLatest commit: 12e2aee The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
✔️ Deploy Preview for astro-docs-2 ready! 🔨 Explore the source changes: 9c1ec9a 🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61fc66d8c7850500080af77c 😎 Browse the preview: https://deploy-preview-2534--astro-docs-2.netlify.app |
✔️ Deploy Preview for astro-docs-2 ready! 🔨 Explore the source changes: a593809 🔍 Inspect the deploy log: https://app.netlify.com/sites/astro-docs-2/deploys/61fc6ae2746f600008dd5a00 😎 Browse the preview: https://deploy-preview-2534--astro-docs-2.netlify.app |
@@ -2,6 +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'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you possibly copy this module into the test fixture? Would be nice to not couple the tests with the examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I also added hast-util-select
as a dev dependency to ensure it's installed for the tests
* Replaced "UnifiedPluginImport" for a function * Updated tests * Updated docs * Updated examples * Added changeset * Fixed tests * Removed unused "UnifiedPluginImport" * Duplicated add-classes.mjs
Changes
Fixes #2097
Importing local plugins into markdown has been tedious, because you need to use weird syntax:
Also, the example in the documentation doesn't work: #2097
So, I replaced the input to expect a function instead of the result of an import:
This way you can pass any function that is a unified plugin no matter where you get it. Plus, this isn't breaking because, well,
import
didn't work 😅Testing
yarn test:match "plugins"
Docs
Adding a Markdown plugin