Files
blog/markdoc.config.mjs
Dave 3dec403492
Some checks failed
Build and Deploy DAVE | DMGs Site / deploy (push) Failing after 3m22s
Try deploy
2026-03-05 11:39:28 +01:00

91 lines
1.9 KiB
JavaScript

import {
defineMarkdocConfig,
component,
nodes,
Markdoc,
} from '@astrojs/markdoc/config';
export default defineMarkdocConfig({
nodes: {
table: {
...nodes.table,
render: component('./src/components/markdoc/Table.astro'),
},
},
tags: {
ElementSymbol: {
render: component('./src/components/content/ElementSymbol.astro'),
attributes: {
element: { type: String },
size: { type: String },
color: { type: String },
},
},
Callout: {
render: component('./src/components/content/Callout.astro'),
attributes: {
type: {
type: String,
default: 'default',
},
title: { type: String },
},
},
Figure: {
render: component('./src/components/content/Figure.astro'),
selfClosing: true,
attributes: {
src: {
type: String,
required: true,
},
alt: {
type: String,
required: true,
},
caption: { type: String },
credit: { type: String },
},
},
Sidenote: {
selfClosing: true,
attributes: {
id: {
type: String,
required: true,
},
title: {
type: String,
},
marker: {
type: String,
default: '⋄',
},
content: {
type: String,
required: true,
},
type: {
type: String,
default: 'default',
},
},
transform(node, config) {
const attrs = node.transformAttributes(config);
return new Markdoc.Tag('sup', {}, [
new Markdoc.Tag(
'a',
{
href: `#${attrs.id}`,
id: `ref-${attrs.id}`,
class: 'sidenote-ref',
style: `anchor-name: --note-${attrs.id}`,
},
[`[${attrs.marker}]`],
),
]);
},
},
},
});