-
-
Notifications
You must be signed in to change notification settings - Fork 658
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Content excerpt support #68
Comments
@nahokomatsui Have you tried to use remark-excerpt? You can extend plugins in @nuxt/content: https://content.nuxtjs.org/configuration#markdownplugins |
We could support it I guess @benjamincanac if Then we would need to have |
Thank you for your considerations. For your information, I tried registering remark-excerpt plugin following @benjamincanac's advice on my example repo: https://github.com/nahokomatsui/nuxt-content-excerpt Just adding the plugin to configuration causes omitting not-excerpt contents from all fetched contents. I also tried parsing contents with remark-excerpt inside content:file:beforeInsert hook but it didn't work well either. Therefore It would be appreciated if it is supported inside Nuxt Content module with @atinux's way. |
@nahokomatsui Have you tried using excerpt inside |
@benjamincanac I tried it on this commit but it makes excerpt value undefined. |
@nahokomatsui Until we support it, you could do something like: const remark = require('remark');
const excerpt = require('remark-excerpt');
...
'content:file:beforeInsert': (document) => {
document.excerpt = await remark()
.use(excerpt)
.process(document.text)
} |
@benjamincanac Sorry for misunderstanding. import remark from 'remark'
import remarkExcerpt from 'remark-excerpt'
import retextStringify from 'retext-stringify'
...
hooks: {
'content:file:beforeInsert': async (document) => {
if (document.extension === '.md') {
const processed = await remark()
.use(remarkExcerpt)
.use(retextStringify)
.process(document.text)
document.excerpt = processed.contents
}
}
} This workaround should be enough until it is officially supported in a more integrated way. Thank you. |
My "101" solution : I manually add a new field in the YAML, which contains a "résumé", or the first paragraph of my doc. |
I solved the problem just with this code:
Then you can use |
@imlautaro This has been implemented in the core of @nuxt/content since then: https://content.nuxtjs.org/writing#excerpt. |
Describe the solution you'd like
Please provide a way to fetch plain content body texts (not the body object of the current fetching result), in order to display excerpt on pages such as content list view.
Feature like Content Excerpt of VuePress would be awesome.
Describe alternatives you've considered
Having
<nuxt-content>
prop for displaying excerpt and other selected content properties would be useful too.The text was updated successfully, but these errors were encountered: