@astrojs/markdoc 0.0.1 → 0.0.3

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/markdoc:build: cache hit, replaying output a0f6fc6f4f62084c
2
- @astrojs/markdoc:build: 
3
- @astrojs/markdoc:build: > @astrojs/markdoc@0.0.1 build /home/runner/work/astro/astro/packages/integrations/markdoc
4
- @astrojs/markdoc:build: > astro-scripts build "src/**/*.ts" && tsc
5
- @astrojs/markdoc:build: 
1
+ @astrojs/markdoc:build: cache hit, replaying output 30bf30e6debacf79
2
+ @astrojs/markdoc:build: 
3
+ @astrojs/markdoc:build: > @astrojs/markdoc@0.0.3 build /home/runner/work/astro/astro/packages/integrations/markdoc
4
+ @astrojs/markdoc:build: > astro-scripts build "src/**/*.ts" && tsc
5
+ @astrojs/markdoc:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @astrojs/markdoc
2
2
 
3
+ ## 0.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#6552](https://github.com/withastro/astro/pull/6552) [`392ba3e4d`](https://github.com/withastro/astro/commit/392ba3e4d55f73ce9194bd94a2243f1aa62af079) Thanks [@bluwy](https://github.com/bluwy)! - Fix integration return type
8
+
9
+ ## 0.0.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [#6494](https://github.com/withastro/astro/pull/6494) [`a13e9d7e3`](https://github.com/withastro/astro/commit/a13e9d7e33baccf51e7d4815f99b481ad174bc57) Thanks [@Yan-Thomas](https://github.com/Yan-Thomas)! - Consistency improvements to several package descriptions
14
+
3
15
  ## 0.0.1
4
16
 
5
17
  ### Patch Changes
package/README.md CHANGED
@@ -113,21 +113,21 @@ import markdoc from '@astrojs/markdoc';
113
113
 
114
114
  // https://astro.build/config
115
115
  export default defineConfig({
116
- integrations: [
117
- markdoc({
118
- tags: {
119
- aside: {
120
- render: 'Aside',
116
+ integrations: [
117
+ markdoc({
118
+ tags: {
119
+ aside: {
120
+ render: 'Aside',
121
121
  attributes: {
122
122
  // Component props as attribute definitions
123
123
  // See Markdoc's documentation on defining attributes
124
124
  // https://markdoc.dev/docs/attributes#defining-attributes
125
125
  type: { type: String },
126
126
  }
127
- },
128
- },
129
- }),
130
- ],
127
+ },
128
+ },
129
+ }),
130
+ ],
131
131
  });
132
132
  ```
133
133
 
@@ -159,11 +159,11 @@ import markdoc from '@astrojs/markdoc';
159
159
 
160
160
  // https://astro.build/config
161
161
  export default defineConfig({
162
- integrations: [
163
- markdoc({
164
- nodes: {
165
- heading: {
166
- render: 'Heading',
162
+ integrations: [
163
+ markdoc({
164
+ nodes: {
165
+ heading: {
166
+ render: 'Heading',
167
167
  // Markdoc requires type defs for each attribute.
168
168
  // These should mirror the `Props` type of the component
169
169
  // you are rendering.
@@ -172,10 +172,10 @@ export default defineConfig({
172
172
  attributes: {
173
173
  level: { type: String },
174
174
  }
175
- },
176
- },
177
- }),
178
- ],
175
+ },
176
+ },
177
+ }),
178
+ ],
179
179
  });
180
180
  ```
181
181
 
@@ -218,7 +218,7 @@ import Aside from './Aside';
218
218
  <Aside client:load />
219
219
  ```
220
220
 
221
- This component [can be applied via the `components` prop](#render-html-elements-as-astro-components):
221
+ This component [can be applied via the `components` prop](#render-markdoc-nodes--html-elements-as-astro-components):
222
222
 
223
223
  ```astro
224
224
  ---
@@ -277,7 +277,7 @@ Now, you can call this function from any Markdoc content entry:
277
277
  ```
278
278
 
279
279
  :::note
280
- These options will be applied during [the Markdoc "transform" phase](https://markdoc.dev/docs/render#transform). This is run **at build time** (rather than server request time) both for static and SSR Astro projects. If you need to define configuration at runtime (ex. SSR variables), [see the next section](#Define-markdoc-configuration-at-runtime).
280
+ These options will be applied during [the Markdoc "transform" phase](https://markdoc.dev/docs/render#transform). This is run **at build time** (rather than server request time) both for static and SSR Astro projects. If you need to define configuration at runtime (ex. SSR variables), [see the next section](#define-markdoc-configuration-at-runtime).
281
281
  :::
282
282
 
283
283
  📚 [See the Markdoc documentation](https://markdoc.dev/docs/functions#creating-a-custom-function) for more on using variables or functions in your content.
package/dist/index.d.ts CHANGED
@@ -1,12 +1,3 @@
1
1
  import type { Config } from '@markdoc/markdoc';
2
- import type { AstroIntegration, ContentEntryType, HookParameters } from 'astro';
3
- declare type IntegrationWithPrivateHooks = {
4
- name: string;
5
- hooks: Omit<AstroIntegration['hooks'], 'astro:config:setup'> & {
6
- 'astro:config:setup': (params: HookParameters<'astro:config:setup'> & {
7
- addContentEntryType: (contentEntryType: ContentEntryType) => void;
8
- }) => void | Promise<void>;
9
- };
10
- };
11
- export default function markdoc(markdocConfig?: Config): IntegrationWithPrivateHooks;
12
- export {};
2
+ import type { AstroIntegration } from 'astro';
3
+ export default function markdoc(markdocConfig?: Config): AstroIntegration;
package/dist/index.js CHANGED
@@ -11,7 +11,8 @@ function markdoc(markdocConfig = {}) {
11
11
  return {
12
12
  name: "@astrojs/markdoc",
13
13
  hooks: {
14
- "astro:config:setup": async ({ updateConfig, config, addContentEntryType }) => {
14
+ "astro:config:setup": async (params) => {
15
+ const { updateConfig, config, addContentEntryType } = params;
15
16
  function getEntryInfo({ fileUrl, contents }) {
16
17
  const parsed = parseFrontmatter(contents, fileURLToPath(fileUrl));
17
18
  return {
@@ -38,6 +39,7 @@ function markdoc(markdocConfig = {}) {
38
39
  return;
39
40
  validateRenderProperties(markdocConfig, config);
40
41
  const body = getEntryInfo({
42
+ // Can't use `pathToFileUrl` - Vite IDs are not plain file paths
41
43
  fileUrl: new URL(prependForwardSlash(id), "file://"),
42
44
  contents: code
43
45
  }).body;
package/dist/utils.js CHANGED
@@ -22,6 +22,8 @@ class MarkdocError extends Error {
22
22
  super(...params);
23
23
  this.type = "MarkdocError";
24
24
  const {
25
+ // Use default code for unknown errors in Astro core
26
+ // We don't have a best practice for integration error codes yet
25
27
  code = 99999,
26
28
  name,
27
29
  title = "MarkdocError",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/markdoc",
3
- "description": "Use Markdoc within Astro",
4
- "version": "0.0.1",
3
+ "description": "Add support for Markdoc pages in your Astro site",
4
+ "version": "0.0.3",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -33,7 +33,7 @@
33
33
  "@types/chai": "^4.3.1",
34
34
  "@types/html-escaper": "^3.0.0",
35
35
  "@types/mocha": "^9.1.1",
36
- "astro": "2.1.0",
36
+ "astro": "2.1.4",
37
37
  "astro-scripts": "0.0.14",
38
38
  "chai": "^4.3.6",
39
39
  "devalue": "^4.2.0",
package/src/index.ts CHANGED
@@ -3,7 +3,7 @@ import Markdoc from '@markdoc/markdoc';
3
3
  import type { AstroConfig, AstroIntegration, ContentEntryType, HookParameters } from 'astro';
4
4
  import fs from 'node:fs';
5
5
  import { fileURLToPath } from 'node:url';
6
- import { InlineConfig } from 'vite';
6
+ import type { InlineConfig } from 'vite';
7
7
  import {
8
8
  getAstroConfigPath,
9
9
  MarkdocError,
@@ -11,24 +11,19 @@ import {
11
11
  prependForwardSlash,
12
12
  } from './utils.js';
13
13
 
14
- type IntegrationWithPrivateHooks = {
15
- name: string;
16
- hooks: Omit<AstroIntegration['hooks'], 'astro:config:setup'> & {
17
- 'astro:config:setup': (
18
- params: HookParameters<'astro:config:setup'> & {
19
- // `contentEntryType` is not a public API
20
- // Add type defs here
21
- addContentEntryType: (contentEntryType: ContentEntryType) => void;
22
- }
23
- ) => void | Promise<void>;
24
- };
14
+ type SetupHookParams = HookParameters<'astro:config:setup'> & {
15
+ // `contentEntryType` is not a public API
16
+ // Add type defs here
17
+ addContentEntryType: (contentEntryType: ContentEntryType) => void;
25
18
  };
26
19
 
27
- export default function markdoc(markdocConfig: Config = {}): IntegrationWithPrivateHooks {
20
+ export default function markdoc(markdocConfig: Config = {}): AstroIntegration {
28
21
  return {
29
22
  name: '@astrojs/markdoc',
30
23
  hooks: {
31
- 'astro:config:setup': async ({ updateConfig, config, addContentEntryType }) => {
24
+ 'astro:config:setup': async (params) => {
25
+ const { updateConfig, config, addContentEntryType } = params as SetupHookParams;
26
+
32
27
  function getEntryInfo({ fileUrl, contents }: { fileUrl: URL; contents: string }) {
33
28
  const parsed = parseFrontmatter(contents, fileURLToPath(fileUrl));
34
29
  return {