Skip to content

Commit

Permalink
zine v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kristoff-it committed Oct 11, 2024
1 parent 876b3d2 commit d9f0a63
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 31 deletions.
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
.version = "0.0.0",
.dependencies = .{
.zine = .{
.url = "git+https://github.com/kristoff-it/zine?ref=v0.6.3#9d95313c744c2ca7c466b82725a1fe959d81f6e6",
.hash = "1220415067dc7d10b6a3ccd1f3c5b35b5af6e2a7675232af55cebd50f711a55fc7e7",
.url = "git+https://github.com/kristoff-it/zine?ref=v0.7.0#36e5751c989cffbcf797d25ca7fe40d0dcd56a78",
.hash = "1220354bc547dec5285f1e5ea64ea7fc5eaab92d0e8becf366d8be5344dd086261d0",
},
},
.paths = .{"."},
Expand Down
98 changes: 70 additions & 28 deletions content/docs/superhtml/scripty.smd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ variant as defined in your `build.zig` file.
#### Examples

```superhtml
<span text="$site.localeName()"></span>
<span :text="$site.localeName()"></span>
```
### []($heading.id("Site.link")) [`fn`]($link.ref("Site.link")) link () -> [String]($link.ref("String"))

Expand All @@ -95,7 +95,7 @@ multilingual website.
#### Examples

```superhtml
<a href="$site.link()" text="$site.title"></a>
<a href="$site.link()" :text="$site.title"></a>
```
### []($heading.id("Site.asset")) [`fn`]($link.ref("Site.asset")) asset ([String]($link.ref("String"))) -> [Asset]($link.ref("Asset"))

Expand Down Expand Up @@ -124,7 +124,7 @@ matched by Zine with either:
```superhtml
<a href="$site.page('downloads').link()">Downloads</a>
```
### []($heading.id("Site.pages")) [`fn`]($link.ref("Site.pages")) pages ([String]($link.ref("String")), [[String]($link.ref("String"))...]) -> [[Page]($link.ref("Page"))]
### []($heading.id("Site.pages")) [`fn`]($link.ref("Site.pages")) pages ([String]($link.ref("String")), [[String]($link.ref("String"))...]) -> [[Page]($link.ref("Page"))] *(see also [[any]]($link.ref("Array")))*

Same as `page`, but accepts a variable number of page references and
loops over them in the provided order. All pages must exist.
Expand All @@ -134,7 +134,7 @@ To be used in conjunction with a `loop` attribute.
#### Examples

```superhtml
<ul loop="$site.pages('a', 'b', 'c')"><li text="$loop.it.title"></li></ul>
<ul :loop="$site.pages('a', 'b', 'c')"><li :text="$loop.it.title"></li></ul>
```
### []($heading.id("Site.locale")) [`fn`]($link.ref("Site.locale")) locale ([String]($link.ref("String"))) -> [Site]($link.ref("Site"))

Expand Down Expand Up @@ -185,12 +185,12 @@ as set in the SuperMD frontmatter.
When set to true the page will not be rendered in release mode,
as set in the SuperMD frontmatter.

### `tags` : [[String]($link.ref("String"))]
### `tags` : [[String]($link.ref("String"))] *(see also [[any]]($link.ref("Array")))*

Tags associated with the page,
as set in the SuperMD frontmatter.

### `aliases` : [[String]($link.ref("String"))]
### `aliases` : [[String]($link.ref("String"))] *(see also [[any]]($link.ref("Array")))*

Aliases of the current page,
as set in the SuperMD frontmatter.
Expand All @@ -201,7 +201,7 @@ from different locations.
Every entry in the list is an output location where the
rendered page will be copied to.

### `alternatives` : [[Alternative]($link.ref("Alternative"))]
### `alternatives` : [[Alternative]($link.ref("Alternative"))] *(see also [[any]]($link.ref("Array")))*

Alternative versions of the page,
as set in the SuperMD frontmatter.
Expand Down Expand Up @@ -278,7 +278,7 @@ Returns a reference to a localized variant of the target page.
#### Examples

```superhtml
<div text="$page.locale('en-US').title"></div>
<div :text="$page.locale('en-US').title"></div>
```
### []($heading.id("Page.locale?")) [`fn`]($link.ref("Page.locale?")) locale? ([String]($link.ref("String"))) -> ?[Page]($link.ref("Page"))

Expand All @@ -294,14 +294,14 @@ To be used in conjunction with an `if` attribute.
<a href="$if.link()" :text="$if.title"></a>
</div>
```
### []($heading.id("Page.locales")) [`fn`]($link.ref("Page.locales")) locales () -> [[Page]($link.ref("Page"))]
### []($heading.id("Page.locales")) [`fn`]($link.ref("Page.locales")) locales () -> [[Page]($link.ref("Page"))] *(see also [[any]]($link.ref("Array")))*

Returns the list of localized variants of the current page.

#### Examples

```superhtml
<div loop="$page.locales()"><a href="$loop.it.link()" text="$loop.it.title"></a></div>
<div :loop="$page.locales()"><a href="$loop.it.link()" :text="$loop.it.title"></a></div>
```
### []($heading.id("Page.wordCount")) [`fn`]($link.ref("Page.wordCount")) wordCount () -> [Int]($link.ref("Int"))

Expand Down Expand Up @@ -338,7 +338,7 @@ the current page is an 'index.smd' page).
```superhtml
$page.isSection()
```
### []($heading.id("Page.subpages")) [`fn`]($link.ref("Page.subpages")) subpages () -> [[Page]($link.ref("Page"))]
### []($heading.id("Page.subpages")) [`fn`]($link.ref("Page.subpages")) subpages () -> [[Page]($link.ref("Page"))] *(see also [[any]]($link.ref("Array")))*

Returns a list of all the pages in this section. If the page is
not a section, returns an empty list.
Expand Down Expand Up @@ -375,7 +375,7 @@ Tries to return the page before the target one (sorted by date), to be used with
#### Examples

```superhtml
<div if="$page.prevPage()"></div>
<div :if="$page.prevPage()"></div>
```
### []($heading.id("Page.hasNext")) [`fn`]($link.ref("Page.hasNext")) hasNext () -> [Bool]($link.ref("Bool"))

Expand Down Expand Up @@ -432,7 +432,7 @@ Renders the specified [content section]($link.page('docs/supermd/scripty').ref('
<div :html="$page.contentSection('section-id')"></div>
<div :html="$page.contentSection('other-section')"></div>
```
### []($heading.id("Page.contentSections")) [`fn`]($link.ref("Page.contentSections")) contentSections () -> [[ContentSection]($link.ref("ContentSection"))]
### []($heading.id("Page.contentSections")) [`fn`]($link.ref("Page.contentSections")) contentSections () -> [[ContentSection]($link.ref("ContentSection"))] *(see also [[any]]($link.ref("Array")))*

Returns a list of sections for the current page.

Expand All @@ -452,7 +452,7 @@ Renders the table of content.
#### Examples

```superhtml
<div html="$page.toc()"></div>
<div :html="$page.toc()"></div>
```
# [Ctx]($section.id('Ctx'))

Expand Down Expand Up @@ -501,7 +501,7 @@ Useful for example to generate RSS links:
<ctx alt="$page.alternative('rss')"
<a href="$ctx.alt.link()"
type="$ctx.alt.type"
text="$ctx.alt.name"
:text="$ctx.alt.name"
></a>
</ctx>
```
Expand Down Expand Up @@ -530,7 +530,7 @@ this function returns the heading as simple text.
#### Examples

```superhtml
<div html="$loop.it.heading()"></div>
<div :html="$loop.it.heading()"></div>
```
### []($heading.id("ContentSection.heading?")) [`fn`]($link.ref("ContentSection.heading?")) heading? () -> ?[String]($link.ref("String"))

Expand All @@ -540,7 +540,7 @@ this function returns the heading as simple text.
#### Examples

```superhtml
<div html="$loop.it.heading()"></div>
<div :html="$loop.it.heading()"></div>
```
### []($heading.id("ContentSection.html")) [`fn`]($link.ref("ContentSection.html")) html () -> [String]($link.ref("String"))

Expand All @@ -549,7 +549,7 @@ Renders the section.
#### Examples

```superhtml
<div html="$loop.it.html()"></div>
<div :html="$loop.it.html()"></div>
```
# [Build]($section.id('Build'))

Expand Down Expand Up @@ -577,7 +577,7 @@ Retuns a build-time asset (i.e. an asset generated through your 'build.zig' file
#### Examples

```superhtml
<div text="$build.asset('foo').bytes()"></div>
<div :text="$build.asset('foo').bytes()"></div>
```
# [Asset]($section.id('Asset'))

Expand Down Expand Up @@ -611,7 +611,7 @@ Returns the size of an asset file in bytes.
#### Examples

```superhtml
<div text="$site.asset('foo.json').size()"></div>
<div :text="$site.asset('foo.json').size()"></div>
```
### []($heading.id("Asset.bytes")) [`fn`]($link.ref("Asset.bytes")) bytes () -> [String]($link.ref("String"))

Expand All @@ -620,7 +620,7 @@ Returns the raw contents of an asset.
#### Examples

```superhtml
<div text="$page.assets.file('foo.json').bytes()"></div>
<div :text="$page.assets.file('foo.json').bytes()"></div>
```
### []($heading.id("Asset.ziggy")) [`fn`]($link.ref("Asset.ziggy")) ziggy () -> [any]($link.ref("any"))

Expand All @@ -629,7 +629,7 @@ Tries to parse the asset as a Ziggy document.
#### Examples

```superhtml
<div text="$page.assets.file('foo.ziggy').ziggy().get('bar')"></div>
<div :text="$page.assets.file('foo.ziggy').ziggy().get('bar')"></div>
```
# [Map]($section.id('Map'))

Expand Down Expand Up @@ -666,8 +666,8 @@ Tries to get a dynamic value, to be used in conjuction with an `if` attribute.
#### Examples

```superhtml
<div if="$page.custom.get?('myValue')">
<span text="$if"></span>
<div :if="$page.custom.get?('myValue')">
<span :text="$if"></span>
</div>
```
### []($heading.id("Map.has")) [`fn`]($link.ref("Map.has")) has ([String]($link.ref("String"))) -> [Bool]($link.ref("Bool"))
Expand All @@ -678,9 +678,9 @@ Returns true if the map contains the provided key.
#### Examples

```superhtml
<div if="$page.custom.has('myValue')">Yep!</div>
<div :if="$page.custom.has('myValue')">Yep!</div>
```
### []($heading.id("Map.iterate")) [`fn`]($link.ref("Map.iterate")) iterate () -> [[KV]($link.ref("KV"))]
### []($heading.id("Map.iterate")) [`fn`]($link.ref("Map.iterate")) iterate () -> [[KV]($link.ref("KV"))] *(see also [[any]]($link.ref("Array")))*

Iterates over key-value pairs of a Ziggy map.

Expand All @@ -689,7 +689,7 @@ Iterates over key-value pairs of a Ziggy map.
```superhtml
$page.custom.iterate()
```
### []($heading.id("Map.iterPattern")) [`fn`]($link.ref("Map.iterPattern")) iterPattern ([String]($link.ref("String"))) -> [[KV]($link.ref("KV"))]
### []($heading.id("Map.iterPattern")) [`fn`]($link.ref("Map.iterPattern")) iterPattern ([String]($link.ref("String"))) -> [[KV]($link.ref("KV"))] *(see also [[any]]($link.ref("Array")))*

Iterates over key-value pairs of a Ziggy map where the key
matches the given pattern.
Expand Down Expand Up @@ -810,7 +810,7 @@ The argument specifies the language name.
```superhtml
<pre>
<code class="ziggy"
html="$page.custom.get('sample').syntaxHighLight('ziggy')"
:html="$page.custom.get('sample').syntaxHighLight('ziggy')"
></code>
</pre>
```
Expand Down Expand Up @@ -1069,6 +1069,48 @@ In nested loops, accesses the upper `$loop`
```superhtml
$loop.up().it
```
# [Array]($section.id('Array'))

An array of items.

## Fields

### `len` : [Int]($link.ref("Int"))

The length of the array.

### `empty` : [Bool]($link.ref("Bool"))

True when len is 0.

## Functions

### []($heading.id("Array.slice")) [`fn`]($link.ref("Array.slice")) slice ([Int]($link.ref("Int")), ?[Int]($link.ref("Int"))) -> [[any]($link.ref("any"))]

Slices an array from the first value (inclusive) to the
second value (exclusive).

The second value can be omitted and defaults to the array's
length, meaning that invoking `slice` with one argunent
produces **suffixes** of the original sequence (i.e. it
removes a prefix from the original sequence).

Note that negative values are not allowed at the moment.

#### Examples

```superhtml
$page.tags.slice(0,1)
```
### []($heading.id("Array.at")) [`fn`]($link.ref("Array.at")) at ([Int]($link.ref("Int"))) -> [any]($link.ref("any"))

Returns the value at the provided index.

#### Examples

```superhtml
$page.tags.at(0)
```
# [KV]($section.id('KV'))

A key-value pair.
Expand Down
1 change: 1 addition & 0 deletions content/index.smd
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.author = "Loris Cro",
.layout = "index.shtml",
.draft = false,
.tags = ["foo", "bar", "baz"],
---

># [Warning]($block.attrs('warning'))
Expand Down
31 changes: 30 additions & 1 deletion content/log.smd
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,40 @@ You can [subscribe to this page via RSS](https://zine-ssg.io/log/index.xml).

To update Zine to the latest release run:
```sh
zig fetch --save "git+https://github.com/kristoff-it/zine#v0.6.3"
zig fetch --save "git+https://github.com/kristoff-it/zine#v0.7.0"
```

## Changes


[]($section.id('v0.7.0').data('date','2024-10-11'))
- Introduced actual arrays in Zine. Previously we would immediately evaluate
Scripty expressions into iterators, which made it awkward to implement bulitin
functions such as `sort`. Zine now has a real concept of Array with dedicated
builtins, you can read more in the reference for
[`[any]`]($link.page('docs/superhtml/scripty').ref('Array')).
Note that arrays don't yet offer a sorting builtin (figuring out
the interface to expose to the user has been left as work for a subsequent
release), but they do support other basic stuff like slicing. I'm happy to
work with users to implement functions that would unblock them, even if the
design of the function will have to be changed in the future.

- Zine currently has a limitation that prevents it from correctly rendering
(calling `content()` on) pages that have been loaded through Scripty. Over
time this limitation has been mitigated, but it's not fully gone yet.
Unfortunately the check that told you that this was the case was not working
correctly, and has now been fixed. The most likely situation where you might
encounter this problem is when trying to render the content of various pages
in an RSS template. Previously it might have worked for simple cases and caused
a panic in others, now you will get a consistent error message that tells you
that the feature is not available yet.

- The webserver now properly parses percent encoding in URLs, used whenever files
have funky names. Thank you GigaGrunch! ([#65](https://github.com/kristoff-it/zine/pull/65))

- Paths with spaces were not handled correctly when tracking dependencies, causing
some failures that might have looked like cache issues, now fixed thanks to brandondyck ([#68](https://github.com/kristoff-it/zine/pull/68))

[]($section.id('v0.6.3').data('date','2024-09-19'))
- When iterating **content sections** with `$page.contentSections()`, you can now obtain the section's attached heading by calling
[`heading`]($link.page('docs/superhtml/scripty').ref('ContentSection.heading')) or
Expand Down
4 changes: 4 additions & 0 deletions layouts/scripty-reference.shtml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
padding: 3px 5px;
}

#reference h3 > em {
font-size: 0.7em;
}

#reference table {
width: 100%;
padding: 10px;
Expand Down

0 comments on commit d9f0a63

Please sign in to comment.