feat: migrate to Next.js

This commit is contained in:
Konstantin Zhigaylo 2023-08-26 10:03:08 +03:00
parent fbcbe37f5e
commit 9da933e36e
No known key found for this signature in database
GPG key ID: E5D6C0144FC10261
30 changed files with 810 additions and 9457 deletions

3
.eslintrc.json Normal file
View file

@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}

20
.gitignore vendored
View file

@ -8,16 +8,28 @@
# testing
/coverage
# next.js
/.next/
/out/
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
*.pem
# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# local env files
.env*.local
# vercel
.vercel
# typescript
*.tsbuildinfo
next-env.d.ts

View file

@ -1,6 +0,0 @@
{
"arrowParens": "avoid",
"trailingComma": "es5",
"singleQuote": true,
"semi": true
}

38
README.md Normal file
View file

@ -0,0 +1,38 @@
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
## Getting Started
First, run the development server:
```bash
npm run dev
# or
yarn dev
# or
pnpm dev
```
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font.
## Learn More
To learn more about Next.js, take a look at the following resources:
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
## Deploy on Vercel
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

View file

@ -1,9 +1,9 @@
import { Text, HStack } from "@chakra-ui/react";
import { FaCoffee } from "react-icons/fa";
import { useNavigate } from "react-router-dom";
import { useRouter } from "next/router";
function Logo() {
const navigate = useNavigate();
const navigate = useRouter()
function brew_coffee() {
navigate("/coffee");

View file

@ -18,27 +18,27 @@ import {
FaTools,
FaUserFriends,
} from 'react-icons/fa';
import { Navigate, useNavigate } from 'react-router-dom';
import { ColorModeSwitcher } from '../ColorModeSwitcher';
import { useRouter } from 'next/router';
import { ColorModeSwitcher } from '../components/ColorModeSwitcher';
import Logo from './Logo';
function NavBar() {
const navigate = useNavigate();
const navigate = useRouter();
function go_home() {
navigate('/');
navigate.push('/');
}
function go_projects() {
navigate('/projects');
navigate.push('/projects');
}
function go_workspace() {
navigate('/workspace');
navigate.push('/workspace');
}
function go_contacts() {
navigate('/contacts');
navigate.push('/contacts');
}
function go_source() {

View file

@ -19,7 +19,7 @@ function SocialCard(props) {
}}>
<CardBody>
<HStack flex={1}>
<Text fontWeight={700}>{props.social}</Text>
<Text fontWeight={700} fontSize={`sm`}>{props.social}</Text>
<Box flex={1} align="right">
{props.icon}
</Box>

7
jsconfig.json Normal file
View file

@ -0,0 +1,7 @@
{
"compilerOptions": {
"paths": {
"@/*": ["./*"]
}
}
}

6
next.config.js Normal file
View file

@ -0,0 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
}
module.exports = nextConfig

View file

@ -1,45 +1,26 @@
{
"name": "personal-website",
"name": "homepage",
"version": "0.1.0",
"private": true,
"dependencies": {
"@chakra-ui/anatomy": "^2.1.2",
"@chakra-ui/next-js": "^2.1.5",
"@chakra-ui/react": "^2.7.0",
"@chakra-ui/theme-tools": "^2.1.0",
"@emotion/react": "^11.11.0",
"@emotion/styled": "^11.11.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"framer-motion": "^6.5.1",
"next": "^13.4.19",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^3.11.0",
"react-router-dom": "^6.11.2",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
"dependencies": {
"@chakra-ui/anatomy": "^2.2.0",
"@chakra-ui/next-js": "^2.1.5",
"@chakra-ui/react": "^2.8.0",
"@chakra-ui/theme-tools": "^2.1.0",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"eslint": "8.48.0",
"eslint-config-next": "13.4.19",
"framer-motion": "^10.16.1",
"next": "13.4.19",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-icons": "^4.10.1"
}
}

View file

@ -1,12 +1,8 @@
import { Text, Box, Container, Heading, HStack } from "@chakra-ui/react";
import Footer from "../components/Footer";
import NavBar from "../components/NavBar"
import { useEffect } from "react";
function NotFound() {
useEffect(() => {
document.title = "Konstantin Zero - Not Found"
})
return (
<>
<Container justifyContent="left" maxW={750} marginLeft="auto" marginRight="auto">

82
pages/_app.js Normal file
View file

@ -0,0 +1,82 @@
import { ChakraProvider } from "@chakra-ui/react";
import { extendTheme } from "@chakra-ui/react";
import { mode } from "@chakra-ui/theme-tools";
import { Inter, Kalam } from "next/font/google";
const styles = {
global: (props) => ({
body: {
bg: mode("#FCFCFC", "#191919")(props),
transitionProperty: "all",
transitionDuration: "0.3s",
},
}),
};
const components = {
Button: {
baseStyle: {
_hover: {
transform: "scale(1.1)",
},
_active: {
transform: "scale(0.85)",
},
},
},
Text: {
baseStyle: (props) => ({
color: mode("#191919", "#FCFCFC")(props),
transitionProperty: "all",
transitionDuration: ".3s",
fontWeight: "400",
}),
variants: {
"footer-text": (props) => ({
color: mode("#999999", "#999999")(props),
}),
},
},
};
const inter = Inter({ subsets: ["latin"] });
const kalam = Kalam({ weight: "700", subsets: ["latin"] });
const theme = extendTheme({
fonts: {
body: "var(--font-inter)",
heading: "var(--font-kalam)",
},
colors: {
gray: {
50: "#FCFCFC",
100: "#E8E8E8",
200: "#DCDCDC",
300: "#CDCDCD",
700: "#323232",
800: "#191919",
},
},
styles: styles,
config: {
disableTransitionOnChange: false,
},
components: components,
});
export default function App({ Component, pageProps }) {
return (
<>
<style jsx global>
{`
:root {
--font-inter: ${inter.style.fontFamily};
--font-kalam: ${kalam.style.fontFamily};
}`}
</style>
<ChakraProvider theme={theme}>
<Component {...pageProps} />
</ChakraProvider>
</>
);
}

13
pages/_document.js Normal file
View file

@ -0,0 +1,13 @@
import { Html, Head, Main, NextScript } from 'next/document'
export default function Document() {
return (
<Html lang="en">
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
)
}

View file

@ -16,12 +16,12 @@ function Contacts() {
<NavBar/>
<Box margin="15px" marginTop="20px">
<HStack flex={1}>
<Heading fontSize="6xl" fontWeight={700} textDecoration="underline" fontFamily="Kalam">Contacts.</Heading>
<Heading fontSize="6xl" fontWeight={700} textDecoration="underline">Contacts.</Heading>
</HStack>
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Email.</Heading>
<Heading fontSize="4xl" fontWeight={700}>Email.</Heading>
</HStack>
<Text fontSize="lg">
The only one mailbox where you can send me an email.
@ -30,7 +30,7 @@ function Contacts() {
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Blogs.</Heading>
<Heading fontSize="4xl" fontWeight={700}>Blogs.</Heading>
</HStack>
<Text fontSize="lg">
I have blogs on Mastodon (usually posting there).
@ -39,7 +39,7 @@ function Contacts() {
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Chats.</Heading>
<Heading fontSize="4xl" fontWeight={700}>Chats.</Heading>
</HStack>
<Text fontSize="lg">
That's where you can contact me for any questions.
@ -50,7 +50,7 @@ function Contacts() {
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Repositories.</Heading>
<Heading fontSize="4xl" fontWeight={700}>Repositories.</Heading>
</HStack>
<Text fontSize="lg">
I have repoistories on GitLab and GitHub (mirror).

View file

@ -1,12 +1,8 @@
import { Text, Box, Container, Heading, HStack, Image, SkeletonCircle } from "@chakra-ui/react";
import { useEffect } from "react";
import Footer from "../components/Footer";
import NavBar from "../components/NavBar"
function Home() {
useEffect(() => {
document.title = "Konstantin Zero - Home"
})
return (
<>
<Container justifyContent="left" maxW={750} marginLeft="auto" marginRight="auto">

View file

@ -1,13 +1,8 @@
import { Text, Box, Container, Heading, HStack, Badge } from "@chakra-ui/react";
import { useEffect } from "react";
import Footer from "../components/Footer";
import NavBar from "../components/NavBar"
function Projects() {
useEffect(() => {
document.title = "Konstantin Zero - Projects"
})
function open_kamiya_gl() {
window.open("https://gitlab.com/kostya-zero/kamiya", "_blank", 'noopener,noreferrer')
}
@ -18,13 +13,6 @@ function Projects() {
window.open("https://crates.io/crates/kamiya", "_blank", 'noopener,noreferrer')
}
function open_pipe_gl() {
window.open("https://gitlab.com/kostya-zero/pipe", "_blank", 'noopener,noreferrer')
}
function open_pipe_gh() {
window.open("https://github.com/kostya-zero/pipe", "_blank", 'noopener,noreferrer')
}
function open_resup_gl() {
window.open("https://gitlab.com/kostya-zero/resup", "_blank", 'noopener,noreferrer')
}
@ -38,12 +26,12 @@ function Projects() {
<NavBar/>
<Box margin="15px" marginTop="20px" >
<HStack flex={1}>
<Heading fontSize="6xl" textDecoration="underline" fontWeight={700} fontFamily="Kalam">Projects.</Heading>
<Heading fontSize="6xl" textDecoration="underline" fontWeight={700}>Projects.</Heading>
</HStack>
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Kamiya</Heading>
<Heading fontSize="4xl" fontWeight={700}>Kamiya</Heading>
<Box flex={1} align="right">
<Text>Available on</Text>
<Badge colorScheme="orange" align="right" onClick={open_kamiya_gl} cursor="pointer">GitLab</Badge>
@ -59,7 +47,7 @@ function Projects() {
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Resup</Heading>
<Heading fontSize="4xl" fontWeight={700}>Resup</Heading>
<Box flex={1} align="right">
<Text>Available on</Text>
<Badge colorScheme="orange" align="right" onClick={open_resup_gl} cursor="pointer">GitLab</Badge>

View file

@ -26,12 +26,12 @@ function Workspace() {
<NavBar/>
<Box margin="15px" marginTop="20px" >
<HStack flex={1}>
<Heading fontSize="6xl" fontWeight={700} textDecoration="underline" fontFamily="Kalam">Workspace.</Heading>
<Heading fontSize="6xl" fontWeight={700} textDecoration="underline">Workspace.</Heading>
</HStack>
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Main OS.</Heading>
<Heading fontSize="4xl" fontWeight={700}>Main OS.</Heading>
</HStack>
<Text fontSize="lg">
I use Fedora Linux as my main operating system.
@ -49,7 +49,7 @@ function Workspace() {
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Editor.</Heading>
<Heading fontSize="4xl" fontWeight={700}>Editor.</Heading>
</HStack>
<Text fontSize="lg">
I use <b>Neovim</b> as code editor.
@ -67,7 +67,7 @@ function Workspace() {
</Box>
<Box margin="15px" marginTop="35px" >
<HStack flex={1}>
<Heading fontSize="4xl" fontWeight={700} fontFamily="Kalam">Shell.</Heading>
<Heading fontSize="4xl" fontWeight={700}>Shell.</Heading>
</HStack>
<Text fontSize="lg">
As shell I use <b>fish</b>.

File diff suppressed because it is too large Load diff

BIN
public/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View file

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#ffffff" />
<meta
name="description"
content="Konstantin Zero's homepage."
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<title>Konstantin Zero</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;700&family=Kalam:wght@300;400;700&display=swap" rel="stylesheet">
</head>
<body>
<a hidden rel="me" href="https://md.debilosempire.org/@kostya_zero"></a>
<a hidden rel="me" href="https://mastodon.ml/@kostya_zero"></a>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>

View file

@ -1,25 +0,0 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View file

@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View file

@ -1,30 +0,0 @@
import React from 'react';
import { ChakraProvider } from '@chakra-ui/react';
import theme from './theme/theme';
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
import Home from './pages/Home';
import NotFound from './pages/NotFound';
import Projects from './pages/Projects';
import Workspace from './pages/Workspace';
import Contacts from './pages/Contacts';
import GreenTea from './pages/GreenTea';
function App() {
return (
<ChakraProvider theme={theme}>
<Router>
<Routes>
<Route path='/' element={<Home/>} />
<Route path='/projects' element={<Projects/>} />
<Route path='/workspace' element={<Workspace/>} />
<Route path='/contacts' element={<Contacts/>} />
<Route path='/coffee' element={<GreenTea/>} />
<Route path='*' element={<NotFound/>}/>
</Routes>
</Router>
</ChakraProvider>
);
}
export default App;

View file

@ -1,18 +0,0 @@
import React from 'react';
import { Image, keyframes, usePrefersReducedMotion } from '@chakra-ui/react';
import logo from './logo.svg';
const spin = keyframes`
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
`;
export const Logo = props => {
const prefersReducedMotion = usePrefersReducedMotion();
const animation = prefersReducedMotion
? undefined
: `${spin} infinite 20s linear`;
return <Image animation={animation} src={logo} {...props} />;
};

View file

@ -1,20 +0,0 @@
import { ColorModeScript } from '@chakra-ui/react';
import React, { StrictMode } from 'react';
import * as ReactDOM from 'react-dom/client';
import App from './App';
import * as serviceWorker from './serviceWorker';
const container = document.getElementById('root');
const root = ReactDOM.createRoot(container);
root.render(
<StrictMode>
<ColorModeScript />
<App />
</StrictMode>
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://cra.link/PWA
serviceWorker.unregister();

View file

@ -1,141 +0,0 @@
// This optional code is used to register a service worker.
// register() is not called by default.
// This lets the app load faster on subsequent visits in production, and gives
// it offline capabilities. However, it also means that developers (and users)
// will only see deployed updates on subsequent visits to a page, after all the
// existing tabs open on the page have been closed, since previously cached
// resources are updated in the background.
// To learn more about the benefits of this model and instructions on how to
// opt-in, read https://cra.link/PWA
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://cra.link/PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then(registration => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://cra.link/PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It is the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch(error => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then(response => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then(registration => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then(registration => {
registration.unregister();
})
.catch(error => {
console.error(error.message);
});
}
}

View file

@ -1,62 +0,0 @@
import { extendTheme } from "@chakra-ui/react";
import { mode } from "@chakra-ui/theme-tools";
const styles = {
global: props => ({
body: {
bg: mode("#FCFCFC", "#191919")(props),
transitionProperty: "all",
transitionDuration: "0.3s"
}
})
}
const components = {
Button: {
baseStyle: {
_hover: {
transform: "scale(1.1)",
},
_active: {
transform: "scale(0.85)"
}
}
},
Text: {
baseStyle: props => ({
color: mode("#191919", "#FCFCFC")(props),
transitionProperty: "all",
transitionDuration: ".3s",
fontWeight: "400"
}),
variants: {
'footer-text': props => ({
color: mode("#999999", "#999999")(props)
})
}
}
}
const theme = extendTheme({
fonts: {
body: 'Inter, sans-serif',
heading: 'Kalam, serif',
},
colors: {
gray: {
50: '#FCFCFC',
100: '#E8E8E8',
200: '#DCDCDC',
300: '#CDCDCD',
700: '#323232',
800: '#191919'
},
},
styles: styles,
config: {
disableTransitionOnChange: false
},
components: components
})
export default theme;