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.

Struggles with `contentDirInclude`

See original GitHub issue

Device info:

  • MacBook Pro (15-inch, 2017)
  • 2.8 GHz Quad-Core Intel Core i7
  • MacOS Monterey 12.4

Given the following directory structure:

# ...various NextJS files and dirs...
|— vault
|  |— posts
|  |   |— some-post.md
|  |— books
|  |   |— some-book.md
|  |— templates
|  |   |— some-template.md
|  |— some-unpublished-file.md
|— contentlayer.config.ts

And given the following Content Layer source configuration:

export default makeSource({
    contentDirPath: 'vault',
    contentDirInclude: [
      'books',
      'posts',
    ],
    documentTypes: [
        Post,
        Book,
    ],
})

I would expect to load in both ./vault/posts/some-post.md and ./vault/books/some-book.md, but no documents are loaded.

If I remove the contentDirInclude statement, my desired documents are loaded, however both some-template.md and some-unpublished-file.md will be checked and give me a warning about undefined documents.

If I switch to use contentDirExclude with the following configuration:

export default makeSource({
    contentDirPath: 'vault',
    contentDirExclude: [
      '.',
      'templates',
    ],
    documentTypes: [
        Post,
        Book,
    ],
})

I successfully load my desired documents and ignore some-template.md, however some-unpublished-thought.md still gets checked.

Is there some error in how I am referring to directories in using these options? I’ve tried variations such as ./ instead of ., or ./books/ and vault/books instead of books.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
franknoirotcommented, Jun 21, 2022

Sure thing @seancdavis! Apologies I kept working on this repo so I’ve gotta link to some commits to show where I was making this decision:

  • Here is where I made the call to scope things to a private and public directory to avoid the issue.
  • This commit is a couple fix commits after the one above where I got it to run a successful build (the commit above works with npm run dev though).

Let me know if you need anything else to explore.

As background, I’m publishing updates to this repo to https://obsidian-nextjs-blog.netlify.app/. I think Content Layer will let me finally have my personal Obsidian knowledge graph notes right next to my personal site’s code so that I can take notes in Obsidian and publish them to a website simply by moving notes to designated folders in my Obsidian vault, while having the published and unpublished parts of my personal notes remain connected within Obsidian! Thanks for building this tool, it was the missing piece.

0reactions
stale[bot]commented, Sep 3, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Contentlayerdev Contentlayer Issues - IssueHint
Struggles with `contentDirInclude `, closed, 6, 2022-06-18, 2022-10-12. don't generate invalid typescript, closed, 4, 2022-06-18, 2022-10-29.
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