diff options
author | 2023-01-11 12:51:31 -0500 | |
---|---|---|
committer | 2023-01-11 12:51:31 -0500 | |
commit | 52209ca2ad72a30854947dcb3a90ab4db0ac0a6f (patch) | |
tree | 707b90eee0464eedfa2dbc10d01500c73d6661c7 /packages/markdown/remark/src | |
parent | 665a2c2225e42881f5a9550599e8f3fc1deea0b4 (diff) | |
download | astro-52209ca2ad72a30854947dcb3a90ab4db0ac0a6f.tar.gz astro-52209ca2ad72a30854947dcb3a90ab4db0ac0a6f.tar.zst astro-52209ca2ad72a30854947dcb3a90ab4db0ac0a6f.zip |
[Content collections] Remove experimental flag (#5825)
* refactor: remove experimental.cc from core
* chore: remove experimental flag from tests
* fix: mock contentDir in remark tests
* fix: check vfile.path in rel-image-error plugin
* fix: move .astro/ excludes to all test/fixtures
* fix: include test/**/fixtures in ignore
* chore: changeset
Diffstat (limited to 'packages/markdown/remark/src')
-rw-r--r-- | packages/markdown/remark/src/index.ts | 5 | ||||
-rw-r--r-- | packages/markdown/remark/src/remark-content-rel-image-error.ts | 2 | ||||
-rw-r--r-- | packages/markdown/remark/src/types.ts | 2 |
3 files changed, 3 insertions, 6 deletions
diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index 91680f3fd..fdd669280 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -53,7 +53,6 @@ export async function renderMarkdown( remarkRehype = markdownConfigDefaults.remarkRehype, gfm = markdownConfigDefaults.gfm, smartypants = markdownConfigDefaults.smartypants, - isExperimentalContentCollections = false, contentDir, frontmatter: userFrontmatter = {}, } = opts; @@ -91,9 +90,7 @@ export async function renderMarkdown( } // Apply later in case user plugins resolve relative image paths - if (isExperimentalContentCollections) { - parser.use([toRemarkContentRelImageError({ contentDir })]); - } + parser.use([toRemarkContentRelImageError({ contentDir })]); parser.use([ [ diff --git a/packages/markdown/remark/src/remark-content-rel-image-error.ts b/packages/markdown/remark/src/remark-content-rel-image-error.ts index 1a0870c22..3e3664b20 100644 --- a/packages/markdown/remark/src/remark-content-rel-image-error.ts +++ b/packages/markdown/remark/src/remark-content-rel-image-error.ts @@ -10,6 +10,8 @@ import type { VFile } from 'vfile'; export default function toRemarkContentRelImageError({ contentDir }: { contentDir: URL }) { return function remarkContentRelImageError() { return (tree: any, vfile: VFile) => { + if (typeof vfile?.path !== 'string') return; + const isContentFile = pathToFileURL(vfile.path).href.startsWith(contentDir.href); if (!isContentFile) return; diff --git a/packages/markdown/remark/src/types.ts b/packages/markdown/remark/src/types.ts index 40b2ac841..ff3060704 100644 --- a/packages/markdown/remark/src/types.ts +++ b/packages/markdown/remark/src/types.ts @@ -59,8 +59,6 @@ export interface MarkdownRenderingOptions extends AstroMarkdownOptions { scopedClassName: string | null; }; /** Used to prevent relative image imports from `src/content/` */ - isExperimentalContentCollections?: boolean; - /** Used to prevent relative image imports from `src/content/` */ contentDir: URL; /** Used for frontmatter injection plugins */ frontmatter?: Record<string, any>; |