Skip to content

Commit c01b82f

Browse files
committed
Add source system to TILs
1 parent 79b2647 commit c01b82f

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

resources/data/til/jetbrains/timestamp-shortcut.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
category: JetBrains
33
title: Adding a timestamp shortcut
4+
sources:
5+
- https://www.rudyisme.com/item/shortcut-to-get-the-current-unix-timestamp-in-phpstorm
46
---
57
There is a way in Jetbrains IDEs to insert the current timestamp anywhere.
68

resources/views/pages/til/show.twig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,24 @@
1717
</div>
1818
</div>
1919

20+
{% if til.sources %}
21+
<div class="mt-4 md:mt-14 mb-5 text-gray-600 dark:text-gray-400">
22+
<div class="mb-2 border-b-2 border-gray-500">
23+
<h4 class="text-sm">
24+
{% if til.sources|length == 1 %}
25+
Source
26+
{% else %}
27+
Sources
28+
{% endif %}
29+
</h4>
30+
</div>
31+
32+
<div class="flex flex-col text-sm">
33+
{% for source in til.sources %}
34+
<a href="{{ source }}" class="hover:underline">{{ source }}</a>
35+
{% endfor %}
36+
</div>
37+
</div>
38+
{% endif %}
39+
2040
{% endblock %}

src/Til/Entry.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ public function __construct(
1212
public string $content,
1313
public string $slug,
1414
public string $url,
15+
public array $sources,
1516
) {}
1617
}

src/Til/Renderer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,15 @@ public function render(string $path, string $content): Entry
109109
throw new Exception('Invalid title in ' . $path);
110110
}
111111

112+
$sources = $frontMatter['sources'] ?? [];
113+
112114
return new Entry(
113115
$category,
114116
$title,
115117
$result->getContent(),
116118
$slug,
117119
$this->url($slug),
120+
$sources,
118121
);
119122
}
120123

0 commit comments

Comments
 (0)