My personal site. theclashfruit.me
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: some minor improvements

+30 -93
-15
app/(admin)/admin/art/page.tsx
··· 1 - import type { Metadata } from 'next'; 2 - 3 - export const metadata: Metadata = { 4 - title: 'Admin > Art' 5 - }; 6 - 7 - export default function Art() { 8 - return ( 9 - <> 10 - <p>Admin {'>'} Art</p> 11 - 12 - <ul></ul> 13 - </> 14 - ); 15 - }
+1 -1
app/(admin)/admin/photos/page.tsx app/(admin)/admin/gallery/page.tsx
··· 1 1 import type { Metadata } from 'next'; 2 2 3 3 export const metadata: Metadata = { 4 - title: 'Admin > Photos' 4 + title: 'Admin > Art & Photos' 5 5 }; 6 6 7 7 export default function Photos() {
+2 -7
app/(admin)/layout.tsx
··· 45 45 text: 'Comments' 46 46 }, 47 47 { 48 - icon: <LineSquiggle />, 49 - href: '/admin/art', 50 - text: 'Art' 51 - }, 52 - { 53 48 icon: <ImageIcon />, 54 - href: '/admin/photos', 55 - text: 'Photos' 49 + href: '/admin/gallery', 50 + text: 'Art & Photos' 56 51 } 57 52 ]} 58 53 />
+21 -3
app/(main)/post/[slug]/page.tsx
··· 13 13 import Form from 'next/form'; 14 14 import type { Metadata } from 'next'; 15 15 import CommentForm from '@/components/CommentForm'; 16 + import { notFound } from 'next/navigation'; 17 + import { userAuthorized } from '@/lib/auth'; 18 + import { Permission } from '@/lib/enums'; 16 19 17 20 export async function generateMetadata({ 18 21 params ··· 21 24 }): Promise<Metadata> { 22 25 const slug = (await params).slug; 23 26 24 - const { posts: post, users: user } = await fetchPostData(slug); 27 + const { post, user } = await fetchPostData(slug); 25 28 26 29 return { 27 30 title: post.title, ··· 52 55 params: Promise<{ slug: string }>; 53 56 }) { 54 57 const { slug } = await params; 55 - const { posts: post } = await fetchPostData(slug); 58 + const { post } = await fetchPostData(slug); 59 + 60 + if (!post) 61 + notFound(); 62 + 63 + if (post.draft) 64 + if (!(await userAuthorized([Permission.Admin]))) notFound(); 56 65 57 66 const commentsEnabled = false; 58 67 const comments = commentsEnabled ? await fetchComments(post.id) : []; ··· 106 115 .where(eq(postsTable.slug, slug)) 107 116 .limit(1); 108 117 109 - return post[0]; 118 + if (post.length !== 1) 119 + return { 120 + post: undefined, 121 + user: undefined 122 + }; 123 + 124 + return { 125 + post: post[0].posts, 126 + user: post[0].users 127 + }; 110 128 }; 111 129 112 130 const fetchComments = async (id: bigint): Promise<CommentWithReplies[]> => {
+6 -67
styles/pages/Blog.module.scss
··· 26 26 > a { 27 27 position: absolute; 28 28 29 - top: 0; 30 - left: 0; 29 + top: -12px; 30 + left: -12px; 31 31 32 - height: 100%; 33 - width: 100%; 32 + height: calc((2 * 12px) + 100%); 33 + width: calc((2 * 12px) + 100%); 34 + 35 + border-radius: 12px; 34 36 } 35 37 } 36 38 ··· 52 54 grid-template-columns: 1fr; 53 55 } 54 56 } 55 - 56 - /* 57 - return ( 58 - <> 59 - <ul 60 - style={{ 61 - display: 'grid', 62 - gridTemplateColumns: '1fr 1fr', 63 - gap: '8px', 64 - listStyle: 'none' 65 - }} 66 - > 67 - {posts.map((p) => ( 68 - <li 69 - key={p.id} 70 - style={{ 71 - padding: '12px', 72 - background: 'var(--surfaceContainer)', 73 - border: '1px solid var(--outlineVariant)', 74 - borderRadius: '12px', 75 - position: 'relative' 76 - }} 77 - > 78 - <div> 79 - <Link 80 - href={`/post/${p.slug}`} 81 - style={{ 82 - height: '100%', 83 - width: '100%', 84 - position: 'absolute', 85 - top: 0, 86 - left: 0 87 - }} 88 - ></Link> 89 - 90 - <div 91 - style={{ 92 - marginBottom: '6px' 93 - }} 94 - > 95 - <h6 96 - style={{ 97 - margin: 0 98 - }} 99 - > 100 - {p.title} 101 - </h6> 102 - <label 103 - style={{ 104 - color: 'var(--outline)' 105 - }} 106 - > 107 - {p.publishedAt.toLocaleString('en-GB')} 108 - </label> 109 - </div> 110 - 111 - <p>{p.excerpt}</p> 112 - </div> 113 - </li> 114 - ))} 115 - </ul> 116 - </> 117 - */