Drop _config.yml — fold its values into constants in lib/build.rb
This is one specific site deployed to one specific place; its title, URL,
baseurl, repo, and language aren't going to vary per environment, so a
YAML file to load them from was another small piece of Jekyll's shape
(a config file) kept out of habit rather than need. Also drops `tagline`,
which the YAML carried but nothing ever rendered — a dead value that a
plain CONFIG hash doesn't surface the way an unused constant would.
Rakefile's serve task now reads BASEURL directly instead of loading
_config.yml a second time just for that one key.
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
index 99382ee..bfc8ad8 100644
--- a/.github/workflows/pages.yml
+++ b/.github/workflows/pages.yml
@@ -7,10 +7,10 @@ on:
pull_request:
workflow_dispatch:
-# The site is its own small Ruby/ERB build (see lib/arbitrary_definitions/
-# site_builder.rb and Rakefile) rather than Jekyll, so it has to build on
-# Actions rather than GitHub's hosted Jekyll build regardless — this also
-# pins the build to Ruby 4.0 rather than whatever Ruby GitHub Pages uses.
+# The site is its own small Ruby/ERB build (see lib/build.rb and Rakefile)
+# rather than Jekyll, so it has to build on Actions rather than GitHub's
+# hosted Jekyll build regardless — this also pins the build to Ruby 4.0
+# rather than whatever Ruby GitHub Pages uses.
permissions:
contents: read
pages: write
@@ -38,10 +38,10 @@ jobs:
- name: Report the toolchain
run: ruby -v
- # The baseurl comes from _config.yml rather than actions/configure-pages,
- # so the build does not depend on the Pages API being reachable and stays
- # green on branches and forks. Change it there if the site ever moves off
- # a project page.
+ # BASEURL is a constant in lib/build.rb rather than coming from
+ # actions/configure-pages, so the build does not depend on the Pages API
+ # being reachable and stays green on branches and forks. Change it
+ # there if the site ever moves off a project page.
- name: Build
run: bundle exec rake build
diff --git a/README.md b/README.md
index de97d42..53d06d5 100644
--- a/README.md
+++ b/README.md
@@ -79,7 +79,7 @@ to **GitHub Actions**. The workflow token is not permitted to turn Pages on
by itself, so the `deploy` job fails until this is done — the `build` job
runs regardless.
-The site's `baseurl` lives in `_config.yml` rather than coming from
+The site's `BASEURL` is a constant in `lib/build.rb` rather than coming from
`actions/configure-pages`, which keeps the build independent of the Pages
API. Change it there if the site ever moves off a project page.
diff --git a/Rakefile b/Rakefile
index ab3e3ec..b292c78 100644
--- a/Rakefile
+++ b/Rakefile
@@ -11,19 +11,17 @@ end
desc "Serve the already-built site at http://127.0.0.1:4000"
task :serve do
require "webrick"
- require "yaml"
+ require "build"
site_dir = File.expand_path("_site", __dir__)
abort "_site is empty — run `bundle exec rake build` first" unless Dir.exist?(site_dir)
- # Every link the build emits is prefixed with `baseurl` (see relative_url
- # in lib/build.rb), so the site has to be mounted under that same path
+ # Every link the build emits is prefixed with BASEURL (see relative_url in
+ # lib/build.rb), so the site has to be mounted under that same path
# locally, the way `jekyll serve` used to.
- baseurl = YAML.safe_load_file(File.expand_path("_config.yml", __dir__)).fetch("baseurl", "")
-
server = WEBrick::HTTPServer.new(Port: 4000, BindAddress: "127.0.0.1", DocumentRoot: site_dir)
- server.mount(baseurl.empty? ? "/" : baseurl, WEBrick::HTTPServlet::FileHandler, site_dir)
- puts "http://127.0.0.1:4000#{baseurl}/"
+ server.mount(BASEURL.empty? ? "/" : BASEURL, WEBrick::HTTPServlet::FileHandler, site_dir)
+ puts "http://127.0.0.1:4000#{BASEURL}/"
trap("INT") { server.shutdown }
server.start
diff --git a/_config.yml b/_config.yml
deleted file mode 100644
index 08d624d..0000000
--- a/_config.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-title: Arbitrary Definitions
-tagline: A personal umbrella, given a shared visual spine
-description: >-
- Arbitrary Definitions is a personal design system for self-hosted,
- single-user tools — synthesized from three real running projects, not
- written from a spec. Sixteen components and five foundations, built with a
- small Ruby/ERB site builder running on Ruby 4.0.
-
-url: https://kejadlen.github.io
-baseurl: /arbitrary-definitions-design-system
-repository: kejadlen/arbitrary-definitions-design-system
-lang: en
diff --git a/_layouts/page.erb b/_layouts/page.erb
index 8bd11b6..74ed742 100644
--- a/_layouts/page.erb
+++ b/_layouts/page.erb
@@ -5,19 +5,19 @@
VERSION are constants from lib/build.rb, and relative_url/escape are
plain top-level methods. %>
<!DOCTYPE html>
-<html lang="<%= CONFIG.fetch("lang", "en") %>">
+<html lang="<%= LANG %>">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#faf9f7" media="(prefers-color-scheme: light)">
<meta name="theme-color" content="#0e0d0b" media="(prefers-color-scheme: dark)">
-<title><%= title %> | <%= CONFIG.fetch("title") %></title>
+<title><%= title %> | <%= TITLE %></title>
<meta name="description" content="<%= escape(description) %>">
-<link rel="canonical" href="<%= CONFIG.fetch("url") %><%= relative_url(url) %>">
+<link rel="canonical" href="<%= SITE_URL %><%= relative_url(url) %>">
<meta property="og:title" content="<%= escape(title) %>">
-<meta property="og:site_name" content="<%= escape(CONFIG.fetch("title")) %>">
-<meta property="og:url" content="<%= CONFIG.fetch("url") %><%= relative_url(url) %>">
+<meta property="og:site_name" content="<%= escape(TITLE) %>">
+<meta property="og:url" content="<%= SITE_URL %><%= relative_url(url) %>">
<meta property="og:description" content="<%= escape(description) %>">
<!-- The system's one loaded webfont — see assets/css/tokens.css. Sans is a
@@ -71,7 +71,7 @@
</svg>
<span class="ad-visually-hidden" data-theme-label>Theme</span>
</button>
- <a class="btn" data-size="sm" href="https://github.com/<%= CONFIG.fetch("repository") %>">Source</a>
+ <a class="btn" data-size="sm" href="https://github.com/<%= REPOSITORY %>">Source</a>
</div>
</div>
</header>
@@ -104,8 +104,8 @@
<footer class="ad-doc-footer">
<div class="ad-doc-footer__inner">
- <p><%= CONFIG.fetch("title") %> v<%= VERSION %> — built with Ruby <%= RUBY_VERSION %>.</p>
- <p><a href="https://github.com/<%= CONFIG.fetch("repository") %>">View the source</a></p>
+ <p><%= TITLE %> v<%= VERSION %> — built with Ruby <%= RUBY_VERSION %>.</p>
+ <p><a href="https://github.com/<%= REPOSITORY %>">View the source</a></p>
</div>
</footer>
diff --git a/lib/build.rb b/lib/build.rb
index cd601e1..5a56bb7 100644
--- a/lib/build.rb
+++ b/lib/build.rb
@@ -22,10 +22,24 @@ require "kramdown-parser-gfm"
ROOT = File.expand_path("..", __dir__)
SITE = File.join(ROOT, "_site")
-CONFIG = YAML.safe_load_file(File.join(ROOT, "_config.yml"))
NAV = YAML.safe_load_file(File.join(ROOT, "_data", "nav.yml"))
VERSION = "2.0.0"
+# This is one specific site, deployed to one specific place — these aren't
+# going to vary per environment, so they're constants rather than a config
+# file to load. (The previous _config.yml also carried a `tagline` key
+# nothing ever rendered — a small config file with a dead entry is exactly
+# the kind of thing that's easy to miss when it's not just a constant.)
+TITLE = "Arbitrary Definitions"
+DESCRIPTION = "Arbitrary Definitions is a personal design system for self-hosted, " \
+ "single-user tools — synthesized from three real running projects, not " \
+ "written from a spec. Sixteen components and five foundations, built with a " \
+ "small Ruby/ERB site builder running on Ruby 4.0."
+SITE_URL = "https://kejadlen.github.io"
+BASEURL = "/arbitrary-definitions-design-system"
+REPOSITORY = "kejadlen/arbitrary-definitions-design-system"
+LANG = "en"
+
# Plain CSS files, concatenated in this order into assets/css/style.css:
# reset/base first, then components, then this site's own chrome.
CSS_FILES = %w[
@@ -58,7 +72,7 @@ PAGES = [
# page bodies (a handful link to other pages) and the layout.
def relative_url(path)
path = "/#{path}" unless path.start_with?("/")
- "#{CONFIG.fetch("baseurl", "").chomp("/")}#{path}"
+ "#{BASEURL.chomp("/")}#{path}"
end
def escape(value) = CGI.escapeHTML(value.to_s)
@@ -101,7 +115,7 @@ def render_page(source_path, url, section)
html = render_shell(
title: front.fetch("title"),
- description: front["description"] || front["summary"] || CONFIG["description"],
+ description: front["description"] || front["summary"] || DESCRIPTION,
url: url,
body: body,
)