From c259a518189736a6e819d580afdc78f35c6db543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=90=D1=80=D1=82=D1=91=D0=BC?= Date: Sat, 15 Jun 2024 20:59:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=87=D1=91=D1=82=D1=87=D0=B8=D0=BA=20?= =?UTF-8?q?=D0=B3=D0=BE=D0=B4=D0=B8=D0=BA=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/about/about.md | 2 +- layouts/shortcodes/age.html | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 layouts/shortcodes/age.html diff --git a/content/about/about.md b/content/about/about.md index 389e105..d564788 100755 --- a/content/about/about.md +++ b/content/about/about.md @@ -6,7 +6,7 @@ showFullContent: true # Приветствую! -Меня звать **Сисадмин Линк**, парень, 23 годика, я создатель данного сайта и хостер некоторых [сервисов](/services) с **открытым исходным кодом**. +Меня звать **Сисадмин Линк**, парень, {{< age >}} годика, я создатель данного сайта и хостер [некоторых сервисов](/services) с **открытым исходным кодом**. Работаю сисадмином в подразделении одного колледжа. diff --git a/layouts/shortcodes/age.html b/layouts/shortcodes/age.html new file mode 100644 index 0000000..c0fde3c --- /dev/null +++ b/layouts/shortcodes/age.html @@ -0,0 +1,17 @@ +{{ $birth := "2000-10-28" | time }} +{{ $today := now }} +{{ $age := sub $today.Year $birth.Year }} +{{ $monthDiff := sub $today.Month $birth.Month }} +{{ $dayDiff := sub $today.Day $birth.Day }} + +{{ if (gt $monthDiff 0) }} + {{ $age }} +{{ else if (lt $monthDiff 0) }} + {{ sub $age 1 }} +{{ else }} + {{ if (ge $dayDiff 0) }} + {{ $age }} + {{ else }} + {{ sub $age 1 }} + {{ end }} +{{ end }}