statiqdev / Statiq.Framework

A flexible and extensible static content generation framework for .NET.
https://statiq.dev/framework
MIT License
421 stars 75 forks source link

Expand the Globber to be able to match individual files or documents against pattern(s) #203

Closed Perksey closed 3 years ago

Perksey commented 3 years ago

When migrating Silk.NET I found myself needing to filter documents based on patterns in a parallel module. Currently there's no easy way to do this.

Use case:

Possible Solutions:

Thanks for building a great framework!

daveaglick commented 3 years ago

Can I just say I love you you've jumped right in and are already doing cool out-of-the-box stuff :)

There may be something already existing that can help here. Given an IEnumerable<TDocument>, there are a couple extension methods called FilterSources and FilterDestinations that might help. Both extension methods take one or more globbing patterns and apply it to the document enumerable, filtering for matching source and destination paths respectively. Does that seem like it's on the right track, or have a I totally missed something here?

Perksey commented 3 years ago

Thanks! We actually ended up getting this working (as you saw on Twitter) by just coalescing the pipelines, you can have an explore here: https://github.com/dotnet/Silk.NET/tree/feature/heavy-wip-website/src/Website

It's a great framework and saved me making my own generator from scratch (which I was actually prepared to do and already had a prototype working)!

Can't speak highly enough about your work with Statiq, truly is something else :D

Perksey commented 3 years ago

Will close this as the Filter* modules are a good choice and is what we've moved to use now, I don't think expanding the separate Globber API is particularly necessary.