File tree 12 files changed +77
-35
lines changed
@details/(..)details/[type]/[articleUrl]
details/[type]/[articleUrl]
12 files changed +77
-35
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,15 @@ DB_AUTH_TOKEN='YOUR_DB_NAME'
12
12
# @see https://next-auth.js.org/configuration/options#secret
13
13
AUTH_SECRET = ' supersecret'
14
14
15
- # Preconfigured Discord OAuth provider, works out-of-the-box
16
- # @see https://next-auth.js.org/providers/discord
17
- AUTH_DISCORD_ID = ' '
18
- AUTH_DISCORD_SECRET = ' '
15
+ # Preconfigured Github OAuth provider, works out-of-the-box
16
+ # @see https://next-auth.js.org/providers/github
17
+ AUTH_GITHUB_ID = ' '
18
+ AUTH_GITHUB_SECRET = ' '
19
+
20
+ # Unsplash API Keys
21
+ UNSPLASH_ACCESS_KEY = ' '
22
+ UNSPLASH_SECRET_KEY = ' '
23
+
24
+ # Upstash Redis Credentials
25
+ REDIS_URL = ' '
26
+ REDIS_TOKEN = ' '
File renamed without changes.
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
3
3
import { NewsArticle } from "~/app/_components/details/news-article" ;
4
- import { exampleData } from "~/app/example-data" ;
5
-
6
- export function generateStaticParams ( ) : { itemId : string } [ ] {
7
- return exampleData . map ( ( item ) => ( {
8
- itemId : item . id ,
9
- } ) ) ;
10
- }
11
4
12
5
export default async function Page ( {
13
6
params,
14
7
} : {
15
- params : { itemId : string } ;
8
+ params : { articleUrl : string ; type : string } ;
16
9
} ) : Promise < React . ReactElement > {
17
10
// const articleData = exampleData.filter(
18
11
// (item) => item.id === params.itemId,
@@ -21,6 +14,8 @@ export default async function Page({
21
14
// (res) => res.filter((item) => item.id === params.itemId)[0],
22
15
// );
23
16
24
- return < NewsArticle url = { decodeURIComponent ( params . itemId ) } /> ;
17
+ if ( params . type === "news" )
18
+ return < NewsArticle url = { decodeURIComponent ( params . articleUrl ) } /> ;
19
+ return < div > Something is not quite right</ div > ;
25
20
// if (articleData?.type === "news") return <div>Article not found</div>;
26
21
}
Original file line number Diff line number Diff line change
1
+ import type { DashboardItem } from "~/app/example-data" ;
1
2
import { DashboardList } from "~/app/_components/dashboard-list" ;
2
3
import { getRssData } from "~/app/example-data" ;
3
4
@@ -6,9 +7,22 @@ export const revalidate = 3600;
6
7
export default async function Page ( ) : Promise < React . ReactElement > {
7
8
const rssData = await getRssData ( ) ;
8
9
10
+ const items : DashboardItem [ ] | undefined = rssData . items ?. map ( ( item ) => ( {
11
+ title : item . title ?? "" ,
12
+ id : item . id ,
13
+ contentSnippet : item . contentSnippet ?? "" ,
14
+ icon : "" ,
15
+ details : {
16
+ type : "news" ,
17
+ articleUrl : item . link ?? "" ,
18
+ date : item . isoDate ?? "" ,
19
+ source : rssData . title ?? "" ,
20
+ } ,
21
+ } ) ) ;
22
+
9
23
return (
10
24
< div className = "relative max-w-full p-2 md:p-8" >
11
- < DashboardList rssData = { rssData } />
25
+ { items !== undefined ? < DashboardList items = { items } /> : null }
12
26
</ div >
13
27
) ;
14
28
}
File renamed without changes.
Original file line number Diff line number Diff line change @@ -13,9 +13,9 @@ import { NewsArticle } from "~/app/_components/details/news-article";
13
13
export async function generateMetadata ( {
14
14
params,
15
15
} : {
16
- params : { itemId ?: string } ;
16
+ params : { articleUrl ?: string ; type ?: string } ;
17
17
} ) : Promise < Metadata > {
18
- const url = decodeURIComponent ( params . itemId ?? "" ) ;
18
+ const url = decodeURIComponent ( params . articleUrl ?? "" ) ;
19
19
let extractedData ;
20
20
try {
21
21
try {
@@ -60,12 +60,14 @@ export async function generateMetadata({
60
60
export default function Page ( {
61
61
params,
62
62
} : {
63
- params : { itemId : string } ;
63
+ params : { articleUrl : string ; type : string } ;
64
64
} ) : React . ReactElement {
65
65
// const articleData = exampleData.filter(
66
66
// (item) => item.id === params.itemId,
67
67
// )[0];
68
68
69
- return < NewsArticle url = { decodeURIComponent ( params . itemId ) } /> ;
69
+ if ( params . type === "news" )
70
+ return < NewsArticle url = { decodeURIComponent ( params . articleUrl ) } /> ;
71
+ return < div > Something is not quite right</ div > ;
70
72
// if (articleData?.type === "news") return <div>Article not found</div>;
71
73
}
Original file line number Diff line number Diff line change 2
2
3
3
import { usePathname } from "next/navigation" ;
4
4
import { LinkButton } from "@ai-inbox/ui/button" ;
5
- import { IconNews } from "@tabler/icons-react" ;
5
+ import { IconMail , IconNews } from "@tabler/icons-react" ;
6
6
7
- import type { NewsItem } from "../example-data" ;
7
+ import type { DashboardItem } from "../example-data" ;
8
8
9
9
export function DashboardItem ( {
10
10
item,
11
11
} : {
12
- item : NewsItem ;
12
+ item : DashboardItem ;
13
13
} ) : React . ReactElement {
14
14
// eslint-disable-next-line react/jsx-no-useless-fragment -- i need it to be a react node
15
15
let icon = < > </ > ;
16
- switch ( item . type ) {
17
- // case "email":
18
- // icon = <IconMail size={20} className="shrink-0" />;
19
- // break;
20
- case "newsItem " :
16
+ switch ( item . details . type ) {
17
+ case "email" :
18
+ icon = < IconMail size = { 20 } className = "shrink-0" /> ;
19
+ break ;
20
+ case "news " :
21
21
icon = < IconNews size = { 20 } className = "shrink-0" /> ;
22
22
break ;
23
23
// case "other":
@@ -28,7 +28,7 @@ export function DashboardItem({
28
28
29
29
return (
30
30
< LinkButton
31
- href = { `/details/${ item . id } ` }
31
+ href = { `/details/${ item . details . type } / ${ item . id } ` }
32
32
variant = { pathname . includes ( `/details/${ item . id } ` ) ? "secondary" : "ghost" }
33
33
className = "min-w-0 max-w-full shrink grow items-center justify-start gap-2 p-1 px-1"
34
34
>
Original file line number Diff line number Diff line change @@ -11,14 +11,14 @@ import {
11
11
import { Input } from "@ai-inbox/ui/input" ;
12
12
import { IconFilter , IconSortAscending } from "@tabler/icons-react" ;
13
13
14
- import type { NewsFeed } from "../example-data" ;
14
+ import type { DashboardItem as DashboardItemType } from "../example-data" ;
15
15
import { DashboardItem } from "~/app/_components/dashboard-item" ;
16
16
import { feeds } from "~/app/feeds" ;
17
17
18
18
export function DashboardList ( {
19
- rssData ,
19
+ items ,
20
20
} : {
21
- rssData : NewsFeed ;
21
+ items : DashboardItemType [ ] ;
22
22
} ) : React . ReactElement {
23
23
const [ searchString , setSearchString ] = useState ( "" ) ;
24
24
return (
@@ -64,8 +64,8 @@ export function DashboardList({
64
64
</ DropdownMenu >
65
65
</ div >
66
66
< div className = "flex w-full flex-col gap-2" >
67
- { rssData . items . map ( ( item ) =>
68
- item . title ? .toLowerCase ( ) . includes ( searchString . toLowerCase ( ) ) ? (
67
+ { items . map ( ( item ) =>
68
+ item . title . toLowerCase ( ) . includes ( searchString . toLowerCase ( ) ) ? (
69
69
< DashboardItem key = { item . id } item = { item } />
70
70
) : null ,
71
71
) }
Original file line number Diff line number Diff line change @@ -114,11 +114,32 @@ export type NewsItem = Parser.Item & {
114
114
export type NewsFeed = Omit < Parser . Output < undefined > , "items" > & {
115
115
id : string ;
116
116
type : "newsFeed" ;
117
- items : NewsItem [ ] ;
117
+ items ? : NewsItem [ ] ;
118
118
} ;
119
119
120
120
export type NewsSource = {
121
121
title : string ;
122
+ icon : string ;
122
123
url : string ;
123
124
feeds : NewsFeed [ ] ;
124
125
} ;
126
+
127
+ export type DashboardItem = {
128
+ id : string ;
129
+ title : string ;
130
+ contentSnippet : string ;
131
+ icon : string ;
132
+ details : DashboardDetails ;
133
+ } ;
134
+
135
+ export type DashboardDetails =
136
+ | {
137
+ type : "news" ;
138
+ articleUrl : string ;
139
+ date : Date | string ;
140
+ source : string ;
141
+ }
142
+ | {
143
+ type : "email" ;
144
+ id : string ;
145
+ } ;
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ export const env = createEnv({
17
17
DB_AUTH_TOKEN : z . string ( ) ,
18
18
UNSPLASH_ACCESS_KEY : z . string ( ) ,
19
19
UNSPLASH_SECRET_KEY : z . string ( ) ,
20
+ // UPSTASH_REDIS_REST_TOKEN: z.string(),
21
+ // UPSTASH_REDIS_REST_URL: z.string(),
20
22
} ,
21
23
/**
22
24
* Specify your client-side environment variables schema here.
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ import { z } from "zod";
3
3
4
4
export const env = createEnv ( {
5
5
server : {
6
- AUTH_DISCORD_ID : z . string ( ) . min ( 1 ) ,
7
- AUTH_DISCORD_SECRET : z . string ( ) . min ( 1 ) ,
6
+ AUTH_GITHUB_ID : z . string ( ) . min ( 1 ) ,
7
+ AUTH_GITHUB_SECRET : z . string ( ) . min ( 1 ) ,
8
8
AUTH_SECRET :
9
9
process . env . NODE_ENV === "production"
10
10
? z . string ( ) . min ( 1 )
You can’t perform that action at this time.
0 commit comments