From caa1e26a933a76a6e70cb010c908eaba349fd05d Mon Sep 17 00:00:00 2001 From: Robert Prehn <3952444+prehnRA@users.noreply.github.com> Date: Sat, 23 Sep 2023 17:15:30 +0000 Subject: [PATCH] feat: Add various styles --- assets/css/app.css | 27 +++++++++-- assets/tailwind.config.js | 2 +- lib/pre_dot_hn.ex | 98 +++++++++++++++++++++++++++++--------- lib/pre_dot_hn/markdown.ex | 14 ------ site/pages/about.md | 4 +- 5 files changed, 102 insertions(+), 43 deletions(-) diff --git a/assets/css/app.css b/assets/css/app.css index 7df1242..a517edc 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -3,18 +3,31 @@ @import "tailwindcss/utilities"; html { - --base-font-size: 16.666667; - --base-line-height: 1.32; + --base-font-size: 20; + --base-line-height: 1.3; --font-size: calc(var(--base-font-size) * 1px); --line-height: calc(var(--base-line-height) * 1rem); --base-vspace: calc(var(--base-line-height) * var(--base-font-size)); --vspace: calc(var(--base-vspace) * 1px); + --line-trim: -0.6666666666666667px; font-size: var(--font-size); line-height: var(--line-height); } .container { - max-width: 80ch; + max-width: 65ch; +} + +a { + @apply text-blue; +} + +a::before { + /* content: "⇲"; */ +} + +nav a { + @apply text-dark; } .box { @@ -28,6 +41,14 @@ p { margin-bottom: var(--vspace); } +a { + display: inline-block; +} + +a:hover { + @apply bg-light text-dark; +} + @font-face { font-family: "JetBrainsMono"; src: url("/fonts/JetBrainsMono-VariableFont_wght.ttf"); diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index 37290af..633faeb 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -17,7 +17,7 @@ module.exports = { blue: 'rgb(93, 110, 238)', magenta: 'rgb(211, 48, 233)', cyan: 'rgb(139, 243, 231)', - light: 'rgb(181, 190, 255)' + light: 'rgb(218, 222, 255)'// 'rgb(181, 190, 255)' }, fontSize: { // xs: ['0.75rem', { lineHeight: '1rem' }], diff --git a/lib/pre_dot_hn.ex b/lib/pre_dot_hn.ex index d3743e2..45e82a9 100644 --- a/lib/pre_dot_hn.ex +++ b/lib/pre_dot_hn.ex @@ -37,27 +37,61 @@ defmodule PreDotHn do def validate(other), do: {:ok, other} def run() do - "site/**/*.md" - |> Path.wildcard() - |> Enum.map(&read/1) - |> Enum.map(&validate/1) - |> Enum.filter(fn - {:error, error} -> - Logger.warn(error) + posts = + "site/**/*.md" + |> Path.wildcard() + |> Enum.map(&read/1) + |> Enum.map(&validate/1) + |> Enum.filter(fn + {:error, error} -> + Logger.warn(error) - false + false - {:ok, _other} -> - true - end) - |> Enum.map(fn {:ok, page} -> - page = - page |> Enum.map(fn {key, value} -> {String.to_atom(key), value} end) |> Enum.into(%{}) + {:ok, _other} -> + true + end) + |> Enum.map(&elem(&1, 1)) + |> Enum.sort_by(&Map.get(&1, "date"), :desc) + |> Enum.map(&atomize_keys/1) - write_page(page) - end) + index = make_index(posts) + + Enum.map([index | posts], &write_page/1) end + def atomize_keys(page) do + page + |> Enum.map(fn {key, value} -> {String.to_atom(key), value} end) + |> Enum.into(%{}) + end + + def make_index(posts) do + assigns = %{posts: posts} + + body = + ~H""" +