Skip to content

Codex: Start app router migration #314

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
25 changes: 25 additions & 0 deletions app/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import '../styles/global.css'
import Providers from './providers'
import Script from 'next/script'
import { GA_TRACKING_ID } from '../lib/gtag'

export const metadata = {
title: 'Hyper',
description: 'The official website for the Hyper terminal',
}

export default function RootLayout({ children }) {
return (
<html lang="en">
<head>
<Script async src={`https://www.googletagmanager.com/gtag/js?id=${GA_TRACKING_ID}`} />
<Script id="gtag-init" dangerouslySetInnerHTML={{
__html: `window.dataLayer = window.dataLayer || [];function gtag(){dataLayer.push(arguments);}gtag('js', new Date());gtag('config', '${GA_TRACKING_ID}');`,
}} />
</head>
<body>
<Providers>{children}</Providers>
</body>
</html>
)
}
8 changes: 8 additions & 0 deletions app/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import HomePage, { getStaticProps } from '../pages/index'

export const revalidate = 60 * 60 * 24

export default async function Page() {
const { props } = await getStaticProps()
return <HomePage {...props} />
}
27 changes: 27 additions & 0 deletions app/providers.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use client'
import { useState, useEffect } from 'react'
import { usePathname } from 'next/navigation'
import NProgress from 'nprogress'
import { pageView as gTagPageView } from '../lib/gtag'
import { SearchContext } from '../lib/search-context'

export default function Providers({ children }) {
const [search, setSearch] = useState('')
const pathname = usePathname()

useEffect(() => {
const timeout = setTimeout(NProgress.start, 500)
gTagPageView(window.location.href)
return () => {
clearTimeout(timeout)
setSearch('')
NProgress.done()
}
}, [pathname])

return (
<SearchContext.Provider value={{ search, setSearch }}>
{children}
</SearchContext.Provider>
)
}
8 changes: 6 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const withMDX = require('@next/mdx')({
extension: /\.mdx?$/,
})

module.exports = withMDX({
/** @type {import('next').NextConfig} */
const nextConfig = {
pageExtensions: ['js', 'mdx'],
})
experimental: { appDir: true },
}

module.exports = withMDX(nextConfig)
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@
"start": "next start"
},
"dependencies": {
"@mdx-js/loader": "^1.6.4",
"@mdx-js/react": "^1.6.4",
"@next/mdx": "^9.4.2",
"@mdx-js/loader": "^2.4.1",
"@mdx-js/react": "^2.4.1",
"@next/mdx": "^14.1.0",
"copee": "^1.0.6",
"husky": "^4.2.5",
"image-size": "^0.9.3",
"lint-staged": "^10.2.3",
"next": "^13.0.5",
"husky": "^8.0.0",
"image-size": "^1.0.0",
"lint-staged": "^15.0.0",
"next": "^14.1.0",
"nprogress": "^0.2.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-gravatar": "^2.6.3",
"react-highlighter": "^0.4.3"
},
"devDependencies": {
"prettier": "^2.0.5",
"shell-quote": "^1.7.2"
"prettier": "^3.0.0",
"shell-quote": "^1.8.0"
},
"prettier": {
"singleQuote": true,
Expand Down