-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
.../apps/service-site/src/features/posts/components/PostDetailPage/PostDetailPage.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.navPostWrapper { | ||
display: grid; | ||
grid-auto-flow: row; | ||
gap: var(--spacing-8); | ||
} | ||
|
||
@media screen and (min-width: 768px) { | ||
.navPostWrapper { | ||
grid-auto-flow: column; | ||
gap: var(--spacing-10); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
frontend/apps/service-site/src/features/posts/utils/getNextPost.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Lang } from '@/features/i18n' | ||
import type { Post } from 'contentlayer/generated' | ||
import { filterPostsByLang } from './filterPostsByLang' | ||
import { sortPostsByDate } from './sortPostsByDate' | ||
|
||
type Params = { | ||
lang: Lang | ||
targetPost: Post | ||
} | ||
|
||
export function getNextPost({ lang, targetPost }: Params) { | ||
const posts = filterPostsByLang(lang) | ||
const sortedPosts = sortPostsByDate(posts) | ||
|
||
const targetIndex = sortedPosts.findIndex( | ||
(post) => post._id === targetPost._id, | ||
) | ||
|
||
if (targetIndex === -1 || targetIndex === sortedPosts.length - 1) { | ||
return undefined | ||
} | ||
|
||
return sortedPosts[targetIndex + 1] | ||
} |
24 changes: 24 additions & 0 deletions
24
frontend/apps/service-site/src/features/posts/utils/getPrevPost.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Lang } from '@/features/i18n' | ||
import type { Post } from 'contentlayer/generated' | ||
import { filterPostsByLang } from './filterPostsByLang' | ||
import { sortPostsByDate } from './sortPostsByDate' | ||
|
||
type Params = { | ||
lang: Lang | ||
targetPost: Post | ||
} | ||
|
||
export function getPrevPost({ lang, targetPost }: Params) { | ||
const posts = filterPostsByLang(lang) | ||
const sortedPosts = sortPostsByDate(posts) | ||
|
||
const targetIndex = sortedPosts.findIndex( | ||
(post) => post._id === targetPost._id, | ||
) | ||
|
||
if (targetIndex === -1 || targetIndex === 0) { | ||
return undefined | ||
} | ||
|
||
return sortedPosts[targetIndex - 1] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export * from './filterPostsByLang' | ||
export * from './findPostByLangAndSlug' | ||
export * from './getNextPost' | ||
export * from './getPrevPost' | ||
export * from './sortPostsByDate' |