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: minor fixes
  • Loading branch information
Bartek532 committed Jul 5, 2023
commit aa26fdbfbcb649226f127a04a1f129c6a4fc9417
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ node_modules
.next
yarn.lock
package-lock.json
pnpm-lock.yaml
public
dist
28 changes: 14 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ If you spot a typo or an error, please boldly let me know. **You can also write
Description of the project files and directories.

```bash
├── app/ # Next.js app directory (v13)
├── components/ # React components
├── content/ # All .mdx files with content
├── context/ # React context global state
├── data/ # Global available data
├── env/ # Env variables handling (validation)
├── hooks/ # Shared React hooks
├── lib/ # Lib files
├── pages/ # Next.js pages
├── providers/ # React context global state
├── scripts/ # Scripts executed during deployment (algolia, redirects, feed)
├── public/ # All images, icons, fonts
├── styles/ # All shared styles
├── types/ # TypeScript types
Expand All @@ -37,19 +39,16 @@ Description of the project files and directories.
├── .prettierignore # Files ignored by Prettier
├── .prettierrc # Code convention enforced by Prettier
├── build.sh # Deployment script
├── generateAlgoliaItems.ts # Script to generate Algolia index
├── generateFeed.ts # Script to generate xml and json feed
├── generateNewPostRedirect.ts # Script to generate new post redirect
├── next.config.js # Next.js config
├── package.json # Dependencies and additional information
├── README.md
├── tsconfig.json # Typescript configuration
└── yarn.lock # Yarn lockfile
└── pnpm-lock.yaml # Pnpm lockfile
```

## Styleguide

Coding conventions are enforced by [ESLint](.eslintrc.js) and [Prettier](.prettierrc).
Coding conventions are enforced by [ESLint](.eslintrc.json) and [Prettier](.prettierrc).

- Semicolons
- Double quotes
Expand All @@ -60,7 +59,7 @@ Coding conventions are enforced by [ESLint](.eslintrc.js) and [Prettier](.pretti
- Trailing commas in arrays and objects
- [Non-default exports](https://humanwhocodes.com/blog/2019/01/stop-using-default-exports-javascript-module/) are preferred for components
- Module imports are ordered and separated: **built-in** -> **external** -> **internal** -> **css/assets/other**
- TypeScript: strict mode, with no implicitly any
- TypeScript: strict mode, with strict ESLint rules

## Example component structure

Expand All @@ -74,9 +73,9 @@ Coding conventions are enforced by [ESLint](.eslintrc.js) and [Prettier](.pretti
import styles from "./component.module.scss";
import { memo } from "react";

type ComponentProps = {
interface ComponentProps {
readonly title: string;
};
}

export const Component = memo<ComponentProps>(({ title }) => {
return <h1>{title}</h1>;
Expand All @@ -90,16 +89,17 @@ Component.displayName = "Component";
| Tech | Description |
| --------------------------------------------------------- | ------------------------------------------------------------------- |
| [TypeScript](https://www.typescriptlang.org/) | Static type-checking programming language |
| [Next.js](https://nextjs.org/) | The React Framework for Production |
| [Next.js 13](https://nextjs.org/) | The React Framework for Production |
| [React](https://reactjs.org/) | Library for building user interfaces |
| [MDX](https://mdxjs.com/) | Markdown for the component era |
| [Algolia](https://www.algolia.com/) | Implementing search |
| [Algolia](https://www.algolia.com/) | Implementing powerful search |
| [Framer Motion](https://www.framer.com/motion/) | Motion library for React |
| [Context API](https://reactjs.org/docs/context.html) | React structure that enables to share data with multiple components |
| [React Query](https://react-query.tanstack.com/) | Performant and powerful data synchronization for React |
| [React Hook Form](https://react-hook-form.com) | Forms with easy-to-use validation |
| [Vercel KV](https://vercel.com/docs/storage/vercel-kv) | Durable Redis database |
| [SCSS](https://sass-lang.com) | CSS with superpowers |
| [CSS Modules](https://github.com/css-modules/css-modules) | Styles convention in React |
| [Husky](https://github.com/typicode/husky) | Git hooks |
| [Zod](https://zod.dev) | TypeScript-first schema validation with static type inference |
| [Husky](https://github.comtypicode/husky) | Git hooks |
| [ESLint](https://eslint.org/) | TypeScript linting |
| [Prettier](https://prettier.io/) | Code formatter |
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ Please read [CONTRIBUTING.md](https://github.com/Bartek532/zagrodzki.me/blob/mai
| Tech | Description |
| --------------------------------------------------------- | ------------------------------------------------------------------- |
| [TypeScript](https://www.typescriptlang.org/) | Static type-checking programming language |
| [Next.js](https://nextjs.org/) | The React Framework for Production |
| [Next.js 13](https://nextjs.org/) | The React Framework for Production |
| [React](https://reactjs.org/) | Library for building user interfaces |
| [MDX](https://mdxjs.com/) | Markdown for the component era |
| [Algolia](https://www.algolia.com/) | Implementing search |
| [Supabase](https://supabase.com/) | Open source database |
| [Algolia](https://www.algolia.com/) | Implementing powerful search |
| [Framer Motion](https://www.framer.com/motion/) | Motion library for React |
| [Context API](https://reactjs.org/docs/context.html) | React structure that enables to share data with multiple components |
| [React Query](https://react-query.tanstack.com/) | Performant and powerful data synchronization for React |
| [React Hook Form](https://react-hook-form.com) | Forms with easy-to-use validation |
| [Vercel KV](https://vercel.com/docs/storage/vercel-kv) | Durable Redis database |
| [SCSS](https://sass-lang.com) | CSS with superpowers |
| [CSS Modules](https://github.com/css-modules/css-modules) | Styles convention in React |
| [Husky](https://github.com/typicode/husky) | Git hooks |
| [Zod](https://zod.dev) | TypeScript-first schema validation with static type inference |
| [Husky](https://github.comtypicode/husky) | Git hooks |
| [ESLint](https://eslint.org/) | TypeScript linting |
| [Prettier](https://prettier.io/) | Code formatter |

Expand All @@ -44,11 +44,11 @@ Please read [CONTRIBUTING.md](https://github.com/Bartek532/zagrodzki.me/blob/mai

git clone https://github.com/Bartek532/zagrodzki.me.git

yarn install
pnpm install

# set up environment variables
cp .env-sample .env.local # set up environment variables

yarn start
pnpm dev

```

Expand Down
2 changes: 1 addition & 1 deletion components/blog/listing/PostsListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const PostsListing = memo<PostsListingProps>(({ popularPosts, categories
<CategoriesList categories={categories} />
<PopularPosts posts={popularPosts} />
<div className={styles.wrapper}>
{searchParams?.has("category") ? (
{searchParams.has("category") ? (
<>
<h2 className={styles.searchedCategory}>
{allCategories.find((c) => c.slug === searchParams.get("category"))?.name}
Expand Down
1 change: 0 additions & 1 deletion components/mdx/author/Author.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const Author = memo<AuthorProps>(({ name }) => {
<div className={styles.info}>
<div className={styles.name}>Written by {author.name}</div>
<p className={styles.description}>{author.meta.description}</p>

<div className={styles.learnMore}>
<Link href={author.meta.about}>Learn more about {author.name.split(" ")[0]}</Link>
</div>
Expand Down
25 changes: 10 additions & 15 deletions components/tile/spotify/api/spotify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "server-only";
import dayjs from "dayjs";
import "server-only";

import { env } from "env/server";

Expand Down Expand Up @@ -73,24 +73,19 @@ export const fetchLastTrack = async () => {
if (isCurrentlyPlayingPayload(currentlyPlayingData)) {
return {
track: currentlyPlayingData.item,
status: currentlyPlayingData.is_playing
? TRACK_STATUS.ONLINE
: TRACK_STATUS.OFFLINE,
status: currentlyPlayingData.is_playing ? TRACK_STATUS.ONLINE : TRACK_STATUS.OFFLINE,
};
}

const recentlyPlayedData = await fetch(
`https://api.spotify.com/v1/me/player/recently-played`,
{
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
},
next: {
revalidate: 60,
},
const recentlyPlayedData = await fetch(`https://api.spotify.com/v1/me/player/recently-played`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
},
);
next: {
revalidate: 60,
},
});

if (!isRecentlyPlayedPayload(recentlyPlayedData)) {
throw new Error("Unexpected error occured!");
Expand Down
38 changes: 19 additions & 19 deletions lib/gtag.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export const reportPageView = (url: string) => {
if (typeof window !== "undefined") {
//@ts-expect-error
window.gtag("config", process.env.GA_TRACKING_ID, {
page_path: url,
});
}
};
// export const reportPageView = (url: string) => {
// if (typeof window !== "undefined") {
// //@ts-expect-error
// window.gtag("config", process.env.GA_TRACKING_ID, {
// page_path: url,
// });
// }
// };

//@ts-expect-error
export const event = ({ action, category, label, value }) => {
if (typeof window !== "undefined") {
//@ts-expect-error
window.gtag("event", action, {
event_category: category,
event_label: label,
value: value,
});
}
};
// //@ts-expect-error
// export const event = ({ action, category, label, value }) => {
// if (typeof window !== "undefined") {
// //@ts-expect-error
// window.gtag("event", action, {
// event_category: category,
// event_label: label,
// value: value,
// });
// }
// };
5 changes: 1 addition & 4 deletions styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@
@use "variables";
@use "reset";

html {
scroll-behavior: smooth;
}

body {
min-height: 100vh;
min-height: -webkit-fill-available;
width: 100%;
overflow-x: hidden;
background-color: var(--bg-100);
color: var(--black-100);
scroll-behavior: smooth;

&::-webkit-scrollbar {
width: 10px;
Expand Down