feat: tweaks; improve posts ux
This commit is contained in:
parent
07b5a7438c
commit
f765c692af
8 changed files with 15 additions and 49 deletions
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "www-aaronjy-me",
|
"name": "www-aaronjy-me",
|
||||||
"version": "2.1.1",
|
"version": "2.1.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
|
|
|
@ -17,10 +17,9 @@ function BookReview({ review, html }) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>
|
<h1>
|
||||||
{title}
|
{title} <small>- {author}</small>
|
||||||
<br />
|
|
||||||
<small>by {author}</small>
|
|
||||||
</h1>
|
</h1>
|
||||||
|
|
||||||
<Link href="./">Back...</Link>
|
<Link href="./">Back...</Link>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
|
|
|
@ -19,10 +19,6 @@ function Footer() {
|
||||||
<a href="/static/pgp.txt">PGP key</a>
|
<a href="/static/pgp.txt">PGP key</a>
|
||||||
</span>
|
</span>
|
||||||
{", "}
|
{", "}
|
||||||
<span>
|
|
||||||
<a href="mailto:me@aaronjy.me">Send me an email</a>
|
|
||||||
</span>
|
|
||||||
{", "}
|
|
||||||
<span>
|
<span>
|
||||||
<a
|
<a
|
||||||
href="https://git.aaronjy.me/aaron/aaronjy-me"
|
href="https://git.aaronjy.me/aaron/aaronjy-me"
|
||||||
|
|
|
@ -3,23 +3,15 @@ import Link from "next/link";
|
||||||
|
|
||||||
export default function StaticContentList({ entries, urlPrefix, max = 0 }) {
|
export default function StaticContentList({ entries, urlPrefix, max = 0 }) {
|
||||||
return (
|
return (
|
||||||
<table>
|
<div>
|
||||||
<tbody>
|
{entries
|
||||||
{entries
|
.map((e) => (
|
||||||
.map((e) => (
|
<p key={e.slug}>
|
||||||
<tr key={e.slug}>
|
<Link href={`${urlPrefix}${e.slug}`}>{e.title}</Link>{" "}
|
||||||
<td>
|
{!!e.datePublished && <i>{`on ${formatDate(e.datePublished)}`}</i>}
|
||||||
{!!e.datePublished && (
|
</p>
|
||||||
<span>{formatDate(e.datePublished)}</span>
|
))
|
||||||
)}
|
.slice(0, max > 0 ? max : entries.length)}
|
||||||
</td>
|
</div>
|
||||||
<td>
|
|
||||||
<Link href={`${urlPrefix}${e.slug}`}>{e.title}</Link>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
))
|
|
||||||
.slice(0, max > 0 ? max : entries.length)}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import { NextSeo } from "next-seo";
|
||||||
|
|
||||||
export async function getServerSideProps({ params }) {
|
export async function getServerSideProps({ params }) {
|
||||||
const { path } = params;
|
const { path } = params;
|
||||||
console.log(params);
|
|
||||||
const res = await fetchBasicPages([], {
|
const res = await fetchBasicPages([], {
|
||||||
path: {
|
path: {
|
||||||
_eq: path?.join("/") ?? null,
|
_eq: path?.join("/") ?? null,
|
||||||
|
|
|
@ -16,7 +16,7 @@ export async function getServerSideProps() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const reviews = (await res.json()).data.sort(
|
const reviews = (await res.json()).data.sort(
|
||||||
(a, b) => new Date(b.read_date).getTime() - new Date(a.read_date).getTime(),
|
(a, b) => new Date(b.readDate).getTime() - new Date(a.readDate).getTime(),
|
||||||
);
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -4,27 +4,6 @@ import Article from "@/components/Article/Article";
|
||||||
import { fetchPosts, markdownToHtml } from "@/services/content-service";
|
import { fetchPosts, markdownToHtml } from "@/services/content-service";
|
||||||
import { FailedFetchPostError, FailedFetchPostsError } from "@/errors";
|
import { FailedFetchPostError, FailedFetchPostsError } from "@/errors";
|
||||||
|
|
||||||
// export async function getStaticPaths () {
|
|
||||||
// const res = await fetchPosts(['slug'], {
|
|
||||||
// status: 'published'
|
|
||||||
// })
|
|
||||||
|
|
||||||
// if (!res.ok) {
|
|
||||||
// throw new FailedFetchPostsError(await res.text())
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const posts = (await res.json()).data
|
|
||||||
|
|
||||||
// return {
|
|
||||||
// paths: posts.map(post => ({
|
|
||||||
// params: {
|
|
||||||
// slug: post.slug
|
|
||||||
// }
|
|
||||||
// })),
|
|
||||||
// fallback: true // false or "blocking"
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const getServerSideProps = async ({ params }) => {
|
export const getServerSideProps = async ({ params }) => {
|
||||||
const { slug } = params;
|
const { slug } = params;
|
||||||
const res = await fetchPosts([], {
|
const res = await fetchPosts([], {
|
||||||
|
|
|
@ -15,6 +15,7 @@ export const getServerSideProps = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
|
|
||||||
const posts = json.data.sort(
|
const posts = json.data.sort(
|
||||||
(a, b) =>
|
(a, b) =>
|
||||||
new Date(b.datePublished).getTime() - new Date(a.datePublished).getTime(),
|
new Date(b.datePublished).getTime() - new Date(a.datePublished).getTime(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue