upstream #1
@ -3,8 +3,7 @@ import Tag from '@/components/Tag'
|
|||||||
import siteMetadata from '@/data/siteMetadata'
|
import siteMetadata from '@/data/siteMetadata'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import Pagination from '@/components/Pagination'
|
import Pagination from '@/components/Pagination'
|
||||||
|
import formatDate from '@/lib/utils/formatDate'
|
||||||
const postDateTemplate = { year: 'numeric', month: 'long', day: 'numeric' }
|
|
||||||
|
|
||||||
export default function ListLayout({ posts, title, initialDisplayPosts = [], pagination }) {
|
export default function ListLayout({ posts, title, initialDisplayPosts = [], pagination }) {
|
||||||
const [searchValue, setSearchValue] = useState('')
|
const [searchValue, setSearchValue] = useState('')
|
||||||
@ -58,9 +57,7 @@ export default function ListLayout({ posts, title, initialDisplayPosts = [], pag
|
|||||||
<dl>
|
<dl>
|
||||||
<dt className="sr-only">Published on</dt>
|
<dt className="sr-only">Published on</dt>
|
||||||
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400">
|
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400">
|
||||||
<time dateTime={date}>
|
<time dateTime={date}>{formatDate(date)}</time>
|
||||||
{new Date(date).toLocaleDateString(siteMetadata.locale, postDateTemplate)}
|
|
||||||
</time>
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div className="space-y-3 xl:col-span-3">
|
<div className="space-y-3 xl:col-span-3">
|
||||||
|
@ -3,8 +3,7 @@ import PageTitle from '@/components/PageTitle'
|
|||||||
import SectionContainer from '@/components/SectionContainer'
|
import SectionContainer from '@/components/SectionContainer'
|
||||||
import { BlogSeo } from '@/components/SEO'
|
import { BlogSeo } from '@/components/SEO'
|
||||||
import siteMetadata from '@/data/siteMetadata'
|
import siteMetadata from '@/data/siteMetadata'
|
||||||
|
import formatDate from '@/lib/utils/formatDate'
|
||||||
const postDateTemplate = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }
|
|
||||||
|
|
||||||
export default function PostLayout({ frontMatter, authorDetails, next, prev, children }) {
|
export default function PostLayout({ frontMatter, authorDetails, next, prev, children }) {
|
||||||
const { date, title } = frontMatter
|
const { date, title } = frontMatter
|
||||||
@ -20,9 +19,7 @@ export default function PostLayout({ frontMatter, authorDetails, next, prev, chi
|
|||||||
<div>
|
<div>
|
||||||
<dt className="sr-only">Published on</dt>
|
<dt className="sr-only">Published on</dt>
|
||||||
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400">
|
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400">
|
||||||
<time dateTime={date}>
|
<time dateTime={date}>{formatDate(date)}</time>
|
||||||
{new Date(date).toLocaleDateString(siteMetadata.locale, postDateTemplate)}
|
|
||||||
</time>
|
|
||||||
</dd>
|
</dd>
|
||||||
</div>
|
</div>
|
||||||
</dl>
|
</dl>
|
||||||
|
14
lib/utils/formatDate.js
Normal file
14
lib/utils/formatDate.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import siteMetadata from '@/data/siteMetadata'
|
||||||
|
|
||||||
|
const formatDate = (date) => {
|
||||||
|
const options = {
|
||||||
|
year: 'numeric',
|
||||||
|
month: 'long',
|
||||||
|
day: 'numeric',
|
||||||
|
}
|
||||||
|
const now = new Date(date).toLocaleDateString(siteMetadata.locale, options)
|
||||||
|
|
||||||
|
return now
|
||||||
|
}
|
||||||
|
|
||||||
|
export default formatDate
|
@ -3,9 +3,9 @@ import { PageSeo } from '@/components/SEO'
|
|||||||
import Tag from '@/components/Tag'
|
import Tag from '@/components/Tag'
|
||||||
import siteMetadata from '@/data/siteMetadata'
|
import siteMetadata from '@/data/siteMetadata'
|
||||||
import { getAllFilesFrontMatter } from '@/lib/mdx'
|
import { getAllFilesFrontMatter } from '@/lib/mdx'
|
||||||
|
import formatDate from '@/lib/utils/formatDate'
|
||||||
|
|
||||||
const MAX_DISPLAY = 5
|
const MAX_DISPLAY = 5
|
||||||
const postDateTemplate = { year: 'numeric', month: 'long', day: 'numeric' }
|
|
||||||
|
|
||||||
export async function getStaticProps() {
|
export async function getStaticProps() {
|
||||||
const posts = await getAllFilesFrontMatter('blog')
|
const posts = await getAllFilesFrontMatter('blog')
|
||||||
@ -37,9 +37,7 @@ export default function Home({ posts }) {
|
|||||||
<dl>
|
<dl>
|
||||||
<dt className="sr-only">Published on</dt>
|
<dt className="sr-only">Published on</dt>
|
||||||
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400">
|
<dd className="text-base font-medium leading-6 text-gray-500 dark:text-gray-400">
|
||||||
<time dateTime={date}>
|
<time dateTime={date}>{formatDate(date)}</time>
|
||||||
{new Date(date).toLocaleDateString(siteMetadata.locale, postDateTemplate)}
|
|
||||||
</time>
|
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<div className="space-y-5 xl:col-span-3">
|
<div className="space-y-5 xl:col-span-3">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user