Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
fix(default.md): correct typo in author field from "autor" to "author…
Browse files Browse the repository at this point in the history
…" for consistency

feat(default.md): add support for draft field to mark content as draft
feat(day1-aoc-daniel.md): add new project page for AoC - Day 1 with Elixir & OCaml code
fix(list.html): improve styling of list items with flexbox layout and add author name to each post
  • Loading branch information
Daniel-Boll committed Dec 1, 2023
1 parent 18f99da commit 0a7c007
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 6 deletions.
2 changes: 1 addition & 1 deletion archetypes/default.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
autor: "gnussy contributors"
author: "gnussy contributors"
title: "{{ replace .Name "-" " " | title }}"
date: {{ .Date }}
draft: true
Expand Down
37 changes: 37 additions & 0 deletions content/projects/day1-aoc-daniel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
author: "Daniel Boll"
title: "AoC - Day 1"
date: 2023-12-01T09:44:14-03:00
description: "Using Elixir & OCaml"
draft: false
---

Uh, hi?

```elixir
defmodule Day1 do
@spec part_one(String.t()) :: integer()
def part_one(file) do
load_file(file)
|> Enum.map(fn calibration ->
numbers =
calibration
|> String.split("")
|> Enum.filter(&Regex.match?(~r/\d/, &1))

numbers
|> Kernel.hd()
|> Kernel.<>(List.last(numbers))
|> String.to_integer()
end)
|> Enum.sum()
end

@spec load_file(String.t()) :: [String.t()]
def load_file(file) do
File.read!(file)
|> String.trim_trailing()
|> String.split("\n")
end
end
```
42 changes: 37 additions & 5 deletions themes/tuna/layouts/_default/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,46 @@
{{ .Content }}
</p>
{{ range .Pages }}
<a href="{{ .Permalink }}">{{ .Title }}</a>
<div class="sub-sub-title">
<div class="post">
<div class="author-name">
[{{ .Params.author }}]
</div>
<div class="headline">
<a href="{{ .Permalink }}">{{ .Title }}</a> :: {{ .Description }}
</div>
<div class="sub-sub-title">
<span class="date">
{{ .Date.Format "2006 January 2" }}
</span> - {{ .Description }}
{{ .Date.Format "2006 January 2" }}
</span>
</div>
</div>
<br>
{{ end }}
</div>
</div>
<style>
.post {
display: flex;
flex-direction: column;
gap: 0.5rem;
padding: 1rem;
font-size: 0.8em;
line-height: 1;
border-radius: 0.25em;
background: rgba(27,31,35,0.05);
color: #24292e;
text-decoration: none;
border: 1px solid rgba(27,31,35,0.1);
max-width: 20rem;
}

.post .sub-sub-title {
font-size: 0.8em;
color: #586069;
}

.author-name {
font-weight: bold;
font-size: 1.2em;
}
</style>
{{ end }}

0 comments on commit 0a7c007

Please sign in to comment.