~subsetpark/bagatto

6e66ac991292e2f65e854a37add0786cbd3ad266 — Zach Smith 9 months ago 501e43f
Update API
1 files changed, 95 insertions(+), 52 deletions(-)

M api.md
M api.md => api.md +95 -52
@@ 12,6 12,7 @@
, [bagatto/format](#bagattoformat)
, [bagatto/get-default](#bagattoget-default)
, [bagatto/glob](#bagattoglob)
, [bagatto/include](#bagattoinclude)
, [bagatto/item-getter](#bagattoitem-getter)
, [bagatto/jdn-data](#bagattojdn-data)
, [bagatto/json-data](#bagattojson-data)


@@ 26,6 27,7 @@
, [bagatto/render](#bagattorender)
, [bagatto/renderer](#bagattorenderer)
, [bagatto/set-defaults!](#bagattoset-defaults)
, [bagatto/set-output-dir!](#bagattoset-output-dir)
, [bagatto/site-getter](#bagattosite-getter)
, [bagatto/slug-from-attr](#bagattoslug-from-attr)
, [bagatto/slugify](#bagattoslugify)


@@ 61,7 63,7 @@ repl:11:> (f {"author" "Z. D. Smith"} {:title "My second post"})
"site/z-d-smith/my-second-post.html"
```

[1]: /usr/lib/janet/bagatto.janet#L248
[1]: bagatto.janet#L267

## bagatto/*



@@ 74,7 76,7 @@ repl:11:> (f {"author" "Z. D. Smith"} {:title "My second post"})
Generate a function that will return all the filenames that match a given
file blob.

[2]: /usr/lib/janet/bagatto.janet#L106
[2]: bagatto.janet#L122

## bagatto/attr-sorter



@@ 87,7 89,7 @@ file blob.
Return a sorter function that, given a list of items, sorts
according to the items' values at the specified key.

[3]: /usr/lib/janet/bagatto.janet#L331
[3]: bagatto.janet#L350

## bagatto/datestr->date



@@ 102,7 104,7 @@ of the kind returned by `os/date`. Pass a truthy value in the second
argument to adjust for human display (setting values like day and
month to be 1-indexed).

[4]: /usr/lib/janet/bagatto.janet#L79
[4]: bagatto.janet#L95

## bagatto/datestr->secs



@@ 115,7 117,7 @@ month to be 1-indexed).
Given a string representation of a date or datetime, return the
epoch seconds value for that date.

[5]: /usr/lib/janet/bagatto.janet#L71
[5]: bagatto.janet#L87

## bagatto/epp



@@ 129,7 131,7 @@ Pretty-print to stderr. Since Temple templates operate over stdout,
we should use stderr instead if we need to print something to the
console for debugging purposes.

[6]: /usr/lib/janet/bagatto.janet#L420
[6]: bagatto.janet#L466

## bagatto/eval-data



@@ 144,7 146,7 @@ Evaluate an object according to the Bagatto *site data specification*.
Not necessary to define a module, but can be useful to debug your
configuration from within the REPL.

[7]: /usr/lib/janet/bagatto.janet#L344
[7]: bagatto.janet#L363

## bagatto/eval-loader



@@ 160,7 162,7 @@ and contents, it produces.
Not necessary to define a module, but can be useful to debug your
configuration from within the REPL.

[8]: /usr/lib/janet/bagatto.janet#L354
[8]: bagatto.janet#L373

## bagatto/eval-site



@@ 176,7 178,9 @@ given a site data object as context.
Not necessary to define a module, but can be useful to debug your
configuration from within the REPL.

[9]: /usr/lib/janet/bagatto.janet#L365
# TODO : To make this work again, expose the generator functions in a non-threaded context.

[9]: bagatto.janet#L384

## bagatto/format



@@ 190,7 194,7 @@ A simple wrapper around `string/format` to ease development. If one
of `xs` is nil, it will output an empty string rather than crashing
the template.

[10]: /usr/lib/janet/bagatto.janet#L410
[10]: bagatto.janet#L456

## bagatto/get-default



@@ 209,7 213,7 @@ and then implement your more specific logic.

(see `bagatto/set-defaults!` for more information.)

[11]: /usr/lib/janet/bagatto.janet#L28
[11]: bagatto.janet#L34

## bagatto/glob



@@ 221,11 225,35 @@ and then implement your more specific logic.



[12]: /usr/lib/janet/bagatto.janet#L98
[12]: bagatto.janet#L114

## bagatto/include

**macro**  | [source][13]

```janet
(include template)
```

Require and render the named template.

In addition to being a convenient wrapper around

```
{$ (import foo) $}
{% (foo/render-dict args) %}
```

`include` will update the error-tracking context with the name of
the included template. This makes it much easier to trace rendering
errors in nested templates.


[13]: bagatto.janet#L414

## bagatto/item-getter

**function**  | [source][13]
**function**  | [source][14]

```janet
(item-getter path)


@@ 236,11 264,11 @@ the given path in the item.

The path should be a tuple of keys, eg.: `[:user :full-name]`. 

[13]: /usr/lib/janet/bagatto.janet#L238
[14]: bagatto.janet#L257

## bagatto/jdn-data

**function**  | [source][14]
**function**  | [source][15]

```janet
(jdn-data src)


@@ 248,11 276,11 @@ The path should be a tuple of keys, eg.: `[:user :full-name]`.

Get metadata from a JDN-formatted string.

[14]: /usr/lib/janet/bagatto.janet#L51
[15]: bagatto.janet#L67

## bagatto/json-data

**function**  | [source][15]
**function**  | [source][16]

```janet
(json-data src)


@@ 260,11 288,11 @@ Get metadata from a JDN-formatted string.

Get metadata from a JSON-formatted string.

[15]: /usr/lib/janet/bagatto.janet#L56
[16]: bagatto.janet#L72

## bagatto/markdown->html

**function**  | [source][16]
**function**  | [source][17]

```janet
(markdown->html md)


@@ 272,11 300,11 @@ Get metadata from a JSON-formatted string.

Render a markdown string into HTML.

[16]: /usr/lib/janet/bagatto.janet#L392
[17]: bagatto.janet#L438

## bagatto/mmarkdown->html

**function**  | [source][17]
**function**  | [source][18]

```janet
(mmarkdown->html md &keys {:smart smart})


@@ 290,11 318,11 @@ Accepts &keys flags :

(requires the presence of the multimarkdown executable.)

[17]: /usr/lib/janet/bagatto.janet#L397
[18]: bagatto.janet#L443

## bagatto/mmarkdown-data

**function**  | [source][18]
**function**  | [source][19]

```janet
(mmarkdown-data md)


@@ 302,11 330,11 @@ Accepts &keys flags :

Get metadata from a markdown string using multimarkdown.

[18]: /usr/lib/janet/bagatto.janet#L46
[19]: bagatto.janet#L62

## bagatto/parse-base

**function**  | [source][19]
**function**  | [source][20]

```janet
(parse-base _src attrs)


@@ 315,13 343,13 @@ Get metadata from a markdown string using multimarkdown.
Base attribute parser: bypasses the input source and returns the
default attributes that are provided for every file. These are:
- `:path`: the file path
- `:src`: (if the file was read) the contents of the file 
- `:contents`: (if the file was read) the contents of the file 

[19]: /usr/lib/janet/bagatto.janet#L126
[20]: bagatto.janet#L142

## bagatto/parse-jdn

**function**  | [source][20]
**function**  | [source][21]

```janet
(parse-jdn src attrs)


@@ 329,11 357,11 @@ default attributes that are provided for every file. These are:

Attribute parser for JDN.

[20]: /usr/lib/janet/bagatto.janet#L145
[21]: bagatto.janet#L161

## bagatto/parse-json

**function**  | [source][21]
**function**  | [source][22]

```janet
(parse-json src attrs)


@@ 341,11 369,11 @@ Attribute parser for JDN.

Attribute parser for JSON.

[21]: /usr/lib/janet/bagatto.janet#L150
[22]: bagatto.janet#L166

## bagatto/parse-mmarkdown

**function**  | [source][22]
**function**  | [source][23]

```janet
(parse-mmarkdown src attrs)


@@ 355,11 383,11 @@ Attribute parser for multimarkdown.

(requires the presence of the multimarkdown executable.)

[22]: /usr/lib/janet/bagatto.janet#L136
[23]: bagatto.janet#L152

## bagatto/path-copier

**function**  | [source][23]
**function**  | [source][24]

```janet
(path-copier base &opt key)


@@ 379,11 407,11 @@ repl:4:> (f {} {:path "original/source/directory/newfile.png"})
"destination/newfile.png"
```

[23]: /usr/lib/janet/bagatto.janet#L310
[24]: bagatto.janet#L329

## bagatto/render

**function**  | [source][24]
**function**  | [source][25]

```janet
(render template site &opt item)


@@ 404,11 432,11 @@ template.

See the [Temple](https://git.sr.ht/~bakpakin/temple) site for more details.

[24]: /usr/lib/janet/bagatto.janet#L159
[25]: bagatto.janet#L175

## bagatto/renderer

**function**  | [source][25]
**function**  | [source][26]

```janet
(renderer template-path &opt extra-attrs)


@@ 419,11 447,11 @@ that will call `render` with that template on any input.

(see `bagatto/render` for more details.)

[25]: /usr/lib/janet/bagatto.janet#L214
[26]: bagatto.janet#L233

## bagatto/set-defaults!

**function**  | [source][26]
**function**  | [source][27]

```janet
(set-defaults! defaults)


@@ 435,11 463,26 @@ specifications. For instance, setting the default of `:attrs` to
by parsing it as JSON. `:attrs` could still be set on any entry in
the data spec in order to override the default.

[26]: /usr/lib/janet/bagatto.janet#L17
[27]: bagatto.janet#L23

## bagatto/set-output-dir!

**function**  | [source][28]

```janet
(set-output-dir! dir)
```

Name a directory for all produced files to be placed. For instance,

`(bagatto/set-output-dir! "site")` will place your generated file
hierarchy in a directory called `site`.

[28]: bagatto.janet#L48

## bagatto/site-getter

**function**  | [source][27]
**function**  | [source][29]

```janet
(site-getter path)


@@ 450,11 493,11 @@ the value at the given path in the site.

The path should be a tuple of keys, eg.: `[:blog :description]`. 

[27]: /usr/lib/janet/bagatto.janet#L228
[29]: bagatto.janet#L247

## bagatto/slug-from-attr

**function**  | [source][28]
**function**  | [source][30]

```janet
(slug-from-attr item key)


@@ 465,11 508,11 @@ it make the value into a slug.

(see `bagatto/slugify` for more details.)

[28]: /usr/lib/janet/bagatto.janet#L200
[30]: bagatto.janet#L219

## bagatto/slugify

**function**  | [source][29]
**function**  | [source][31]

```janet
(slugify s)


@@ 477,11 520,11 @@ it make the value into a slug.

Normalize a string for use as a slug, eg., in a file path.

[29]: /usr/lib/janet/bagatto.janet#L186
[31]: bagatto.janet#L205

## bagatto/slurp-*

**function**  | [source][30]
**function**  | [source][32]

```janet
(slurp-* pattern)


@@ 490,14 533,14 @@ Normalize a string for use as a slug, eg., in a file path.
Generate a function that will slurp all the files that match a given
file blob.

[30]: /usr/lib/janet/bagatto.janet#L114
[32]: bagatto.janet#L130

## bagatto/write-site

**function**  | [source][31]
**function**  | [source][33]

```janet
(write-site writer-specs)
(write-site writer-specs output-dir)
```

Given the output of a site generation specification, trigger the


@@ 506,5 549,5 @@ actual file generation.
Not necessary to define a module, but can be useful to debug your
configuration from within the REPL.

[31]: /usr/lib/janet/bagatto.janet#L376
[33]: bagatto.janet#L397