content icon indicating copy to clipboard operation
content copied to clipboard

Excerpt displaying

Open ipatate opened this issue 3 years ago • 10 comments

Hello, i don't find how to display the excerpt on a list of articles.

 <div v-for="article in articles" :key="article._path">
      <h2>{{ article.title }}</h2>
      <ContentRenderer :value="article" :excerpt="true" />
    </div>

this code display all the content of page : Screenshot 2022-08-08 at 15 35 31

Thanks for help 👍🏼

ipatate avatar Aug 09 '22 07:08 ipatate

Hey @ipatate

Are you using <!--more--> in your content to create the excerpt?

If so we may have a bug @farnabaz

atinux avatar Aug 09 '22 08:08 atinux

More ? No. where i should use ?

I don't find things about "more" in doc.

PS : I talk about v2.

ipatate avatar Aug 09 '22 08:08 ipatate

<!--mode--> is a delimiter that is used to determine excerpt paragraphs. You can simply add <!--more--> in any line of your content and by doing it above paragraphs will become part of the excerpt.

# title

First paragraph

Second paragraph

<!--more-->

Third paragraph. (not included in excerpt)

farnabaz avatar Aug 09 '22 09:08 farnabaz

Ah ok ! Thanks @farnabaz I understand now.

ipatate avatar Aug 09 '22 09:08 ipatate

It works, but i have always the H1 title. Maybe i can remove this tag with filter

ipatate avatar Aug 09 '22 09:08 ipatate

If you don't want to have H1 tag, you can remove # title from your markdown and define content title in front matter

---
title: YOUR TITLE
---

First paragraph

Second paragraph

<!--more-->

Third paragraph. (not included in excerpt)

farnabaz avatar Aug 09 '22 10:08 farnabaz

ok thanks. I use Content Wind.

For get title in Layout, i try this but i think is not clean.

Screenshot 2022-08-09 at 15 03 46

ipatate avatar Aug 09 '22 13:08 ipatate

You think it's possible to implement in a future a system for generate excerpt. A system with tags cleaning (H1, img,..) and keep only text ? with param number for length

ipatate avatar Aug 09 '22 13:08 ipatate

It is possible to do this extraction. The module supports creating custom transformers to manipulate parsed contents. Unfortunately, transformers are not documented yet.

I'll ping in this issue once the documentation is updated 🙂

farnabaz avatar Aug 09 '22 14:08 farnabaz

yeah good news for the transformer ! thanks 🙏

ipatate avatar Aug 09 '22 14:08 ipatate

Here are the docs:

  • Excerpt: https://content.nuxtjs.org/guide/writing/markdown#excerpt
  • Transformers: https://content.nuxtjs.org/api/advanced#transformers

farnabaz avatar Aug 17 '22 15:08 farnabaz

Nice ! thanks @farnabaz

ipatate avatar Aug 18 '22 06:08 ipatate