question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to exclude/ignore README.md from $content() fetches?

See original GitHub issue

I’m wondering if I can tell @nuxt/content to ignore README files when “fetching” data in a cms like manner.

this.$content('menues') and http://localhost:3030/_content/menues both also return the README.md in ~/content/menues/

I don’t want that. I’d like to exclude README files in general for all content fetches.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Atinuxcommented, Mar 1, 2021

I think we should ignore all files and directories starting by _ and also respecting Nuxt ignore pattern.

This way you could have content/_README.md to directly set content/**/README.md in .nuxtignore

2reactions
NozomuIkutacommented, Nov 18, 2020

@katerlouis

where() query-building method is for you (doc).

Each file name is used as a built-in slug property of document in database (doc), which means it can be filtered out by where() method like the following:

$content().where({ slug: { $ne: 'README' } }).fetch()

If you want to fetch all the README.md files only from all the sub directories, you can also do it:

$content({ deep: true }).where({ slug: 'README' }).fetch()
// or
$content({ deep: true }).where({ slug: { $eq: 'README' } }).fetch()

JFYI:

Actually, you can chain query-building methods before calling fetch(), so that you can fetch only documents which match all the queries built in the chain.

For example, here is how Theme Docs fetches prev/next documents of the current page’s document (code):

const [prev, next] = await $content(app.i18n.locale, { deep: true })
      .only(['title', 'slug', 'to'])
      .sortBy('position', 'asc')
      .surround(document.slug, { before: 1, after: 1 })
      .fetch()
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I test what my readme.md file will look like before ...
File extension is .md so you can preview your changes. You will update util you finish, then copy the file content and paste...
Read more >
gitignore Documentation - Git
A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below...
Read more >
How to Create a Self-Updating README.md for Your GitHub ...
In this ./workflows folder, create a ./main.yaml file that will hold our Action. $ cd ./workflows && touch main.yaml. Fill it with this...
Read more >
How I Built A Self-Updating README On My Github Profile
GitHub profile READMEs are a new feature that allows users to have the content of a README markdown file rendered at the profile...
Read more >
Static Readme Regeneration - Aral Roca
This file will contain all the static content of the README.md . ... Fetch all articles of my blog on rss.xml fn get_blog_rss()...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found