Replies: 2 comments 3 replies
-
|
This feedback is invaluable, thanks so much for taking the time to get it all down!
Totally agree. The
It's been on my todo list for Statiq Web for a while to add JSON and XML front matter support. The challenge (if you can call it that - I don't actually think it'll be very hard) is figuring out how to indicate which front matter parser to use (or ideally figure it out based on content, like an initial
Totally agree - a lot of the performance lag right now is due to the Razor rendering engine and there's not a lot we can do about that. It's just not designed for fast-throughput compilation and rendering. What we can do though is provide alternate, more generator friendly view engines. I'm hope to continue adding more of those (a PR to add Scriban support is in the works already). Then it's a tradeoff of power (Razor) vs. speed (Handlebars, Liquid, etc.) and the user can choose the appropriate approach.
I don't know much about Rider, but this seriously works in VS? I've never tried - that's so cool!
Excellent feedback, I'll work on incorporating more documentation in these areas.
Agreed, myself included. I'm planning on doing something very similar to the Wyam docs once Statiq Docs is far enough along to do code analysis on the codebase and extract module classes: https://wyam.io/modules/
Great question - this could definitely be addressed better in the docs. The best way of doing it is to modify the pipeline to add your modules. For example, I recently had a use case where I wanted to add geocoding to documents that contained a metadata key of ...
.ConfigureEngine(x => x
.Pipelines[nameof(Statiq.Web.Pipelines.Content)]
.ProcessModules
.Add(new GeocodeLocations()))Pretty sure I'll also add a new
I actually just finished refactoring the whole settings support in the most recent release, though the new code works mostly like the old code in practice. This is actually a convention several execution context properties follow: a mutable object that's exposed as such in the engine (presumably for use prior to execution) that also implements a read-only interface that gets presented in the context. The intent is that you'll mostly interact with the object via the exposed read-only interface - though as with any interface you can also use reflection and casting to get the underlying object even if it's not intended.
I'd try to avoid manipulating global metadata during execution. Because pipelines run concurrently, modifying anything globally during execution can end up being non-deterministic depending on ordering and that can create hard-to-find bugs and discrepancies. Instead I'd create a thread-safe singleton to store and provide that kind of data - you could either get it via a static method or by registering with the DI container as a singleton service. Thanks again! And don't hesitate to let me know if you have any other questions or feedback. |
Beta Was this translation helpful? Give feedback.
-
My protected override IEnumerable<IDocument> ExecuteInput(IDocument input,
IExecutionContext context)
{
var documentMetadata = new List<Dictionary<string, object>>();
using (TextReader contentReader = new StreamReader(input.GetContentStream()))
{
var metaData = _deserializer.Deserialize<Dictionary<string, object>>(contentReader);
documentMetadata.Add(metaData);
}
return documentMetadata.Select(metadata => input.Clone(metadata));
}I agree with your thought that parsing non-scalar YAML values would be best represented as IMetadata.
Yes, I definitely like that better than delimiting with +++, ---, etc.
I figured... but it's a worthwhile trade-off for the power of Razor when you need it!
That makes sense, thanks!
Yes, I've since found it's better to output the aggregated menu data to a single document that can be referenced later from the execution context Thanks again for your hard work and support! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
First, thank you for building Statiq. I like the "framework" approach as it really enables one to use static site generation perfectly tailored to each use case.
I'm used to Hugo's system for defining menus, but I've been watching for a SSG that would let me use Razor for templates. So when I found Statiq, I figured I'd learn it by building a pipeline to provide similar menu functionality.
It took a while to figure out what I was doing, but I now have a prototype working. Here are my observations.
General
new ExtractFrontMatter("+++", new ParseJson())? (the +++ delimiter is how Hugo delimits TOML front matter, but whatever).Documentation
Concat()documents output by their dependencies, but DirectoryMetadata does not appear to. I had to read the code to figure that out)CacheDocuments()to try and achieve this).Questions
IExecutionContext.Settingsis typed as anIReadOnlyConfigurationSettings, but it actually returns anIConfigurationSettings, which has anAdd()method exposed. (I used this to put the menu data I extract from front matter and config files into the global metadata.) But if it's "read only", should it really have anAdd()method?Hope this helps!
Beta Was this translation helpful? Give feedback.
All reactions