Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the redesign branch with the changes on main #151

Merged
merged 18 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bun.lockb
Binary file not shown.
4,662 changes: 0 additions & 4,662 deletions package-lock.json

This file was deleted.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
},
"dependencies": {
"@fortawesome/free-regular-svg-icons": "^6.4.2",
"@vercel/speed-insights": "^1.1.0",
"caniuse-lite": "^1.0.30001690",
"framer-motion": "^10.16.4",
"next": "latest",
"react": "^18",
Expand Down
12 changes: 9 additions & 3 deletions src/app/api/link/[slug]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function GET(

const headers = initHeaders()

const result = await fetch(
const response = await fetch(
`https://api.notion.com/v1/databases/${
process.env.NOTION_LINKS_DB ?? ''
}/query`,
Expand All @@ -28,12 +28,18 @@ export async function GET(
headers,
body,
}
).then(res => res.json())
)

if (response.status === 404) {
return createError('Link database not found', 404)
}

const result = await response.json()

const dest: string = result.results[0].properties.Destination.url

if (!dest) {
return createError(`There's no link with name '${params.slug}'`, 400)
return createError(`There's no link with name '${params.slug}'`, 404)
}

return Response.json(dest)
Expand Down
10 changes: 8 additions & 2 deletions src/app/api/posts/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function GET(

const headers = initHeaders()

const result = await fetch(
const response = await fetch(
`https://api.notion.com/v1/databases/${
process.env.NOTION_POSTS_DB ?? ''
}/query`,
Expand All @@ -30,7 +30,13 @@ export async function GET(
headers,
body,
}
).then(res => res.json())
)

if (response.status === 404) {
return createError('Post database not found', 404)
}

const result = await response.json()

const posts: Post[] = parsePages(result.results)

Expand Down
10 changes: 8 additions & 2 deletions src/app/api/posts/main-page/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function GET(request: NextRequest) {

const headers = initHeaders()

const result = await fetch(
const response = await fetch(
`https://api.notion.com/v1/databases/${
process.env.NOTION_POSTS_DB ?? ''
}/query`,
Expand All @@ -28,7 +28,13 @@ export async function GET(request: NextRequest) {
headers,
body,
}
).then(res => res.json())
)

if (response.status === 404) {
return createError('Post database not found', 404)
}

const result = await response.json()

const posts: Post[] = parsePages(result.results)

Expand Down
10 changes: 8 additions & 2 deletions src/app/api/posts/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function GET(request: NextRequest) {
try {
const headers = initHeaders()

const result = await fetch(
const response = await fetch(
`https://api.notion.com/v1/databases/${
process.env.NOTION_POSTS_DB ?? ''
}/query`,
Expand All @@ -17,7 +17,13 @@ export async function GET(request: NextRequest) {
redirect: 'follow',
headers,
}
).then(res => res.json())
)

if (response.status === 404) {
return createError('Post database not found', 404)
}

const result = await response.json()

const posts: Post[] = parsePages(result.results)

Expand Down
2 changes: 1 addition & 1 deletion src/app/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Button(
props.defaultCursor && 'cursor-default'
} rounded-md border p-2 [box-shadow:1px_-4px_3px_0_#00000070_inset] disabled:cursor-default disabled:opacity-50 dark:border-primary-950 ${
buttonColors[props.color ?? 'primary']
} ` + props.className ?? ''
} ` + (props.className ?? '')
}
disabled={props.disabled ?? false}
onClick={() => {
Expand Down
12 changes: 7 additions & 5 deletions src/app/components/Countdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ export default function Countdown(props: {
const [difference, setDifference] = useState(0)

useEffect(() => {
setInterval(() => {
const intervalId = setInterval(() => {
const newDifference = props.to.getTime() - new Date().getTime()
console.log(newDifference)

setDifference(newDifference)
}, 100)
}, 10)

return () => clearInterval(intervalId)
}, [props.to])

// var days = Math.floor(difference / (1000 * 60 * 60 * 24))
var days = Math.floor(difference / (1000 * 60 * 60 * 24))
var hours = Math.floor(
(difference % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
)
Expand All @@ -28,7 +30,7 @@ export default function Countdown(props: {
<>
{difference > 0 && (
<span>
{hours}h {minutes}m {seconds}s {props.countdownSuffix}
{days !== 0 && days + "d"} {hours}h {minutes}m {seconds}s {props.countdownSuffix}
</span>
)}
{difference <= 0 && props.finishedMessage}
Expand Down
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Metadata, Viewport } from 'next'
import './globals.css'
import Navbar from './components/Navbar'
import { getContentFont } from './fonts'
import { SpeedInsights } from '@vercel/speed-insights/next'

export const metadata: Metadata = {
title: 'mineTomek',
Expand Down Expand Up @@ -33,6 +34,7 @@ export default function RootLayout({
<Navbar />
<div className='mt-16 bg-white dark:bg-zinc-900'>{children}</div>
{!process.env.LOADED_ENV && <p>.env isn&apos;t loaded</p>}
<SpeedInsights />
</body>
</html>
)
Expand Down
6 changes: 3 additions & 3 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export default function Home() {
const now = new Date()

const checkForBeginningOfYear = () => {
const beginningDate = new Date(now.getFullYear() - 1, 11, 30)
const beginningDate = new Date(now.getFullYear() - 1, 11, 24)
const endDate = new Date(now.getFullYear(), 0, 8)

return beginningDate < now && now < endDate
}

const checkForEndOfYear = () => {
const beginningDate = new Date(now.getFullYear(), 11, 30)
const beginningDate = new Date(now.getFullYear(), 11, 24)
const endDate = new Date(now.getFullYear() + 1, 0, 8)

return beginningDate < now && now < endDate
Expand Down Expand Up @@ -77,7 +77,7 @@ export default function Home() {
defaultCursor
>
<Countdown
to={new Date(`Jan 1, 2024 0:0:0`)}
to={new Date(new Date().getMonth() < 6 ? new Date().getFullYear() : new Date().getFullYear() + 1, 0, 1)}
countdownSuffix={`until ${new Date().getFullYear() + 1}`}
finishedMessage={`Happy ${new Date()
.getFullYear()
Expand Down
Loading