|
An îles module to extract an excerpt from MDX documents:
-
🏷 can render HTML by using the
excerpt
prop in an MDX component -
⚙️
maxLength
,separator
, andextract
options to customize excerpt
// iles.config.ts
import { defineConfig } from 'iles'
export default defineConfig({
modules: [
['@islands/excerpt', { maxLength: 140 }],
],
})
Use meta
to access a text excerpt for the current page:
const { meta } = usePage()
const text = meta.excerpt
When importing MDX components, you can also render an HTML version of the
excerpt by passing an excerpt: true
prop.
<script setup>
import Introduction from '~/pages/intro.mdx'
const pages = useDocuments('~/pages/posts')
</script>
<template>
<Introduction excerpt/>
<template v-for="page in pages">
<component :is="page" excerpt/>
</template>
</template>