mirror of
https://github.com/sern-handler/website
synced 2026-06-24 16:52:22 +00:00
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
import { renderSlot } from 'astro/runtime/server/index.js'
|
|
import { markdown } from './markdown.js'
|
|
|
|
export const Markdown = Object.assign(
|
|
function Markdown(result, attributes, slots) {
|
|
return {
|
|
get [Symbol.toStringTag]() {
|
|
return 'AstroComponent'
|
|
},
|
|
async *[Symbol.asyncIterator]() {
|
|
const mdl = attributes.of
|
|
|
|
if (typeof mdl === 'string') {
|
|
yield await markdown(mdl, {
|
|
fileURL: new URL(import.meta.url),
|
|
contentDir: new URL('./', import.meta.url),
|
|
})
|
|
} else {
|
|
yield renderSlot(result, slots.default)
|
|
}
|
|
},
|
|
}
|
|
},
|
|
{
|
|
isAstroComponentFactory: true,
|
|
Inline: Object.assign(
|
|
function MarkdownInline(result, attributes, slots) {
|
|
return {
|
|
get [Symbol.toStringTag]() {
|
|
return 'AstroComponent'
|
|
},
|
|
async *[Symbol.asyncIterator]() {
|
|
const mdl = attributes.of
|
|
|
|
if (typeof mdl === 'string') {
|
|
yield await markdown.inline(mdl, {
|
|
fileURL: new URL(import.meta.url),
|
|
contentDir: new URL('./', import.meta.url),
|
|
})
|
|
} else {
|
|
yield renderSlot(result, slots.default)
|
|
}
|
|
},
|
|
}
|
|
},
|
|
{
|
|
isAstroComponentFactory: true,
|
|
}
|
|
)
|
|
}
|
|
)
|
|
|
|
export default Markdown
|