diff --git a/packages/integrations/markdoc/src/config.ts b/packages/integrations/markdoc/src/config.ts index 1a20b7431..f8943ba1a 100644 --- a/packages/integrations/markdoc/src/config.ts +++ b/packages/integrations/markdoc/src/config.ts @@ -1,6 +1,6 @@ import type { ConfigType as MarkdocConfig } from '@markdoc/markdoc'; -import { nodes as astroNodes } from './nodes/index.js'; import _Markdoc from '@markdoc/markdoc'; +import { nodes as astroNodes } from './nodes/index.js'; export const Markdoc = _Markdoc; export const nodes = { ...Markdoc.nodes, ...astroNodes }; diff --git a/packages/integrations/markdoc/src/index.ts b/packages/integrations/markdoc/src/index.ts index 65f81644a..0ae1f1fad 100644 --- a/packages/integrations/markdoc/src/index.ts +++ b/packages/integrations/markdoc/src/index.ts @@ -9,8 +9,8 @@ import { isValidUrl, MarkdocError, parseFrontmatter, prependForwardSlash } from import { emitESMImage } from 'astro/assets'; import { bold, red, yellow } from 'kleur/colors'; import type * as rollup from 'rollup'; -import { applyDefaultConfig } from './runtime.js'; import { loadMarkdocConfig, type MarkdocConfigResult } from './load-config.js'; +import { applyDefaultConfig } from './runtime.js'; type SetupHookParams = HookParameters<'astro:config:setup'> & { // `contentEntryType` is not a public API @@ -103,7 +103,9 @@ ${ ? `\nimport { experimentalAssetsConfig } from '@astrojs/markdoc/experimental-assets-config';\nuserConfig.nodes = { ...experimentalAssetsConfig.nodes, ...userConfig.nodes };` : '' } -const stringifiedAst = ${JSON.stringify(/* Double stringify to encode *as* stringified JSON */ JSON.stringify(ast))}; +const stringifiedAst = ${JSON.stringify( + /* Double stringify to encode *as* stringified JSON */ JSON.stringify(ast) + )}; export function getHeadings() { ${ /* Yes, we are transforming twice (once from `getHeadings()` and again from in case of variables). diff --git a/packages/integrations/markdoc/src/nodes/heading.ts b/packages/integrations/markdoc/src/nodes/heading.ts index 81a9181c7..8adf57612 100644 --- a/packages/integrations/markdoc/src/nodes/heading.ts +++ b/packages/integrations/markdoc/src/nodes/heading.ts @@ -1,8 +1,8 @@ import Markdoc, { type RenderableTreeNode, type Schema } from '@markdoc/markdoc'; -import { getTextContent } from '../runtime.js'; import Slugger from 'github-slugger'; +import { getTextContent } from '../runtime.js'; -export const headingSlugger = new Slugger(); +export const headingSlugger = new Slugger(); function getSlug(attributes: Record, children: RenderableTreeNode[]): string { if (attributes.id && typeof attributes.id === 'string') { @@ -25,7 +25,6 @@ export const heading: Schema = { const { level, ...attributes } = node.transformAttributes(config); const children = node.transformChildren(config); - const slug = getSlug(attributes, children); const render = config.nodes?.heading?.render ?? `h${level}`; diff --git a/packages/integrations/markdoc/src/runtime.ts b/packages/integrations/markdoc/src/runtime.ts index dadb73cd6..61b38fd02 100644 --- a/packages/integrations/markdoc/src/runtime.ts +++ b/packages/integrations/markdoc/src/runtime.ts @@ -1,14 +1,14 @@ import type { MarkdownHeading } from '@astrojs/markdown-remark'; import Markdoc, { - type RenderableTreeNode, type ConfigType as MarkdocConfig, + type RenderableTreeNode, } from '@markdoc/markdoc'; import type { ContentEntryModule } from 'astro'; import { nodes as astroNodes } from './nodes/index.js'; /** Used to reset Slugger cache on each build at runtime */ -export { headingSlugger } from './nodes/index.js'; export { default as Markdoc } from '@markdoc/markdoc'; +export { headingSlugger } from './nodes/index.js'; export function applyDefaultConfig( config: MarkdocConfig,