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

Upgrade to Next.js 13.4 #26

Merged
merged 32 commits into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5f5dc01
fix: remove useless nested anchor tags
Bartek532 Jul 1, 2023
ce13bc9
fix: config things
Bartek532 Jul 1, 2023
18ddc4e
fix: layout view
Bartek532 Jul 1, 2023
d1ed3ec
feat: include env variables validation
Bartek532 Jul 2, 2023
4beed9f
feat: move pages to app dir
Bartek532 Jul 2, 2023
c50f39b
feat: move fetching spotify track to server component
Bartek532 Jul 2, 2023
74d7872
fix: minor cleanups
Bartek532 Jul 2, 2023
924cb73
feat: optimize fonts
Bartek532 Jul 2, 2023
3ed644a
fix: more lint fixes
Bartek532 Jul 2, 2023
670a9b5
fix: minor fixes in about view
Bartek532 Jul 2, 2023
33ae4eb
fix: minor things in projects/posts
Bartek532 Jul 2, 2023
7ac6864
feat: adjust eslint config
Bartek532 Jul 3, 2023
88991d9
feat: move sending emails from contact form to server action
Bartek532 Jul 3, 2023
ef6fb5f
fix: renames
Bartek532 Jul 3, 2023
be69467
fix: mdx components
Bartek532 Jul 3, 2023
edcec9d
feat: migrate from supabase to vercel kv in tracking views
Bartek532 Jul 3, 2023
651dd8a
fix: move mailer integration to server action
Bartek532 Jul 3, 2023
3ee0a3b
feat: move seo things to app dir
Bartek532 Jul 4, 2023
bea4111
fix: remove deprecated pages dir
Bartek532 Jul 4, 2023
2fd2421
fix: remove vercel kv lib as it's bugged now
Bartek532 Jul 5, 2023
aa26fdb
fix: minor fixes
Bartek532 Jul 5, 2023
73928f3
feat: add google analytics tracking
Bartek532 Jul 5, 2023
484fcf3
feat: add some workflows
Bartek532 Jul 5, 2023
f24594c
fix: scripts fixes
Bartek532 Jul 5, 2023
4e32ca1
chore: update deps
Bartek532 Jul 5, 2023
ce871d1
fix: minor build fixes
Bartek532 Jul 5, 2023
2bb0219
fix: standarize envs
Bartek532 Jul 5, 2023
8a0b792
fix: minor deploy fixes
Bartek532 Jul 5, 2023
1fe8c45
fix: paths
Bartek532 Jul 5, 2023
1df994e
fix: analysis workflow
Bartek532 Jul 5, 2023
e3029d2
fix: scrolling issues on mdx
Bartek532 Jul 6, 2023
86030d4
fix: spotify track fetching
Bartek532 Jul 6, 2023
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
Prev Previous commit
Next Next commit
fix: more lint fixes
  • Loading branch information
Bartek532 committed Jul 2, 2023
commit 3ed644af69b3ca8591debd73f9b4cb46f3b2e7b0
30 changes: 21 additions & 9 deletions components/about/AboutView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { allPositions } from "data/experience";
import { allFacts } from "data/facts";
import { allRecommendations } from "data/recommendations";
import { allSkills } from "data/skills";
import { env } from "env/client";
import { useTheme } from "providers/ThemeProvider";
import GithubGraphDark from "public/img/gh-graph-dark.png";
import GithubGraphLight from "public/img/gh-graph-light.png";

import styles from "./aboutView.module.scss";
import { Experience } from "./components/experience/Experience";
Expand All @@ -34,28 +37,37 @@ export const AboutView = ({ views }: { views: number }) => {
I'm always open to new suggestions. If you have an
unconventional offer or want to see what else I have to offer,
contact me at{" "}
<Link href="mailto:[email protected]">[email protected]</Link>
<Link href={`mailto:${env.NEXT_PUBLIC_EMAIL}`}>
{env.NEXT_PUBLIC_EMAIL}
</Link>
</p>
</div>
<div className={styles.contact}>
<h2 className={styles.title}>Contact</h2>
<p className={styles.description}>
You can contact me directly from my{" "}
<Link href="/contact">website</Link>, via{" "}
<Link href="mailto:[email protected]">email</Link>,{" "}
<Link href="https://facebook.com/bzagrodzki">Facebook</Link>,{" "}
<Link href="https://twitter.com/bzagrodzki">Twitter</Link> or other
social media. I reply to all messages! Ask me anything, I&apos;m not
afraid of any topics.
<Link href={`mailto:${env.NEXT_PUBLIC_EMAIL}`}>email</Link>,{" "}
<Link
href={`https://facebook.com/${env.NEXT_PUBLIC_FACEBOOK_USERNAME}`}
>
Facebook
</Link>
,{" "}
<Link
href={`https://twitter.com/${env.NEXT_PUBLIC_TWITTER_USERNAME}`}
>
Twitter
</Link>{" "}
or other social media. I reply to all messages! Ask me anything,
I&apos;m not afraid of any topics.
</p>
</div>
</div>
<Recommendations recommendations={allRecommendations} />
<figure className={styles.githubGraph}>
<Image
src={`/img/gh-graph-${theme}.png`}
width="1127"
height="297"
src={theme === "dark" ? GithubGraphDark : GithubGraphLight}
alt="My Github contributions graph"
/>
<figcaption className={styles.caption}>
Expand Down
16 changes: 8 additions & 8 deletions components/about/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
export type Fact = {
export interface Fact {
readonly title: string;
readonly icon: string;
readonly description: string;
};
}

export type Position = {
export interface Position {
readonly position: string;
readonly company: string;
readonly date: string;
readonly id: number;
readonly link: string;
};
}

export type Skill = {
export interface Skill {
readonly name: string;
readonly slug: string;
readonly color: string;
readonly link: string;
};
}

export type Recommendation = {
export interface Recommendation {
readonly content: string;
readonly author: {
readonly name: string;
readonly position: string;
readonly image: string;
};
};
}
5 changes: 4 additions & 1 deletion components/layout/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import dynamic from "next/dynamic";
import NextLink from "next/link";

import { Link } from "components/mdx/link/Link";
import { env } from "env/client";
import { useWindowSize } from "hooks/useWindowSize";
import { useTheme } from "providers/ThemeProvider";
import Logo from "public/svg/logo.svg";
Expand Down Expand Up @@ -48,7 +49,9 @@ export const Footer = () => (
Feel free to reach out if you&apos;re looking for a developer, have a
question or just want to connect 📭
</p>
<Link href="mailto:[email protected]">[email protected]</Link>
<Link href={`mailto:${env.NEXT_PUBLIC_EMAIL}`}>
{env.NEXT_PUBLIC_EMAIL}
</Link>

<div className={styles.links}>
<NextLink href="/" className={styles.home}>
Expand Down
2 changes: 1 addition & 1 deletion components/tile/spotifyTile/api/spotify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const getAccessToken = async (refreshToken: string) => {
"Content-Type": "application/x-www-form-urlencoded",
},
next: {
revalidate: false,
revalidate: 0,
},
},
);
Expand Down
4 changes: 4 additions & 0 deletions env/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const clientSchema = z.object({
NEXT_PUBLIC_TWITTER_USERNAME: z.string(),
NEXT_PUBLIC_LINKEDIN_USERNAME: z.string(),
NEXT_PUBLIC_GITHUB_USERNAME: z.string(),
NEXT_PUBLIC_FACEBOOK_USERNAME: z.string(),
NEXT_PUBLIC_EMAIL: z.string().email(),
});

/**
Expand All @@ -23,4 +25,6 @@ export const clientEnv = {
NEXT_PUBLIC_TWITTER_USERNAME: process.env.NEXT_PUBLIC_TWITTER_USERNAME,
NEXT_PUBLIC_LINKEDIN_USERNAME: process.env.NEXT_PUBLIC_LINKEDIN_USERNAME,
NEXT_PUBLIC_GITHUB_USERNAME: process.env.NEXT_PUBLIC_GITHUB_USERNAME,
NEXT_PUBLIC_FACEBOOK_USERNAME: process.env.NEXT_PUBLIC_FACEBOOK_USERNAME,
NEXT_PUBLIC_EMAIL: process.env.NEXT_PUBLIC_EMAIL,
};
23 changes: 17 additions & 6 deletions hooks/useIntersectionObserver.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { useEffect, useState, useRef } from "react";

type IntersectionObserverOptions = Pick<IntersectionObserverInit, "rootMargin" | "threshold">;
type IntersectionObserverOptions = Pick<
IntersectionObserverInit,
"rootMargin" | "threshold"
>;
type ObserverCallback = (entry: IntersectionObserverEntry) => void;
type Observer = {
interface Observer {
readonly key: string;
readonly intersectionObserver: IntersectionObserver;
readonly elementToCallback: Map<Element, ObserverCallback>;
};
}

export const useIntersectionObserver = <T extends Element = HTMLElement>(options: IntersectionObserverOptions) => {
export const useIntersectionObserver = <T extends Element = HTMLElement>(
options: IntersectionObserverOptions,
) => {
const unobserve = useRef<Map<T, () => void>>(new Map());

const [entry, setEntry] = useState<IntersectionObserverEntry | null>(null);
Expand Down Expand Up @@ -40,6 +45,7 @@ export const useIntersectionObserver = <T extends Element = HTMLElement>(options
}, []);

if (typeof window === "undefined") {
// eslint-disable-next-line @typescript-eslint/no-empty-function
return { entry: null, observeElement: () => {}, cleanup: () => {} };
}

Expand Down Expand Up @@ -76,8 +82,13 @@ const observe = (() => {
return observer;
};

return <T extends Element>(el: T, callback: ObserverCallback, options: IntersectionObserverOptions) => {
const { key, intersectionObserver, elementToCallback } = createObserver(options);
return <T extends Element>(
el: T,
callback: ObserverCallback,
options: IntersectionObserverOptions,
) => {
const { key, intersectionObserver, elementToCallback } =
createObserver(options);
elementToCallback.set(el, callback);
intersectionObserver.observe(el);

Expand Down
14 changes: 10 additions & 4 deletions hooks/useRunningHeader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const options = {
export const useRunningHeader = () => {
const [id, setId] = useState("");

const { observeElement, entry, cleanup } = useIntersectionObserver<HTMLElement>(options);
const { observeElement, entry, cleanup } = useIntersectionObserver(options);

const currentlyVisibleHeaders = useRef<Set<HTMLElement>>(new Set());

Expand All @@ -20,7 +20,9 @@ export const useRunningHeader = () => {

return;
}
el.querySelectorAll<HTMLElement>("h2, h3, h4, h5, h6, #introduction").forEach(observeElement);
el.querySelectorAll<HTMLElement>(
"h2, h3, h4, h5, h6, #introduction",
).forEach(observeElement);
};

useEffect(() => {
Expand All @@ -34,12 +36,16 @@ export const useRunningHeader = () => {
currentlyVisibleHeaders.current.delete(entry.target as HTMLElement);
}

const highestEl = [...currentlyVisibleHeaders.current].reduce<HTMLElement | null>((acc, node) => {
const highestEl = [
...currentlyVisibleHeaders.current,
].reduce<HTMLElement | null>((acc, node) => {
if (!acc) {
return node;
}

if (acc.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_PRECEDING) {
if (
acc.compareDocumentPosition(node) & Node.DOCUMENT_POSITION_PRECEDING
) {
return node;
}

Expand Down
26 changes: 0 additions & 26 deletions hooks/useTheme.ts

This file was deleted.

18 changes: 10 additions & 8 deletions lib/posts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import path from "path";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";

import { getAllResources, getResourcesPaths, getResourceBySlug, getResourceParsedContent } from "lib/resource";
import {
getAllResources,
getResourcesPaths,
getResourceBySlug,
getResourceParsedContent,
} from "lib/resource";

import type { Post } from "types";

dayjs.extend(customParseFormat);
Expand Down Expand Up @@ -38,27 +44,23 @@ export const sortPostsByNewest = (posts: Post[]) => {
});
};

const filterUnpublishedPosts = (posts: Post[]) => posts.filter((post) => post.isPublished);

export const getPublishedPosts = () => {
const posts = getAllPosts();

return filterUnpublishedPosts(posts);
return posts.filter((post) => post.isPublished);
};

export const getNewestPosts = () => {
const publishedPosts = getPublishedPosts();
const sortedPosts = sortPostsByNewest(publishedPosts);

return sortedPosts;
return sortPostsByNewest(publishedPosts);
};

export const getPostsCategories = () => {
const posts = getPublishedPosts();
const allCategories = posts.map((post) => post.category);
const uniqueCategories = [...new Set(allCategories)];

return uniqueCategories;
return [...new Set(allCategories)];
};

export const getPopularPosts = () => {
Expand Down
11 changes: 8 additions & 3 deletions lib/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import path from "path";
import dayjs from "dayjs";
import customParseFormat from "dayjs/plugin/customParseFormat";

import { getAllResources, getResourcesPaths, getResourceBySlug, getResourceParsedContent } from "lib/resource";
import {
getAllResources,
getResourcesPaths,
getResourceBySlug,
getResourceParsedContent,
} from "lib/resource";

import type { Project } from "types";

dayjs.extend(customParseFormat);
Expand Down Expand Up @@ -49,7 +55,6 @@ export const sortProjectsByPriority = (projects: Project[]) => {

export const getBestProjects = () => {
const projects = getAllProjects();
const sortedProjects = sortProjectsByPriority(projects);

return sortedProjects;
return sortProjectsByPriority(projects);
};
9 changes: 5 additions & 4 deletions lib/resource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import unified from "unified";

import type { Project, Post } from "types";
import { commonRehypePlugins } from "utils/markdown";

import type { Project, Post } from "types";

const MDX_REGEX = /\.mdx$/;

type Resource = Project | Post;
Expand All @@ -31,9 +32,9 @@ const getResourceFrontmatter = <T extends Resource>(

export const getAllResources = <T extends Resource>(resourcePath: string) => {
const filenames = fs.readdirSync(resourcePath);
const allResources = filenames.map((filename) => {
return getResourceFrontmatter<T>(filename, resourcePath);
});
const allResources = filenames.map((filename) =>
getResourceFrontmatter<T>(filename, resourcePath),
);

return allResources;
};
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"@svgr/webpack": "^5.5.0",
"@types/gtag.js": "^0.0.8",
"@types/invariant": "^2.2.35",
"@types/mapbox__rehype-prism": "0.8.0",
"@types/node": "16.11.10",
"@types/react": "17.0.37",
"@types/react-dom": "^17.0.11",
Expand Down
Loading