Skip to content

Commit cdcdd64

Browse files
authored
Merge pull request #7 from sea-grass/development
v0.0.6
2 parents df1a4d2 + 98db943 commit cdcdd64

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

site/pages/changelog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ title: Changelog
44
template: page.html
55
---
66

7+
## 0.0.6
8+
9+
This release is a quick follow-up to the previous release to fix a bug with the theme shortcodes.
10+
11+
### Shortcodes
12+
13+
- `{{& theme.head }}` now correctly references theme assets according to the `url_prefix`, if provided.
14+
715
## 0.0.5
816

917
This PR contains many changes that are under the hood to support future features. User-facing changes include a more recent supported Zig version, updates to page parameters, more informative error messages, updates to shortcodes, and improvements to the markdown renderer.

src/main.zig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const BuildCommand = struct {
4242

4343
pub const ParseError = error{
4444
Help,
45+
MalformedUrlPrefix,
4546
MemoryError,
4647
MissingOutDir,
4748
MissingSiteRoot,
@@ -94,6 +95,12 @@ const BuildCommand = struct {
9495

9596
const url_prefix: ?[]const u8 = if (res.args.prefix) |prefix| prefix else null;
9697

98+
if (url_prefix != null) {
99+
if (!mem.startsWith(u8, url_prefix.?, "/")) {
100+
return error.MalformedUrlPrefix;
101+
}
102+
}
103+
97104
return .{
98105
.site_root = arena.allocator().dupe(u8, site_root) catch return error.MemoryError,
99106
.out_dir = arena.allocator().dupe(u8, out_dir_path) catch return error.MemoryError,
@@ -190,6 +197,10 @@ pub fn main() !void {
190197
log.err("Provided site root directory does not exist. Exiting.", .{});
191198
process.exit(1);
192199
},
200+
BuildCommand.ParseError.MalformedUrlPrefix => {
201+
log.err("Provided url prefix is invalid. Note that the url prefix must begin with a '/' character.", .{});
202+
process.exit(1);
203+
},
193204
else => process.exit(1),
194205
};
195206
defer build.deinit();

src/mustache.zig

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,20 @@ fn MustacheWriterType(comptime Context: type, comptime Writer: type) type {
320320
}
321321

322322
if (mem.eql(u8, key, "theme.head")) {
323-
return try fmt.allocPrint(
324-
ctx.arena,
325-
\\<link rel="stylesheet" type="text/css" href="/bulma.css" />
326-
,
327-
.{},
328-
);
323+
return if (ctx.context.site_root.len == 0)
324+
try fmt.allocPrint(
325+
ctx.arena,
326+
\\<link rel="stylesheet" type="text/css" href="/bulma.css" />
327+
,
328+
.{},
329+
)
330+
else
331+
try fmt.allocPrint(
332+
ctx.arena,
333+
\\<link rel="stylesheet" type="text/css" href="{[site_root]s}/bulma.css" />
334+
,
335+
.{ .site_root = ctx.context.site_root },
336+
);
329337
} else if (mem.eql(u8, key, "theme.body")) {
330338
// theme.body can be used by themes to inject e.g. scripts.
331339
// It's currently empty, but content authors are still recommended

0 commit comments

Comments
 (0)