Skip to content
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

Enhancement: Add excludePaths option to frontmatter.content.pageFolders config entries to allow filtering out subdirectories and filepaths based on regex matches #840

Closed
polynook opened this issue Aug 14, 2024 · 5 comments
Labels
enhancement New feature or request In BETA The current task is available for testing in the BETA version. Released The task has been released v10.5.0 Project: v10.5.0

Comments

@polynook
Copy link

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

As of now, frontmatter.content.pageFolders config allows excludeSubdir which is a boolean flag. This is too restrictive to certain workflows.

For example:

We have a docs content folder defined that contains documentation pages. The /.frontmatter/docs/ directory contains handwritten doc files, but there is a subdirectory /.frontmatter/docs/api that has generated pages. These generated pages are not meant to be edited by hand, but they still appear in the CMS dashboard, slowing it down (when the number of pages is in the thousands) and need to be constantly filtered out in the dashboard.

Describe the solution you'd like
Add an excludePaths option to content definitions in frontmatter.content.pageFolders that would be a list of glob patterns and/or regex patterns to match against:

{
  "frontMatter.content.pageFolders": [
    {
      "title": "Pages",
      "path": "/.frontmatter/docs",
      "excludePaths": [
           "api",
           "_*.*" // exclude all files starting with an underscore
      ]
    },
}

excludePaths option would resolve paths relative to the path option of this config. It should support matching against both directories and filepaths for maximum flexibility, since we may not want to exclude select paths.

Supporting glob patterns is nice for ease of use and regex patterns is nice for more complex cases and flexibility.

Describe alternatives you've considered
Haven't come up with any viable alternatives.

@polynook polynook added the enhancement New feature or request label Aug 14, 2024
@project-labels project-labels bot added v10.5.0 Project: v10.5.0 In progress This is actively being worked on labels Oct 8, 2024
estruyf added a commit that referenced this issue Oct 8, 2024
@estruyf
Copy link
Owner

estruyf commented Oct 8, 2024

@polynook, thanks for the suggestion. It is available in the beta for testing. It is implemented like the example above. Let me know what you think.

@polynook
Copy link
Author

polynook commented Oct 8, 2024

@estruyf Thank you for working on this!

I can't seem to get it to work though. I get Property excludePaths is not allowed. when trying to define it in frontmatter.json.

Inspecting https://beta.frontmatter.codes/frontmatter.schema.json appears to be missing the excludePaths option.

Here is how I use it:

"frontMatter.content.pageFolders": [
        {
            "title": "Page",
            "contentTypes": ["Page"],
            "path": "[[workspace]]/.frontmatter/content/page",
            "previewPath": "/",
            "excludePaths": ["generated/*"]
        },
    ],

The files that should be excluded reside in [[workspace]]/.frontmatter/content/page/generated/.

I'm using Front Matter v10.5.112333718.

estruyf added a commit that referenced this issue Oct 8, 2024
@estruyf
Copy link
Owner

estruyf commented Oct 8, 2024

I can't seem to get it to work though. I get Property excludePaths is not allowed. When trying to define it in frontmatter.json.

You can ignore this, as the schema only updates when the documentation site has updates. As it needs to be verified, I haven't done this yet, so you get that. Once it's all working, I update the docs and the schema as well.


I added a small fix for the Windows file system support. I believe this should fix your issue.

@polynook
Copy link
Author

polynook commented Oct 9, 2024

I'm running on WSL and the issue for me was using an incorrect glob pattern ("generated/*" instead of "generated/**") since the content is nested.

You can ignore this, as the schema only updates when the documentation site has updates. As it needs to be verified, I haven't done this yet, so you get that. Once it's all working, I update the docs and the schema as well.

Gotcha. Not sure if you've updated the docs already, but I just wanted to let you know that the schema says excludePaths is boolean:

"excludePaths": {
  "type": "boolean",
  "default": false,
  "description": "Exclude paths (e.g. api, _*.*)"
},

should be

"excludePaths": {
  "type": "array",
  "default": [],
  "description": "Exclude paths (e.g. api, _*.*)"
},

Please ignore if this is related to the documentation site not having been updated yet.

Everything else works great, thank you!

estruyf added a commit that referenced this issue Oct 9, 2024
@estruyf
Copy link
Owner

estruyf commented Oct 9, 2024

That type was indeed incorrect, updated it.

@project-labels project-labels bot added In BETA The current task is available for testing in the BETA version. and removed In progress This is actively being worked on labels Oct 17, 2024
@project-labels project-labels bot added the Released The task has been released label Oct 21, 2024
@estruyf estruyf closed this as completed Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request In BETA The current task is available for testing in the BETA version. Released The task has been released v10.5.0 Project: v10.5.0
Projects
None yet
Development

No branches or pull requests

2 participants