Skip to content

Commit

Permalink
pagination next prev on articles
Browse files Browse the repository at this point in the history
  • Loading branch information
michelson committed Dec 7, 2022
1 parent 8229555 commit 97d092d
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
10 changes: 10 additions & 0 deletions client/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ export const ARTICLE = `
state
updatedAt
description
nextArticleUrl {
id
slug
title
}
prevArticleUrl {
id
slug
title
}
collection{
slug
title
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dev": "next dev -p 8080",
"lint": "next lint",
"build": "next build",
"start": "next start"
"start": "next start -p 8080"
},
"dependencies": {
"@emotion/react": "^11.4.0",
Expand All @@ -33,4 +33,4 @@
"eslint": "^7.28.0",
"eslint-config-next": "^11.0.0"
}
}
}
43 changes: 43 additions & 0 deletions pages/[collection]/[article]/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Layout from "../../../components/themes/base/Layout";
import Moment from "react-moment";
import DraftRenderer from "../../../components/themes/base/textEditor/draftRenderer";
import theme from "../../../components/themes/base/textEditor/theme";
import Link from 'next/link'

import styled from "@emotion/styled";
import { ThemeProvider } from "@emotion/react";
Expand Down Expand Up @@ -107,6 +108,48 @@ export default function Article({ article, lang, site }) {
</ThemeProvider>
</div>

<dl className="mt-12 flex border-t border-slate-200 pt-6 dark:border-slate-800">
{article.prevArticleUrl && (
<div>
<dt className="font-display text-sm font-medium text-slate-900 dark:text-white">
Previous
</dt>
<dd className="mt-1">
<a
passHref
className="text-md dark:text-gray-100 dark:hover:text-gray-400 text-gray-600 hover:text-gray-700 focus:outline-none focus:underline transition duration-150 ease-in-out"
href={article.prevArticleUrl.slug}
>
<span>
<span aria-hidden="true"></span>{' '}
{article.prevArticleUrl.title}
</span>
</a>
</dd>
</div>
)}

{article.nextArticleUrl && (
<div className="ml-auto text-right">
<dt className="font-display text-sm font-medium text-slate-900 dark:text-white">
Next
</dt>
<dd className="mt-1">
<a
passHref
className="text-md dark:text-gray-100 dark:hover:text-gray-400 text-gray-600 hover:text-gray-700 focus:outline-none focus:underline transition duration-150 ease-in-out"
href={article.nextArticleUrl.slug}
>
<span>
{article.nextArticleUrl.title}{' '}
<span aria-hidden="true"></span>
</span>
</a>
</dd>
</div>
)}
</dl>

{/*<div dangerouslySetInnerHTML={
{__html: article.content.html_content}
}/>*/}
Expand Down

0 comments on commit 97d092d

Please sign in to comment.