@astrojs/markdoc 1.0.0-beta.8 → 1.0.0

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.
@@ -3,6 +3,7 @@ import path from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { parseFrontmatter } from "@astrojs/markdown-remark";
5
5
  import Markdoc from "@markdoc/markdoc";
6
+ import { emitClientAsset } from "astro/assets/utils";
6
7
  import { emitImageMetadata } from "astro/assets/utils/node";
7
8
  import { htmlTokenTransform } from "./html/transform/html-token-transform.js";
8
9
  import { setupConfig } from "./runtime.js";
@@ -237,7 +238,8 @@ async function emitOptimizedImages(nodeChildren, ctx) {
237
238
  if (shouldOptimizeImage(node.attributes.src)) {
238
239
  const resolved = await ctx.pluginContext.resolve(node.attributes.src, ctx.filePath);
239
240
  if (resolved?.id && fs.existsSync(new URL(prependForwardSlash(resolved.id), "file://"))) {
240
- const src = await emitImageMetadata(resolved.id, ctx.pluginContext.emitFile);
241
+ const fileEmitter = ctx.pluginContext.meta.watchMode ? void 0 : (opts) => emitClientAsset(ctx.pluginContext, opts);
242
+ const src = await emitImageMetadata(resolved.id, fileEmitter);
241
243
  const fsPath = resolved.id;
242
244
  if (src) {
243
245
  if (ctx.astroConfig.output === "static") {
@@ -90,9 +90,9 @@ function parseInlineStyles(style, options) {
90
90
  }
91
91
  function comment() {
92
92
  const pos = position();
93
- if (FORWARD_SLASH != style.charAt(0) || ASTERISK != style.charAt(1)) return;
93
+ if (FORWARD_SLASH !== style.charAt(0) || ASTERISK !== style.charAt(1)) return;
94
94
  let i = 2;
95
- while (EMPTY_STRING != style.charAt(i) && (ASTERISK != style.charAt(i) || FORWARD_SLASH != style.charAt(i + 1))) {
95
+ while (EMPTY_STRING !== style.charAt(i) && (ASTERISK !== style.charAt(i) || FORWARD_SLASH !== style.charAt(i + 1))) {
96
96
  ++i;
97
97
  }
98
98
  i += 2;
@@ -16,7 +16,7 @@ function htmlTokenTransform(tokenizer, tokens) {
16
16
  if (first.type === "paragraph_open" && second.type === "inline" && third && third.type === "paragraph_close" && Array.isArray(second.children)) {
17
17
  for (const tok of second.children) {
18
18
  if (tok.type === "text") {
19
- if (tok.content.trim() == textBuffer.trim()) {
19
+ if (tok.content.trim() === textBuffer.trim()) {
20
20
  tok.content = textBuffer;
21
21
  }
22
22
  }
package/dist/runtime.js CHANGED
@@ -17,6 +17,7 @@ async function setupConfig(userConfig = {}, options) {
17
17
  if (options?.allowHTML) {
18
18
  merged = mergeConfig(merged, HTML_CONFIG);
19
19
  }
20
+ syncTagNodeAttributes(merged);
20
21
  return merged;
21
22
  }
22
23
  function setupConfigSync(userConfig = {}, options) {
@@ -25,6 +26,7 @@ function setupConfigSync(userConfig = {}, options) {
25
26
  if (options?.allowHTML) {
26
27
  merged = mergeConfig(merged, HTML_CONFIG);
27
28
  }
29
+ syncTagNodeAttributes(merged);
28
30
  return merged;
29
31
  }
30
32
  function mergeConfig(configA, configB) {
@@ -61,6 +63,29 @@ function mergeConfig(configA, configB) {
61
63
  }
62
64
  };
63
65
  }
66
+ function syncTagNodeAttributes(config) {
67
+ const builtinTags = Markdoc.tags;
68
+ const builtinNodes = Markdoc.nodes;
69
+ for (const name of Object.keys(builtinTags)) {
70
+ if (!(name in builtinNodes)) continue;
71
+ const tagSchema = config.tags[name];
72
+ const nodeSchema = config.nodes[name];
73
+ const tagAttrs = tagSchema?.attributes;
74
+ const nodeAttrs = nodeSchema?.attributes;
75
+ if (!tagAttrs && !nodeAttrs) continue;
76
+ const mergedAttrs = { ...tagAttrs, ...nodeAttrs };
77
+ if (tagSchema) {
78
+ config.tags[name] = { ...tagSchema, attributes: mergedAttrs };
79
+ } else {
80
+ config.tags[name] = { ...builtinTags[name], attributes: mergedAttrs };
81
+ }
82
+ if (nodeSchema) {
83
+ config.nodes[name] = { ...nodeSchema, attributes: mergedAttrs };
84
+ } else {
85
+ config.nodes[name] = { ...builtinNodes[name], attributes: mergedAttrs };
86
+ }
87
+ }
88
+ }
64
89
  function transformRespectsRender(transform, configKey) {
65
90
  const source = transform.toString();
66
91
  return source.includes(`config.nodes?.${configKey}?.render`) || source.includes(`config.tags?.${configKey}?.render`);
package/dist/utils.js CHANGED
@@ -26,7 +26,7 @@ function isValidUrl(str) {
26
26
  return false;
27
27
  }
28
28
  }
29
- const componentConfigSymbol = Symbol.for("@astrojs/markdoc/component-config");
29
+ const componentConfigSymbol = /* @__PURE__ */ Symbol.for("@astrojs/markdoc/component-config");
30
30
  function isComponentConfig(value) {
31
31
  return typeof value === "object" && value !== null && componentConfigSymbol in value;
32
32
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/markdoc",
3
3
  "description": "Add support for Markdoc in your Astro site",
4
- "version": "1.0.0-beta.8",
4
+ "version": "1.0.0",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -57,22 +57,22 @@
57
57
  ],
58
58
  "dependencies": {
59
59
  "@markdoc/markdoc": "^0.5.4",
60
- "esbuild": "^0.25.0",
60
+ "esbuild": "^0.27.3",
61
61
  "github-slugger": "^2.0.0",
62
62
  "htmlparser2": "^10.1.0",
63
- "@astrojs/internal-helpers": "0.8.0-beta.0",
64
- "@astrojs/markdown-remark": "7.0.0-beta.5",
65
- "@astrojs/prism": "4.0.0-beta.2"
63
+ "@astrojs/internal-helpers": "0.8.0",
64
+ "@astrojs/markdown-remark": "7.0.0",
65
+ "@astrojs/prism": "4.0.0"
66
66
  },
67
67
  "peerDependencies": {
68
68
  "astro": "^6.0.0-alpha.0"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/markdown-it": "^14.1.2",
72
- "devalue": "^5.6.2",
72
+ "devalue": "^5.6.3",
73
73
  "linkedom": "^0.18.12",
74
74
  "vite": "^7.3.1",
75
- "astro": "6.0.0-beta.8",
75
+ "astro": "6.0.0",
76
76
  "astro-scripts": "0.0.14"
77
77
  },
78
78
  "engines": {