mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-12 07:12:52 +01:00
refactor: improve type safety (#155)
* Fix to make it type safe. * The build is failing, fix it.
This commit is contained in:
committed by
GitHub
parent
f79ee3482d
commit
e9c8930559
@@ -1,9 +1,9 @@
|
||||
---
|
||||
import { UNCATEGORIZED } from '@constants/constants'
|
||||
import I18nKey from '../i18n/i18nKey'
|
||||
import { i18n } from '../i18n/translation'
|
||||
import { getSortedPosts } from '../utils/content-utils'
|
||||
import { getPostUrlBySlug } from '../utils/url-utils'
|
||||
import { i18n } from '../i18n/translation'
|
||||
import I18nKey from '../i18n/i18nKey'
|
||||
import { UNCATEGORIZED } from '@constants/constants'
|
||||
|
||||
interface Props {
|
||||
keyword?: string
|
||||
@@ -30,7 +30,7 @@ if (Array.isArray(categories) && categories.length > 0) {
|
||||
)
|
||||
}
|
||||
|
||||
const groups: { year: number; posts: typeof posts }[] = (function () {
|
||||
const groups: { year: number; posts: typeof posts }[] = (() => {
|
||||
const groupedPosts = posts.reduce(
|
||||
(grouped: { [year: number]: typeof posts }, post) => {
|
||||
const year = post.data.published.getFullYear()
|
||||
@@ -45,8 +45,8 @@ const groups: { year: number; posts: typeof posts }[] = (function () {
|
||||
|
||||
// convert the object to an array
|
||||
const groupedPostsArray = Object.keys(groupedPosts).map(key => ({
|
||||
year: parseInt(key),
|
||||
posts: groupedPosts[parseInt(key)],
|
||||
year: Number.parseInt(key),
|
||||
posts: groupedPosts[Number.parseInt(key)],
|
||||
}))
|
||||
|
||||
// sort years by latest first
|
||||
|
||||
Reference in New Issue
Block a user