@igor.dvlpr/astro-post-excerpt
Version:
⭐ An Astro component that renders post excerpts for your Astro blog - directly from your Markdown and MDX files. Astro v2+ collections are supported as well! 💎
29 lines (27 loc) • 1.32 kB
text/typescript
import type { IAstroCollectionEntry } from './interfaces/IAstroCollectionEntry'
export interface Props extends Record<string, unknown> {
/**
* The post whose excerpt you want to generate and render. If this prop is not supplied or not valid, the component will throw an error.
*/
post: IAstroCollectionEntry
/**
* The number of words the generated excerpt should have in total. Be aware that the prop `maxLength` has precedence over this prop but you can use both props simultaneously. Defaults to **40**.
*/
words?: number
/**
* Max length of the generated excerpt. Be aware that this prop has precedence over the `words` prop but you can use both props simultaneously. Defaults to **0** (unlimited).
*/
maxLength?: number
/**
* Controls whether an ellipsis ("…" is the default, you can configure it) should be appended to the post excerpt. Defaults to **true**.
*/
addEllipsis?: boolean
/**
* Controls whether the appended ellipsis should be aware of how the excerpt ends, i.e. if the excerpt ends with a punctuation symbol the ellipsis won't be appended. Defaults to **true**.
*/
smartEllipsis?: boolean
/**
* Controls the ellipsis string that should be appended to the post excerpt. Defaults to **"…"**.
*/
ellipsis?: string
}