@islands/excerpt
v0.10.0-beta.1
Published
<p align="center"> <a href="https://iles-docs.netlify.app"> <img src="https://github.com/ElMassimo/iles/blob/main/docs/images/banner.png"/> </a> </p>
Downloads
373
Readme
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
Installation 💿
// iles.config.ts
import { defineConfig } from 'iles'
export default defineConfig({
modules: [
['@islands/excerpt', { maxLength: 140 }],
],
})
Usage 🚀
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>