From 58dffeadb367bc6bc12d38e7961fcd6d6aa1f7e6 Mon Sep 17 00:00:00 2001 From: sloane <1699281+sloanelybutsurely@users.noreply.github.com> Date: Sat, 24 Feb 2024 08:43:08 -0500 Subject: [PATCH] more style / layout updates --- assets/tailwind.config.js | 1 + lib/sloane_sh/config.ex | 4 ++-- lib/sloane_sh/layouts.ex | 3 +++ lib/sloane_sh/layouts/partials.ex | 15 ++++++++++----- lib/sloane_sh/markdown.ex | 15 ++------------- lib/sloane_sh/write.ex | 2 +- priv/site/layouts/page.html.eex | 5 ++++- priv/site/layouts/post.html.eex | 8 ++++---- priv/site/layouts/root.html.eex | 9 +++------ priv/site/pages/about.md | 6 ------ priv/site/pages/index.md | 12 ++++++------ 11 files changed, 36 insertions(+), 44 deletions(-) delete mode 100644 priv/site/pages/about.md diff --git a/assets/tailwind.config.js b/assets/tailwind.config.js index 9f0624b..4c2f640 100644 --- a/assets/tailwind.config.js +++ b/assets/tailwind.config.js @@ -17,6 +17,7 @@ module.exports = { }, plugins: [ require('@tailwindcss/forms'), + require('@tailwindcss/typography'), plugin(({addVariant}) => addVariant('phx-no-feedback', ['&.phx-no-feedback', '.phx-no-feedback &'])), plugin(({addVariant}) => addVariant('phx-click-loading', ['&.phx-click-loading', '.phx-click-loading &'])), plugin(({addVariant}) => addVariant('phx-submit-loading', ['&.phx-submit-loading', '.phx-submit-loading &'])), diff --git a/lib/sloane_sh/config.ex b/lib/sloane_sh/config.ex index 07c16e7..9995fc7 100644 --- a/lib/sloane_sh/config.ex +++ b/lib/sloane_sh/config.ex @@ -9,7 +9,7 @@ defmodule SloaneSH.Config do typedstruct do field :pages_dir, String.t(), enforce: true field :posts_dir, String.t(), enforce: true - field :output, String.t(), enforce: true + field :output_dir, String.t(), enforce: true end def default do @@ -18,7 +18,7 @@ defmodule SloaneSH.Config do %Config{ pages_dir: Path.join(priv, "site/pages"), posts_dir: Path.join(priv, "site/posts"), - output: Path.join(priv, "output") + output_dir: Path.join(priv, "output") } end diff --git a/lib/sloane_sh/layouts.ex b/lib/sloane_sh/layouts.ex index a2c909f..8af41a1 100644 --- a/lib/sloane_sh/layouts.ex +++ b/lib/sloane_sh/layouts.ex @@ -24,4 +24,7 @@ defmodule SloaneSH.Layouts do :attrs, :inner_content ]) + + defp prefix_title(prefix, nil), do: prefix + defp prefix_title(prefix, page_title), do: [prefix, " | ", page_title] end diff --git a/lib/sloane_sh/layouts/partials.ex b/lib/sloane_sh/layouts/partials.ex index ac0d243..d592538 100644 --- a/lib/sloane_sh/layouts/partials.ex +++ b/lib/sloane_sh/layouts/partials.ex @@ -8,13 +8,18 @@ defmodule SloaneSH.Layouts.Partials do :def, :header, ~S""" -
-

sloane.sh

-
""", [:ctx, :attrs] ) diff --git a/lib/sloane_sh/markdown.ex b/lib/sloane_sh/markdown.ex index 9c6becc..db72084 100644 --- a/lib/sloane_sh/markdown.ex +++ b/lib/sloane_sh/markdown.ex @@ -6,6 +6,7 @@ defmodule SloaneSH.Markdown do use TypedStruct alias SloaneSH.Context + alias SloaneSH.FrontMatter alias __MODULE__ typedstruct do @@ -15,22 +16,10 @@ defmodule SloaneSH.Markdown do def transform(%Context{} = ctx, data) when is_binary(data) do data - |> parse_attrs(ctx) + |> FrontMatter.parse(ctx) |> parse_markdown(ctx) end - defp parse_attrs("+++" <> rest, _ctx) do - [toml, body] = String.split(rest, ["+++\n", "+++\r\n"], parts: 2) - - with {:ok, attrs} <- Toml.decode(toml, keys: :atoms) do - {:ok, attrs, body} - end - end - - defp parse_attrs(body, _ctx) do - {:ok, %{}, body} - end - defp parse_markdown({:ok, attrs, body}, _ctx) do with {:ok, html, msgs} <- Earmark.as_html(body) do for msg <- msgs, do: Logger.warning(msg) diff --git a/lib/sloane_sh/write.ex b/lib/sloane_sh/write.ex index 8839021..48da04a 100644 --- a/lib/sloane_sh/write.ex +++ b/lib/sloane_sh/write.ex @@ -12,7 +12,7 @@ defmodule SloaneSH.Write do end def write(ctx, name, data) do - path = Path.join(ctx.config.output, name) + path = Path.join(ctx.config.output_dir, name) with :ok <- File.mkdir_p(Path.dirname(path)) do File.write(path, data) diff --git a/priv/site/layouts/page.html.eex b/priv/site/layouts/page.html.eex index fb81838..769e37d 100644 --- a/priv/site/layouts/page.html.eex +++ b/priv/site/layouts/page.html.eex @@ -1 +1,4 @@ -<%= inner_content %> +<%= header(ctx, attrs) %> +
+ <%= inner_content %> +
diff --git a/priv/site/layouts/post.html.eex b/priv/site/layouts/post.html.eex index 9511d75..eecbd39 100644 --- a/priv/site/layouts/post.html.eex +++ b/priv/site/layouts/post.html.eex @@ -1,5 +1,5 @@ -<%= if attrs[:title] do %> -

<%= attrs[:title] %>

-<% end %> +<%= header(ctx, attrs) %> -<%= inner_content %> +
+ <%= inner_content %> +
diff --git a/priv/site/layouts/root.html.eex b/priv/site/layouts/root.html.eex index 1fecd25..93b89c5 100644 --- a/priv/site/layouts/root.html.eex +++ b/priv/site/layouts/root.html.eex @@ -3,13 +3,10 @@ - sloane.sh | <%= attrs[:title] %> + <%= prefix_title("sloane.sh", attrs[:page_title]) %> - - <%= header(ctx, attrs) %> -
- <%= inner_content %> -
+ + <%= inner_content %> diff --git a/priv/site/pages/about.md b/priv/site/pages/about.md deleted file mode 100644 index 8920003..0000000 --- a/priv/site/pages/about.md +++ /dev/null @@ -1,6 +0,0 @@ -+++ -permalink = "/about" -title = "about" -+++ - -Yes it does!! diff --git a/priv/site/pages/index.md b/priv/site/pages/index.md index aea72c0..0d33d77 100644 --- a/priv/site/pages/index.md +++ b/priv/site/pages/index.md @@ -1,12 +1,12 @@ +++ permalink = "/" -title = "home" +page_title = "home" +++ -# Hello, World! +hey, i'm sloane! i'm a professional software engineer and an amateur musician, photographer, wife, chef, and pet mom. -my name is sloane. i am a software engineer. +#### around the web -i'm on the fediverse [@sloane@tech.lgbt](https://tech.lgbt/@sloane) - -also on [github](https://github.com/sloanelybutsurely). +- [@sloane](https://tech.lgbt/@sloane) on the fediverse +- [@sloanelybutsurely](https://github.com/sloanelybutsurely) on github +- [@sloane_of_arc](https://instagram.com/sloane_of_arc) on instagram