()
| 6 | import type { FC } from 'react'; |
| 7 | |
| 8 | const WithBlogCrossLinks: FC = () => { |
| 9 | const { pathname } = getClientContext(); |
| 10 | |
| 11 | // Extracts from the static URL the components used for the Blog Post slug |
| 12 | const [, , category, postname] = pathname.split('/') as [ |
| 13 | unknown, |
| 14 | unknown, |
| 15 | BlogCategory, |
| 16 | string, |
| 17 | ]; |
| 18 | |
| 19 | const { posts } = getBlogData(category); |
| 20 | |
| 21 | const currentItem = posts.findIndex( |
| 22 | ({ slug }) => slug === `/blog/${category}/${postname}` |
| 23 | ); |
| 24 | |
| 25 | const [previousCrossLink, nextCrossLink] = [ |
| 26 | posts[currentItem - 1], |
| 27 | posts[currentItem + 1], |
| 28 | ]; |
| 29 | |
| 30 | return ( |
| 31 | <div className="max-ml:grid-cols-1 mt-4 grid w-full grid-cols-2 gap-4"> |
| 32 | {(previousCrossLink && ( |
| 33 | <CrossLink |
| 34 | type="previous" |
| 35 | text={previousCrossLink.title} |
| 36 | link={previousCrossLink.slug} |
| 37 | /> |
| 38 | )) || <div />} |
| 39 | |
| 40 | {nextCrossLink && ( |
| 41 | <CrossLink |
| 42 | type="next" |
| 43 | text={nextCrossLink.title} |
| 44 | link={nextCrossLink.slug} |
| 45 | /> |
| 46 | )} |
| 47 | </div> |
| 48 | ); |
| 49 | }; |
| 50 | |
| 51 | export default WithBlogCrossLinks; |
nothing calls this directly
no test coverage detected