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.

feat(theme-docs): support a way to ignore some contents

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’m creating a static doc site on the top of content-theme-docs, which will have many page eventually. For now, some pages are completed and ready to be published, while other markdown files are being written.

I decided to publish the doc site with some pages at first, and looked for a way to exclude or hide work-in-progress contents. But, I don’t want to move such files to other directory because then I can’t access them in the doc site with yarn run dev.

I just want work-in-progress pages to be excluded from production build and generate.

At first, I tried ignore option and generate.exclude option like below but I found that they cannot prevent contents from being added to database and rendered in the sidebar.

{
  ignore: process.env.NODE_ENV === 'production' ? [ /^\/sample\/.*/ ] : []
}
{
  generate: {
    exclude: process.env.NODE_ENV === 'production' ? [ /^\/sample\/.*/ ] : []
  }
}

Secondly, I tried to do something on database in content:file:beforeInsert hook, but I couldn’t do anything because the files that I want to be excluded namely had not yet inserted.

FYI: As I described in #576, theme-docs replaces user’s content:file:beforeInsert hook. So I modified the installed @nuxt/content’s file directly to test it.

As far as I read parts of code related to database, it ignores node_modules and hidden files whose name begin with . by default. So, I guess it’s possible to add a logic here to ignore some contents.

Describe the solution you’d like

Adding either content.ignore or content.exclude which is an array of regular expressions will be so nice, in that they align with ignore and generate.exclude options.

{
  content: {
    ignore: process.env.NODE_ENV === 'production' ? [ '**/wip.md' ] : [ ]
  }
}

Describe alternatives you’ve considered

Adding content.dirs which is an array of paths would be also possible. In this case, we can dynamically include or exclude directory for work-in-progress pages, for example, based on process.env.NODE_ENV.

{
  content: {
    dirs: process.env.NODE_ENV === 'production' ? [ 'content' ] : [ 'content', 'content-wip' ]
  }
}

But, we have to resolve conflict between content.dir and content.dirs.

Additional context

Although I’m not so familiar with the database-related parts of code, I will give it a try to implement this feature and submit a draft PR, so that we can discuss this feature in more detail. 🙋

Thank you for reading so long message. 🙇

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
hacknugcommented, Jul 28, 2022

I believe this has been addressed in v2 where you can mark a document as: draft, partial or ignore it.

1reaction
NozomuIkutacommented, Oct 23, 2020

I came up with another idea: setting a flag like publish: true/false in the front matter. This would be more blog-like DX rather than documentation, but the way is much easier than defining patterns to match.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ignore certain tags? - WordPress.org
Hi all,. Is there a way in YARPP (via functions.php or code modification) to make it ignore certain tags? For example, certain tags...
Read more >
Read the Docs Documentation
The tutorial is aimed at people interested in learning how to use Read the Docs to host their documentation projects.
Read more >
Hearten Themes Bundle
The Hearten Themes Bundle is perfect for professional designers and small creative businesses who want to cut their project time in half and...
Read more >
Gigawatt: Setup Your Widgets - Obox ThemesObox Themes
If you are not using the widget-driven layout, you may skip the Slider ... A Widget is a block of content that displays...
Read more >
How to Install the Los Niños Theme - Docs
There are several ways to upload and install a WordPress theme, ... Opt in or out to upload content (simplified for One-click Install);...
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