Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial refactor for 11ty based site building #19

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
FROM node:20-alpine AS site_builder
WORKDIR /app
COPY ./www .

RUN npm i \
; npm run build \
; rm -rf ./static \
; ln -sf ./www/_site ./static


FROM golang:1.19
WORKDIR /app

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

COPY . ./
RUN cd www \
;make installLinux \
;make build \
;cd .. \
;rm -rf ./static \
;ln -sf ./www/dist ./static
RUN rm -rf ./static ./www
COPY --from=site_builder /app/_site ./static

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

Expand Down
2 changes: 1 addition & 1 deletion www/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/bin/
/node_modules/
dist
_site
1 change: 1 addition & 0 deletions www/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v20.12.2
42 changes: 0 additions & 42 deletions www/Makefile

This file was deleted.

7 changes: 7 additions & 0 deletions www/_data/meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require("dotenv").config();

module.exports = function () {
return {
originUrl: process.env.GOBLIN_ORIGIN_URL || "http://goblin.run",
};
};
19 changes: 10 additions & 9 deletions www/pages/_layout.html → www/_includes/layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<meta name="description" content="Install Go binaries—without Go." />
<meta property="og:image" content="/opengraph-image.jpg" />
<link rel="stylesheet" href="/style.css" />

<title>Goblin</title>

<script
Expand Down Expand Up @@ -93,7 +94,7 @@

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

<div style="--delay: 1" class="relative">
<pre><code class="language-command">curl -sf http://goblin.run/github.com/rakyll/hey | sh</code></pre>
<div class="flex absolute inset-y-0 right-3 items-center">
<pre><code class="language-command">curl -sf {{ meta.originUrl }}/github.com/rakyll/hey | sh</code></pre>
<div class="absolute inset-y-0 flex items-center right-3">
<button
@click="() => {
$data.copied = true
setTimeout(() => { $data.copied = false }, 1500)
$clipboard('curl -sf http://goblin.run/github.com/rakyll/hey | sh')
}"
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"
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"
>
<template x-if="$data.copied">
<svg
Expand Down Expand Up @@ -226,28 +227,28 @@ <h1 class="text-4xl font-bold tracking-tight sm:text-6xl">
<div style="--delay: 2">
<a
href="#introduction"
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"
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"
>Get Started</a
>
</div>
</section>

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

{{ .Content }}
{{ content | safe }}
</article>
</main>

<footer class="mx-auto mt-page-top max-w-content px-page-gutter">
<div class="flex gap-3 justify-between items-center py-6 border-t">
<div class="flex items-center justify-between gap-3 py-6 border-t">
<a
href="https://github.com/barelyhuman/goblin"
class="text-sm transition text-subtle hover:text-text"
Expand All @@ -262,4 +263,4 @@ <h1 class="text-4xl font-bold tracking-tight sm:text-6xl">
</div>
</footer>
</body>
</html>
</html>
14 changes: 0 additions & 14 deletions www/hooks/define-env.lua

This file was deleted.

22 changes: 13 additions & 9 deletions www/pages/index.md → www/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
---
layout: layout.njk
---

## Usage

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

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

## API
Expand Down Expand Up @@ -58,25 +62,25 @@ gopkg.in/yaml.v2
Install the latest version:

```command
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/github.com/rakyll/hey | sh
curl -sf {{ meta.originUrl }}/github.com/rakyll/hey | sh
```

Specify package version:

```command
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/github.com/barelyhuman/[email protected] | sh
curl -sf {{ meta.originUrl }}/github.com/barelyhuman/[email protected] | sh
```

Or use commit hashes:

```command
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/github.com/barelyhuman/commitlog@bba8d7a63d622e4f12dbea9722b647cd985be8ad | sh
curl -sf {{ meta.originUrl }}/github.com/barelyhuman/commitlog@bba8d7a63d622e4f12dbea9722b647cd985be8ad | sh
```

Use alternative sources:

```command
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/golang.org/x/tools/godoc | sh
curl -sf {{ meta.originUrl }}/golang.org/x/tools/godoc | sh
```

Specify nested packages
Expand All @@ -85,11 +89,11 @@ Specify nested packages
> call. If you use something like `spf13/cobra` then check the 2nd example.

```command
curl -sf {{.Data.env.GOBLIN_ORIGIN_URL}}/vito/bass/cmd/bass | sh
curl -sf {{ meta.originUrl }}/vito/bass/cmd/bass | sh
```

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

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

```sh
{{.Data.env.GOBLIN_ORIGIN_URL}}/binary/github.com/rakyll/hey?os=darwin&arch=amd64&version=v0.1.3&out=hey
{{ meta.originUrl }}/binary/github.com/rakyll/hey?os=darwin&arch=amd64&version=v0.1.3&out=hey
```

_Note: compilation is limited to 200 seconds due to timeout restrictions._
_Note: compilation is limited to 200 seconds due to timeout restrictions._
Loading
Loading