Skip to content

Commit

Permalink
日付表示をdayjs -> Intl
Browse files Browse the repository at this point in the history
  • Loading branch information
K-tecchan committed Jan 7, 2024
1 parent d877ba7 commit acc7128
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
8 changes: 1 addition & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
"@astrojs/mdx": "^2.0.3",
"@astrojs/sitemap": "^3.0.4",
"astro": "^4.0.9",
"astro-seo": "^0.8.0",
"dayjs": "^1.11.10"
"astro-seo": "^0.8.0"
},
"devDependencies": {
"@playwright/test": "^1.40.1",
Expand Down
10 changes: 7 additions & 3 deletions src/components/Card.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
import dayjs from "dayjs";
interface Props {
slug: string;
data: {
Expand All @@ -20,7 +18,13 @@ const { slug, data } = Astro.props;
</a>
<p class="description">{data.description}</p>
<p class="published">
{dayjs(data.published).format("YYYY/MM/DD")}
{
new Intl.DateTimeFormat("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).format(data.published)
}
</p>
<ul class="tags">
{
Expand Down
9 changes: 7 additions & 2 deletions src/layouts/MarkdownPostLayout.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
import dayjs from "dayjs";
import Layout from "./Layout.astro";
import "../styles/prism.css";
Expand Down Expand Up @@ -29,7 +28,13 @@ const { frontmatter } = Astro.props;
}
</ul>
<div class="published">
{dayjs(frontmatter.published).format("YYYY/MM/DD")}
{
new Intl.DateTimeFormat("ja-JP", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).format(frontmatter.published)
}
</div>
<section>
<slot />
Expand Down

0 comments on commit acc7128

Please sign in to comment.