forked from eightants/reddium
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update packages and create a config API
- Loading branch information
Showing
16 changed files
with
6,286 additions
and
8,242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Use an official Node runtime as the base image | ||
FROM node:20-alpine | ||
|
||
# Set the working directory in the container | ||
WORKDIR /app | ||
|
||
# Copy package.json and package-lock.json | ||
COPY package*.json ./ | ||
|
||
# Install project dependencies | ||
RUN npm install | ||
|
||
# Copy the rest of the application code | ||
COPY . . | ||
|
||
# Build the Next.js application | ||
RUN npm run build | ||
|
||
# Expose the port the app runs on (usually 3000 for Next.js) | ||
EXPOSE 3000 | ||
|
||
# Start the application | ||
CMD ["npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,54 @@ | ||
import React from "react"; | ||
import { getTimeOfDay } from "../functions/common"; | ||
import { DOMAIN } from "../functions/constants"; | ||
import { Props } from "../interfaces"; | ||
import { NavMenu } from "./common"; | ||
import TitleHead from "./TitleHead"; | ||
import Head from "next/head"; | ||
|
||
const Layout = ({ children, title, token }: Props) => ( | ||
<div> | ||
<TitleHead title={title}> | ||
<meta | ||
name="description" | ||
content="The Reddit client for Silicon Valley. " | ||
/> | ||
<meta property="og:url" content={DOMAIN} /> | ||
<meta | ||
property="og:description" | ||
content="The Reddit client for Silicon Valley. " | ||
/> | ||
<meta property="og:image" content={`${DOMAIN}/reddium-mockup.png`} /> | ||
</TitleHead> | ||
<header> | ||
<nav className="flex items-center justify-center max-width-main mx-auto z-50 h-16 my-6 lg:mx-12 sm:mx-6"> | ||
<div className="flex-grow flex items-center"> | ||
<a href="/"> | ||
<div className="pr-4 nav-img h-8 flex flex-row items-center cursor-pointer sm:border-0"> | ||
<img className="h-full sm:h-6" src="reddium_symbol.svg" /> | ||
<h1 className="ml-4 site-name text-3xl tracking-tighter sm:hidden text-black"> | ||
Reddium | ||
interface LayoutProps { | ||
children: React.ReactNode; | ||
title?: string; | ||
token: string | null; // Adjust the type according to your token's actual type | ||
} | ||
|
||
const Layout = ({ children, title = "This is the default title", token }: LayoutProps) => { | ||
return ( | ||
<div> | ||
<Head> | ||
<title>{title}</title> | ||
<meta | ||
name="description" | ||
content="The Reddit client for Silicon Valley. " | ||
/> | ||
<meta property="og:url" content={DOMAIN} /> | ||
<meta | ||
property="og:description" | ||
content="The Reddit client for Silicon Valley. " | ||
/> | ||
<meta property="og:image" content={`${DOMAIN}/reddium-mockup.png`} /> | ||
</Head> | ||
<header> | ||
<nav className="flex items-center justify-center max-width-main mx-auto z-50 h-16 my-6 lg:mx-12 sm:mx-6"> | ||
<div className="flex-grow flex items-center"> | ||
<a href="/"> | ||
<div className="pr-4 nav-img h-8 flex flex-row items-center cursor-pointer sm:border-0"> | ||
<img className="h-full sm:h-6" src="reddium_symbol.svg" /> | ||
<h1 className="ml-4 site-name text-3xl tracking-tighter sm:hidden text-black"> | ||
Reddium | ||
</h1> | ||
</div> | ||
</a> | ||
<div className="pl-4"> | ||
<h1 className="font-bold text-lg leading-6 nav-greeting sm:hidden"> | ||
{getTimeOfDay()} | ||
</h1> | ||
</div> | ||
</a> | ||
<div className="pl-4"> | ||
<h1 className="font-bold text-lg leading-6 nav-greeting sm:hidden"> | ||
{getTimeOfDay()} | ||
</h1> | ||
</div> | ||
</div> | ||
<NavMenu token={token} /> | ||
</nav> | ||
</header> | ||
{children} | ||
</div> | ||
); | ||
<NavMenu token={token} /> | ||
</nav> | ||
</header> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React, { createContext, useContext, useState, useEffect } from 'react'; | ||
|
||
interface Config { | ||
[key: string]: string; | ||
} | ||
|
||
const ConfigContext = createContext<Config | null>(null); | ||
|
||
export const useConfig = () => { | ||
const context = useContext(ConfigContext); | ||
if (context === null) { | ||
throw new Error('useConfig must be used within a ConfigProvider'); | ||
} | ||
return context; | ||
}; | ||
|
||
export const ConfigProvider: React.FC<React.PropsWithChildren<{}>> = ({ children }) => { | ||
const [config, setConfig] = useState<Config | null>(null); | ||
|
||
useEffect(() => { | ||
fetch('/api/config') | ||
.then(response => response.json()) | ||
.then(data => { | ||
setConfig(data); | ||
console.log('Fetched config:', data); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching config:', error); | ||
}); | ||
}, []); | ||
|
||
if (config === null) { | ||
return <div>Loading configuration...</div>; // Or any loading indicator | ||
} | ||
|
||
return <ConfigContext.Provider value={config}>{children}</ConfigContext.Provider>; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.