@astrojs/markdown-remark 2.1.3 → 2.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- @astrojs/markdown-remark:build: cache hit, replaying output d62fcf6af591535d
1
+ @astrojs/markdown-remark:build: cache hit, replaying output 8b8e166000163d0b
2
2
  @astrojs/markdown-remark:build: 
3
- @astrojs/markdown-remark:build: > @astrojs/markdown-remark@2.1.3 build /home/runner/work/astro/astro/packages/markdown/remark
3
+ @astrojs/markdown-remark:build: > @astrojs/markdown-remark@2.1.4 build /home/runner/work/astro/astro/packages/markdown/remark
4
4
  @astrojs/markdown-remark:build: > astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json
5
5
  @astrojs/markdown-remark:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @astrojs/markdown-remark
2
2
 
3
+ ## 2.1.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#6824](https://github.com/withastro/astro/pull/6824) [`2511d58d5`](https://github.com/withastro/astro/commit/2511d58d586af080a78e5ef8a63020b3e17770db) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Add support for using optimized and relative images in MDX files with `experimental.assets`
8
+
9
+ - Updated dependencies [[`8539eb164`](https://github.com/withastro/astro/commit/8539eb1643864ae7e0f5a080915cd75535f7101b), [`a9c22994e`](https://github.com/withastro/astro/commit/a9c22994e41f92a586d8946988d29e3c62148778), [`948a6d7be`](https://github.com/withastro/astro/commit/948a6d7be0c76fd1dd8550270bd29821075f799c)]:
10
+ - astro@2.3.0
11
+
3
12
  ## 2.1.3
4
13
 
5
14
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import type { Data, VFile } from 'vfile';
1
+ import type { VFile, VFileData as Data } from 'vfile';
2
2
  import type { MarkdownAstroData } from './types.js';
3
3
  export declare class InvalidAstroDataError extends TypeError {
4
4
  }
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type { AstroMarkdownOptions, MarkdownRenderingOptions, MarkdownRenderingResult } from './types';
2
2
  export { rehypeHeadingIds } from './rehype-collect-headings.js';
3
+ export { remarkCollectImages } from './remark-collect-images.js';
3
4
  export * from './types.js';
4
5
  export declare const markdownConfigDefaults: Omit<Required<AstroMarkdownOptions>, 'drafts'>;
5
6
  /** Shared utility for rendering markdown */
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { toRemarkInitializeAstroData } from "./frontmatter-injection.js";
2
2
  import { loadPlugins } from "./load-plugins.js";
3
3
  import { rehypeHeadingIds } from "./rehype-collect-headings.js";
4
- import toRemarkCollectImages from "./remark-collect-images.js";
4
+ import { remarkCollectImages } from "./remark-collect-images.js";
5
5
  import remarkPrism from "./remark-prism.js";
6
6
  import scopedStyles from "./remark-scoped-styles.js";
7
7
  import remarkShiki from "./remark-shiki.js";
@@ -15,6 +15,7 @@ import { unified } from "unified";
15
15
  import { VFile } from "vfile";
16
16
  import { rehypeImages } from "./rehype-images.js";
17
17
  import { rehypeHeadingIds as rehypeHeadingIds2 } from "./rehype-collect-headings.js";
18
+ import { remarkCollectImages as remarkCollectImages2 } from "./remark-collect-images.js";
18
19
  export * from "./types.js";
19
20
  const markdownConfigDefaults = {
20
21
  syntaxHighlight: "shiki",
@@ -69,7 +70,7 @@ async function renderMarkdown(content, opts) {
69
70
  parser.use([remarkPrism(scopedClassName)]);
70
71
  }
71
72
  if (opts.experimentalAssets) {
72
- parser.use([toRemarkCollectImages()]);
73
+ parser.use([remarkCollectImages]);
73
74
  }
74
75
  }
75
76
  parser.use([
@@ -127,5 +128,6 @@ ${err.message}`;
127
128
  export {
128
129
  markdownConfigDefaults,
129
130
  rehypeHeadingIds2 as rehypeHeadingIds,
131
+ remarkCollectImages2 as remarkCollectImages,
130
132
  renderMarkdown
131
133
  };
@@ -1,2 +1,2 @@
1
1
  import type { MarkdownVFile } from './types';
2
- export default function toRemarkCollectImages(): () => (tree: any, vfile: MarkdownVFile) => Promise<void>;
2
+ export declare function remarkCollectImages(): (tree: any, vfile: MarkdownVFile) => void;
@@ -1,6 +1,6 @@
1
1
  import { visit } from "unist-util-visit";
2
- function toRemarkCollectImages() {
3
- return () => async function(tree, vfile) {
2
+ function remarkCollectImages() {
3
+ return function(tree, vfile) {
4
4
  if (typeof (vfile == null ? void 0 : vfile.path) !== "string")
5
5
  return;
6
6
  const imagePaths = /* @__PURE__ */ new Set();
@@ -23,5 +23,5 @@ function isValidUrl(str) {
23
23
  }
24
24
  }
25
25
  export {
26
- toRemarkCollectImages as default
26
+ remarkCollectImages
27
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/markdown-remark",
3
- "version": "2.1.3",
3
+ "version": "2.1.4",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  "./dist/internal.js": "./dist/internal.js"
18
18
  },
19
19
  "peerDependencies": {
20
- "astro": "^2.2.0"
20
+ "astro": "^2.3.0"
21
21
  },
22
22
  "dependencies": {
23
23
  "@astrojs/prism": "^2.1.0",
@@ -42,10 +42,10 @@
42
42
  "@types/mdast": "^3.0.10",
43
43
  "@types/mocha": "^9.1.1",
44
44
  "@types/unist": "^2.0.6",
45
- "astro-scripts": "0.0.14",
46
45
  "chai": "^4.3.6",
47
46
  "mdast-util-mdx-expression": "^1.3.1",
48
- "mocha": "^9.2.2"
47
+ "mocha": "^9.2.2",
48
+ "astro-scripts": "0.0.14"
49
49
  },
50
50
  "scripts": {
51
51
  "prepublish": "pnpm build",
@@ -1,4 +1,4 @@
1
- import type { Data, VFile } from 'vfile';
1
+ import type { VFile, VFileData as Data } from 'vfile';
2
2
  import type { MarkdownAstroData } from './types.js';
3
3
 
4
4
  function isValidAstroData(obj: unknown): obj is MarkdownAstroData {
package/src/index.ts CHANGED
@@ -8,7 +8,7 @@ import type {
8
8
  import { toRemarkInitializeAstroData } from './frontmatter-injection.js';
9
9
  import { loadPlugins } from './load-plugins.js';
10
10
  import { rehypeHeadingIds } from './rehype-collect-headings.js';
11
- import toRemarkCollectImages from './remark-collect-images.js';
11
+ import { remarkCollectImages } from './remark-collect-images.js';
12
12
  import remarkPrism from './remark-prism.js';
13
13
  import scopedStyles from './remark-scoped-styles.js';
14
14
  import remarkShiki from './remark-shiki.js';
@@ -24,6 +24,7 @@ import { VFile } from 'vfile';
24
24
  import { rehypeImages } from './rehype-images.js';
25
25
 
26
26
  export { rehypeHeadingIds } from './rehype-collect-headings.js';
27
+ export { remarkCollectImages } from './remark-collect-images.js';
27
28
  export * from './types.js';
28
29
 
29
30
  export const markdownConfigDefaults: Omit<Required<AstroMarkdownOptions>, 'drafts'> = {
@@ -96,7 +97,7 @@ export async function renderMarkdown(
96
97
 
97
98
  if (opts.experimentalAssets) {
98
99
  // Apply later in case user plugins resolve relative image paths
99
- parser.use([toRemarkCollectImages()]);
100
+ parser.use([remarkCollectImages]);
100
101
  }
101
102
  }
102
103
 
@@ -2,18 +2,17 @@ import type { Image } from 'mdast';
2
2
  import { visit } from 'unist-util-visit';
3
3
  import type { MarkdownVFile } from './types';
4
4
 
5
- export default function toRemarkCollectImages() {
6
- return () =>
7
- async function (tree: any, vfile: MarkdownVFile) {
8
- if (typeof vfile?.path !== 'string') return;
5
+ export function remarkCollectImages() {
6
+ return function (tree: any, vfile: MarkdownVFile) {
7
+ if (typeof vfile?.path !== 'string') return;
9
8
 
10
- const imagePaths = new Set<string>();
11
- visit(tree, 'image', (node: Image) => {
12
- if (shouldOptimizeImage(node.url)) imagePaths.add(node.url);
13
- });
9
+ const imagePaths = new Set<string>();
10
+ visit(tree, 'image', (node: Image) => {
11
+ if (shouldOptimizeImage(node.url)) imagePaths.add(node.url);
12
+ });
14
13
 
15
- vfile.data.imagePaths = imagePaths;
16
- };
14
+ vfile.data.imagePaths = imagePaths;
15
+ };
17
16
  }
18
17
 
19
18
  function shouldOptimizeImage(src: string) {