Skip to content

Commit c13fcca

Browse files
committed
feat: initial refactor for 11ty based site building
1 parent bb29236 commit c13fcca

13 files changed

+6100
-98
lines changed

Dockerfile

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
FROM node:20-alpine AS site_builder
2+
WORKDIR /app
3+
COPY ./www .
4+
5+
RUN npm i \
6+
; npm run build \
7+
; rm -rf ./static \
8+
; ln -sf ./www/_site ./static
9+
10+
111
FROM golang:1.19
212
WORKDIR /app
313

@@ -8,12 +18,8 @@ ENV GOBLIN_ORIGIN_URL="http://goblin.run"
818
ENV ORIGIN_URL="http://goblin.run"
919

1020
COPY . ./
11-
RUN cd www \
12-
;make installLinux \
13-
;make build \
14-
;cd .. \
15-
;rm -rf ./static \
16-
;ln -sf ./www/dist ./static
21+
RUN rm -rf ./static ./www
22+
COPY --from=site_builder /app/_site ./static
1723

1824
RUN go build -o ./goblin-api ./cmd/goblin-api
1925

www/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
/bin/
22
/node_modules/
3-
dist
3+
_site

www/.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v20.12.2

www/Makefile

-42
This file was deleted.

www/_data/meta.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require("dotenv").config();
2+
3+
module.exports = function () {
4+
return {
5+
originUrl: process.env.GOBLIN_ORIGIN_URL || "http://goblin.run",
6+
};
7+
};

www/pages/_layout.html renamed to www/_includes/layout.njk

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<meta name="description" content="Install Go binaries—without Go." />
88
<meta property="og:image" content="/opengraph-image.jpg" />
99
<link rel="stylesheet" href="/style.css" />
10+
1011
<title>Goblin</title>
1112

1213
<script
@@ -93,7 +94,7 @@
9394

9495
<nav
9596
aria-label="Primary navigation"
96-
class="flex justify-between items-center mx-auto animate-kids fade-in-y h-header-height max-w-content px-page-gutter"
97+
class="flex items-center justify-between mx-auto animate-kids fade-in-y h-header-height max-w-content px-page-gutter"
9798
style="--from: -10px; --delay: 5"
9899
>
99100
<a href="#" aria-label="Goto top of the page">
@@ -170,15 +171,15 @@ <h1 class="text-4xl font-bold tracking-tight sm:text-6xl">
170171
</p>
171172

172173
<div style="--delay: 1" class="relative">
173-
<pre><code class="language-command">curl -sf http://goblin.run/github.com/rakyll/hey | sh</code></pre>
174-
<div class="flex absolute inset-y-0 right-3 items-center">
174+
<pre><code class="language-command">curl -sf {{ meta.originUrl }}/github.com/rakyll/hey | sh</code></pre>
175+
<div class="absolute inset-y-0 flex items-center right-3">
175176
<button
176177
@click="() => {
177178
$data.copied = true
178179
setTimeout(() => { $data.copied = false }, 1500)
179180
$clipboard('curl -sf http://goblin.run/github.com/rakyll/hey | sh')
180181
}"
181-
class="flex justify-center items-center w-7 h-7 rounded shadow transition-all cursor-copy bg-base text-subtle hover:text-text hover:shadow-md"
182+
class="flex items-center justify-center transition-all rounded shadow w-7 h-7 cursor-copy bg-base text-subtle hover:text-text hover:shadow-md"
182183
>
183184
<template x-if="$data.copied">
184185
<svg
@@ -226,28 +227,28 @@ <h1 class="text-4xl font-bold tracking-tight sm:text-6xl">
226227
<div style="--delay: 2">
227228
<a
228229
href="#introduction"
229-
class="inline-flex px-6 py-3 text-sm font-semibold bg-gradient-to-br rounded-md transition-shadow from-primary to-secondary text-surface hover:shadow"
230+
class="inline-flex px-6 py-3 text-sm font-semibold transition-shadow rounded-md bg-gradient-to-br from-primary to-secondary text-surface hover:shadow"
230231
>Get Started</a
231232
>
232233
</div>
233234
</section>
234235

235236
<article id="introduction">
236237
<p
237-
class="p-3 text-sm font-medium rounded-md border border-primary bg-primary/10 text-primary sm:p-6"
238+
class="p-3 text-sm font-medium border rounded-md border-primary bg-primary/10 text-primary sm:p-6"
238239
>
239240
If you get value from using Goblin, please consider
240241
<a href="https://github.com/sponsors/barelyhuman" class="link"
241242
><b>donating</b></a
242243
>. This helps cover server costs and supports my open source work.
243244
</p>
244245

245-
{{ .Content }}
246+
{{ content | safe }}
246247
</article>
247248
</main>
248249

249250
<footer class="mx-auto mt-page-top max-w-content px-page-gutter">
250-
<div class="flex gap-3 justify-between items-center py-6 border-t">
251+
<div class="flex items-center justify-between gap-3 py-6 border-t">
251252
<a
252253
href="https://github.com/barelyhuman/goblin"
253254
class="text-sm transition text-subtle hover:text-text"
@@ -262,4 +263,4 @@ <h1 class="text-4xl font-bold tracking-tight sm:text-6xl">
262263
</div>
263264
</footer>
264265
</body>
265-
</html>
266+
</html>

www/hooks/define-env.lua

-14
This file was deleted.

www/pages/index.md renamed to www/index.md

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
---
2+
layout: layout.njk
3+
---
4+
15
## Usage
26

37
Install `package` with optional `@version` and `options`:
48

59
```command
6-
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/<package>[@version] | [...options] sh
10+
curl -sf {{ meta.originUrl }}/<package>[@version] | [...options] sh
711
```
812

913
## API
@@ -58,25 +62,25 @@ gopkg.in/yaml.v2
5862
Install the latest version:
5963

6064
```command
61-
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/github.com/rakyll/hey | sh
65+
curl -sf {{ meta.originUrl }}/github.com/rakyll/hey | sh
6266
```
6367

6468
Specify package version:
6569

6670
```command
67-
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/github.com/barelyhuman/[email protected] | sh
71+
curl -sf {{ meta.originUrl }}/github.com/barelyhuman/[email protected] | sh
6872
```
6973

7074
Or use commit hashes:
7175

7276
```command
73-
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/github.com/barelyhuman/commitlog@bba8d7a63d622e4f12dbea9722b647cd985be8ad | sh
77+
curl -sf {{ meta.originUrl }}/github.com/barelyhuman/commitlog@bba8d7a63d622e4f12dbea9722b647cd985be8ad | sh
7478
```
7579

7680
Use alternative sources:
7781

7882
```command
79-
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/golang.org/x/tools/godoc | sh
83+
curl -sf {{ meta.originUrl }}/golang.org/x/tools/godoc | sh
8084
```
8185

8286
Specify nested packages
@@ -85,11 +89,11 @@ Specify nested packages
8589
> call. If you use something like `spf13/cobra` then check the 2nd example.
8690
8791
```command
88-
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/vito/bass/cmd/bass | sh
92+
curl -sf {{ meta.originUrl }}/vito/bass/cmd/bass | sh
8993
```
9094

9195
```command
92-
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/gnorm.org/gnorm | CMD_PATH="/cli" PREFIX=./bin sh
96+
curl -sf {{ meta.originUrl }}/gnorm.org/gnorm | CMD_PATH="/cli" PREFIX=./bin sh
9397
```
9498

9599
## How does it work?
@@ -105,7 +109,7 @@ operating system, architecture, package version, and the binary's name—using G
105109
**Example response**
106110

107111
```sh
108-
{{.Data.env.GOBLIN_ORIGIN_URL}}/binary/github.com/rakyll/hey?os=darwin&arch=amd64&version=v0.1.3&out=hey
112+
{{ meta.originUrl }}/binary/github.com/rakyll/hey?os=darwin&arch=amd64&version=v0.1.3&out=hey
109113
```
110114

111-
_Note: compilation is limited to 200 seconds due to timeout restrictions._
115+
_Note: compilation is limited to 200 seconds due to timeout restrictions._

0 commit comments

Comments
 (0)