Skip to content

Latest commit

 

History

History

excerpt

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 


@islands/excerpt

An îles module to extract an excerpt from MDX documents:

  • 📖 sets meta.excerpt, useful for SEO tags and RSS feeds

  • 🏷 can render HTML by using the excerpt prop in an MDX component

  • ⚙️ maxLength, separator, and extract 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>