Skip to content

Commit 25151db

Browse files
committed
Add Twitter card for Nanoglyphs
1 parent b7e812c commit 25151db

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

build.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,10 +2446,20 @@ func renderNanoglyph(ctx context.Context, c *modulir.Context, source string,
24462446
issue.HookImageURL = "/assets/images/nanoglyphs/" + issue.Slug + "/hook." + format
24472447
}
24482448

2449+
var card *twitterCard
2450+
if issue.ImageURL != "" {
2451+
card = &twitterCard{
2452+
Title: fmt.Sprintf("Nanoglyph %s — %s", issue.Number, issue.Title),
2453+
Description: string(issue.Hook),
2454+
ImageURL: issue.ImageURL,
2455+
}
2456+
}
2457+
24492458
locals := getLocals(map[string]any{
2450-
"InEmail": false,
2451-
"Issue": issue,
2452-
"URLPrefix": "", // Relative prefix for the web version
2459+
"InEmail": false,
2460+
"Issue": issue,
2461+
"TwitterCard": card,
2462+
"URLPrefix": "", // Relative prefix for the web version
24532463
})
24542464

24552465
err = dependencies.renderGoTemplate(ctx, c, sourceTmpl, path.Join(c.TargetDir, "nanoglyphs", issue.Slug), locals)

layouts/nanoglyphs.tmpl.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
{{- /* Served by Modulir itself (but only if websockets are enabled). */ -}}
2121
<script src="/websocket.js" type="text/javascript"></script>
2222
{{end -}}
23+
24+
{{template "views/_twitter.tmpl.html" .}}
2325
{{end}}
2426

2527
<style type="text/css">
@@ -478,4 +480,4 @@
478480
{{end}}
479481
</body>
480482

481-
</html>
483+
</html>

0 commit comments

Comments
 (0)