Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev authored and astrobot-houston committed May 17, 2023
1 parent fb84622 commit d4b00b5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/integrations/markdoc/src/config.ts
Original file line number Diff line number Diff line change
@@ -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 };
Expand Down
6 changes: 4 additions & 2 deletions packages/integrations/markdoc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 <Content /> in case of variables).
Expand Down
5 changes: 2 additions & 3 deletions packages/integrations/markdoc/src/nodes/heading.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>, children: RenderableTreeNode[]): string {
if (attributes.id && typeof attributes.id === 'string') {
Expand All @@ -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}`;
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/markdoc/src/runtime.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit d4b00b5

Please sign in to comment.