From 1e0f893b2421f05da7d384979aadefc61b6c66fd Mon Sep 17 00:00:00 2001 From: Last2014 Date: Mon, 27 Oct 2025 15:46:19 +0900 Subject: [PATCH] Add: age / Change: card width --- package.json | 1 + pnpm-lock.yaml | 8 ++++++++ public/icons/age.svg | 1 + src/constants/details.ts | 12 +++++++++++- src/pages/index.astro | 9 ++++----- 5 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 public/icons/age.svg diff --git a/package.json b/package.json index 5ebe2c7..f2faefc 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "dependencies": { "@tailwindcss/vite": "^4.1.14", "astro": "^5.14.6", + "date-fns": "^4.1.0", "sharp": "^0.34.4", "tailwindcss": "^4.1.14" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6d5baba..bd818df 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,6 +14,9 @@ importers: astro: specifier: ^5.14.6 version: 5.14.6(@types/node@24.8.1)(jiti@2.6.1)(lightningcss@1.30.1)(rollup@4.52.5)(typescript@5.9.3) + date-fns: + specifier: ^4.1.0 + version: 4.1.0 sharp: specifier: ^0.34.4 version: 0.34.4 @@ -760,6 +763,9 @@ packages: engines: {node: '>=4'} hasBin: true + date-fns@4.1.0: + resolution: {integrity: sha512-Ukq0owbQXxa/U3EGtsdVBkR1w7KOQ5gIBqdH2hkvknzZPYvBxb/aa6E8L7tmjFtkwZBu3UXBbjIgPo/Ez4xaNg==} + debug@4.4.3: resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} engines: {node: '>=6.0'} @@ -2328,6 +2334,8 @@ snapshots: cssesc@3.0.0: {} + date-fns@4.1.0: {} + debug@4.4.3: dependencies: ms: 2.1.3 diff --git a/public/icons/age.svg b/public/icons/age.svg new file mode 100644 index 0000000..f42eb78 --- /dev/null +++ b/public/icons/age.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/constants/details.ts b/src/constants/details.ts index 568c842..d0c88d0 100644 --- a/src/constants/details.ts +++ b/src/constants/details.ts @@ -1,4 +1,9 @@ import { type Props as CardProps } from "@/components/Card.astro"; +import { differenceInYears } from "date-fns"; +import { format } from "date-fns"; + +const birthday = new Date("2014-12-08T16:14:00+09:00"); +const age = differenceInYears(new Date(), birthday); export default [ { @@ -8,9 +13,14 @@ export default [ }, { title: "誕生日", - description: "2014/12/8", + description: format(birthday, "yyyy/MM/dd"), img: "cake.svg", }, + { + title: "年齢", + description: `${age}歳`, + img: "age.svg", + }, { title: "場所", description: "神奈川県", diff --git a/src/pages/index.astro b/src/pages/index.astro index 2c404c1..74ce395 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -37,9 +37,9 @@ import contacts from "@/constants/contacts";
詳細 @@ -50,7 +50,6 @@ import contacts from "@/constants/contacts"; description={detail.description} img={detail.img} href={detail.href} - isFullWidth /> ))}
@@ -59,7 +58,7 @@ import contacts from "@/constants/contacts"; flex flex-wrap gap-3 - w-fit + w-[70vw] p-5 `}> リンク @@ -78,7 +77,7 @@ import contacts from "@/constants/contacts"; flex flex-col gap-3 - w-full + w-[70vw] p-5 `}> 連絡先