Example of new custom outputs

So I was pretty excited about the new custom output stuff in 0.20, but maybe I got too excited too quickly. :wink:

I thought this update would simplify creating dynamic pages in non-HTML format. So for example. I want /foo.json to to be a JSON array of the last 5 pages created.

I thought I could go into /content, make a new file, foo.json, and include Go language inside. I did that, but the template stuff isn’t being parsed. I even added front matter, but it didn’t work.

So what am I missing?

It seems that you try to brute-force your way into this new feature, which I guess can take some time.

Have you looked at the documentation?

Also, the recent commits on my blog should give you some insight.

As to examples, I’m sure the community will provide lots of them, as soon as the paint dries.

Yep, I did read the docs. It doesn’t seem to explain how one would create a file w/ custom logic (again, using the Go syntax) to spit out something that’s not HTML. Is it indeed possible?

Yes it is.

Alright - so given /content/foo.json, can you confirm that I need front matter in order for it to be parsed and just not copied over? Could you maybe show a simple example of just outputting one variable in the JSON?

Can you point to where in the documentation is says that you should put a JSON file or similar inside /content? That would be good to fix, as that would create confusion.

As to examples, if you need anymore than what’s provided, you will have to wait for others to chime in.

Err, well, no, it doesn’t say to do that.

Maybe I’m just confused then. My read on this new feature was that I could create a template that was dynamic (locally of course) that would be built static and would allow for things like a custom JSON file, or some such.

Is that not true? If so, then how is it done? I’m not asking for a large demo, even something as simple as:

{ “siteName”: “this would be dynamic based on site name”}

That should be a trivial example, right? (Assuming I’m reading the docs right.)