Skip to content
This repository has been archived by the owner on Jan 5, 2025. It is now read-only.

Commit

Permalink
Fix typo and add footer
Browse files Browse the repository at this point in the history
  • Loading branch information
pepicrft committed Jun 26, 2024
1 parent 17a8886 commit 360999e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .formatter.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
import_deps: [:ecto, :phoenix],
inputs: ["*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
inputs: ["*.{heex,ex,exs}", "{config,lib,test}/**/*.{heex,ex,exs}", "*.{ex,exs}", "priv/*/seeds.exs", "{config,lib,test}/**/*.{ex,exs}"],
subdirectories: ["priv/*/migrations"],
plugins: [Phoenix.LiveView.HTMLFormatter]
]
8 changes: 6 additions & 2 deletions lib/pepicrft/blog/post.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ defmodule Pepicrft.Blog.Post do
"""
@enforce_keys [
:path,
:relative_path,
:slug,
:title,
:description,
:date,
:tags,
:body,
:og_image_slug,
:og_image_path
:og_image_path,
]
defstruct [
:path,
:relative_path,
:slug,
:title,
:description,
Expand All @@ -35,7 +37,8 @@ defmodule Pepicrft.Blog.Post do
@type attributes :: any
@spec build(String.t(), attributes, String.t()) :: %Pepicrft.Blog.Post{}
def build(path, %{"title" => title, "tags" => tags} = frontmatter, body) do
filename_without_extension = path |> Path.rootname() |> Path.split() |> Enum.take(-1) |> hd
filename_without_extension = path |> Path.rootname() |> Path.split() |> Enum.at(-1)
relative_path = "/priv/" <> (Path.relative_to_cwd(path) |> String.split("/priv/") |> Enum.at(-1))
[year, month, day] = filename_without_extension |> String.split("-") |> Enum.take(3)
date = Date.from_iso8601!("#{year}-#{month}-#{day}")

Expand All @@ -54,6 +57,7 @@ defmodule Pepicrft.Blog.Post do
struct!(
__MODULE__,
path: path,
relative_path: relative_path,
slug: slug,
title: title,
date: date,
Expand Down
14 changes: 12 additions & 2 deletions lib/pepicrft_web/controllers/blog_html/show.html.heex
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@

<% date_as_string = Timex.format!(@post.date, "%Y.%m.%d", :strftime) %>
<h1 class="pp-Post_Title"><%= @post.title %></h1>
<p class="pp-Post_TimeAgo"><%= date_as_string %></p>

<div class="pp-Post_Body">
<%= raw @post.body %>
<%= raw(@post.body) %>
</div>

<footer>
<p class="pp-Post_Footer">
<small>
© <time datetime="2024">2024</time>
Pedro Piñera. The post is licensed under
<a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a>
and available as markdown <a href={"https://github.com/pepicrft/website/blob/main#{@post.relative_path}"}>here</a>.
</small>
</p>
</footer>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ but it's a whole different approach to building, debugging, and testing software
Is it worth it?
What's clear though is that there's something unique in the functional programming paradigm that we can't ignore.
When the state is mutated as it's passed around,
data race problems and gone and you can take full advantage of the hardware where the software is running.
data race problems are gone and you can take full advantage of the hardware where the software is running.
Your production servers and development scales by throwing more CPU cores and memory.
Does your test suite take a long time to execute? Increase its parallelism.
And the best part? You can do that without being worried about flakiness levels increasing.
Expand Down

0 comments on commit 360999e

Please sign in to comment.