Skip to content

Commit

Permalink
Update note metadata presentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
damiendart committed Sep 23, 2024
1 parent 4600c76 commit c290aa8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion git-filter-metadata.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if [ "$1" = '--smudge' ]; then
CREATED=$(git log --diff-filter=A --follow --format='%H %ct' -1 -- "$1")
LAST_UPDATED=$(git log -n 1 --pretty=format:'%H %ct' -- "$1")

sed "s/\\\$Metadata\\\$/\$Metadata: $CREATED $LAST_UPDATED\$/g"
sed "s#\\\$Metadata\\\$#\$Metadata: $CREATED $LAST_UPDATED $1\$#g"
exit
fi

Expand Down
4 changes: 4 additions & 0 deletions src/sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ a {
color: var(--base-link);
}

aside {
font-style: italic;
}

body {
@include mixins.nice-font-rendering;

Expand Down
3 changes: 2 additions & 1 deletion src/ssg/Steps/ProcessFrontMatterStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,12 @@ private function parseGitMetadataKeyword(string $keyword): GitMetadata
{
$parts = explode(' ', trim($keyword, '$'));

if (5 !== \count($parts)) {
if (5 > \count($parts)) {
throw new \RuntimeException('Unable to parse expanded "Metadata" keyword');
}

return new GitMetadata(
join(' ', \array_slice($parts, 5)),
new \DateTimeImmutable('@' . $parts[2]),
new \DateTimeImmutable('@' . $parts[4]),
$parts[1],
Expand Down
1 change: 1 addition & 0 deletions src/ssg/ValueObjects/GitMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
final readonly class GitMetadata
{
public function __construct(
public string $path,
public \DateTimeImmutable $createdAt = new \DateTimeImmutable(),
public \DateTimeImmutable $updatedAt = new \DateTimeImmutable(),
public string $createdHash = '0000000000000000000000000000000000000000',
Expand Down
9 changes: 5 additions & 4 deletions src/ssg/input/.templates/base-note.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@

{% block content %}
{% if git.createdAt == git.updatedAt %}
<p><em>This note was created on
<a href="https://github.com/damiendart/robotinaponcho/commit/{{ git.createdHash }}">{{ git.createdAt | date('d M, Y \\a\\t H:i') }}</a>.</em></p>
<aside role="note">This note was created on <a href="https://github.com/damiendart/robotinaponcho/commit/{{ git.createdHash }}">{{ git.createdAt | date('F j, Y') }}</a>.</aside>
{% else %}
<p><em>This note was updated on
<a href="https://github.com/damiendart/robotinaponcho/commit/{{ git.updatedHash }}">{{ git.updatedAt | date('d M, Y \\a\\t H:i') }}</a>.</em></p>
<aside role="note">
This note was created on <a href="https://github.com/damiendart/robotinaponcho/commit/{{ git.createdHash }}">{{ git.createdAt | date('F j, Y') }}</a>
and updated on <a href="https://github.com/damiendart/robotinaponcho/commits/master/{{ git.path }}">{{ git.updatedAt | date('F j, Y') }}</a>.
</aside>
{% endif %}

{{ content | raw }}
Expand Down
2 changes: 1 addition & 1 deletion src/ssg/input/notes/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ title: 'Notes'

<li class="notes-list__item">
<a href="/{{ note.metadata.slug }}">{{ note.metadata.title | smartypants }}</a>
<span class="notes-list__item__meta"><span class="u-visually-hidden">(</span><span>{{ verb }} </span>{{ note.metadata.git.updatedAt | date('d M, Y') }}<span class="u-visually-hidden">)</span></span>
<span class="notes-list__item__meta"><span class="u-visually-hidden">(</span><span>{{ verb }} </span>{{ note.metadata.git.updatedAt | date('F j, Y') }}<span class="u-visually-hidden">)</span></span>
</li>
{% endfor %}
</ul>
Expand Down

0 comments on commit c290aa8

Please sign in to comment.