-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnextjs-project-files.ts
53 lines (43 loc) · 1.25 KB
/
nextjs-project-files.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// app/lib/supabase.ts
import { createClient } from '@supabase/supabase-js'
export const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!
)
// app/types/index.ts
export interface Article {
id: number
title: string
url: string
source: string
published_at: string
votes: number
}
export interface Vote {
articleId: number
voteType: 'up' | 'down'
}
// .env.local
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
// app/page.tsx
import { Metadata } from 'next'
import HomePage from './components/HomePage'
export const metadata: Metadata = {
title: 'Firearms News Aggregator',
description: 'Aggregated firearms news from across the web',
}
export default function Page() {
return <HomePage />
}
// app/components/HomePage.tsx
'use client'
import { useEffect, useState } from 'react'
import { Article } from '../types'
import { supabase } from '../lib/supabase'
import { formatDistanceToNow } from 'date-fns'
export default function HomePage() {
// Previous frontend code goes here, with proper TypeScript types
// Copy the content from the previous frontend artifact but update it
// to use proper Next.js 13+ conventions and TypeScript
}