-
Notifications
You must be signed in to change notification settings - Fork 3
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
Migrate to Next.js 14 app directory #156
Conversation
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. - [Release notes](https://github.com/isaacs/ini/releases) - [Commits](npm/ini@v1.3.5...v1.3.8) Signed-off-by: dependabot[bot] <[email protected]>
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.3. - [Release notes](https://github.com/yargs/y18n/releases) - [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md) - [Commits](yargs/y18n@v4.0.0...y18n-v4.0.3) Signed-off-by: dependabot[bot] <[email protected]>
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/npm/ssri/releases) - [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md) - [Commits](npm/ssri@v6.0.1...v6.0.2) Signed-off-by: dependabot[bot] <[email protected]>
Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.3 to 6.5.4. - [Release notes](https://github.com/indutny/elliptic/releases) - [Commits](indutny/elliptic@v6.5.3...v6.5.4) Signed-off-by: dependabot[bot] <[email protected]>
chore(deps): bump ini from 1.3.5 to 1.3.8
chore(deps): bump y18n from 4.0.0 to 4.0.3
chore(deps): bump ssri from 6.0.1 to 6.0.2
…-6.5.4 chore(deps): bump elliptic from 6.5.3 to 6.5.4
Configure Renovate
fix(deps): pin dependencies
Update dependencies
<ul className="list-none flex flex-wrap pl-0"> | ||
{items.map((tag) => ( | ||
<li | ||
key={`items-${tag}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used template literals including prefixes for the values of key props
`; | ||
|
||
const ExperimentItem = ({ experiment }: Props) => { | ||
export function ExperimentItem({ experiment }: { experiment: Experiment }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added new created type from line 9 to avoid any
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a PR in upstream
import { AllHTMLAttributes } from 'react'; | ||
import { cn } from '../utils/cn'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed imported HTMLAttributes since it is never used, and changed to relative imports
<a | ||
href="https://github.com/vickOnRails/next-starter-peacock" | ||
target="_blank" | ||
rel="noopener noreferrer" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed typo from norefferrer
to noreferrer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any of these changes can also be a separate new PR to upstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a small PR to upstream.
components/nav/nav.tsx
Outdated
if (external) { | ||
return ( | ||
<a | ||
data-test-id={dataTestId} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add data-test-id
for Playwright testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed all data-test-ids
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
await page
.locator('div:has-text("WorksArticlesNotesAbout") a')
.nth(4)
.getAttribute('href'),
- doesn't it make more sense to use
nav
here instead ofdiv
? it seems there are 2nav
s, be sure to write a good selector that will select the correct one - I guess using the
.nth()
is also a bit brittle - probably you can do a better version using just
page.locator(...).getAttribute('href')
{notes.map((note) => ( | ||
<Note | ||
key={`note-${note.id}`} | ||
id={note.id} | ||
key={`note-${note.slug}`} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used template literals including prefixes for the values of key props
import { IContent } from '../../utils/content'; | ||
|
||
// TODO: use some type of hash function to generate the colors | ||
const colorsLookup = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed COLORS_LOOKUP
to camelCase colorsLookup
href={`/works/${slug}`} | ||
className={cn( | ||
'group rounded-xl select-none no-underline flex flex-col lg:py-10 w-full md:flex-row transition-transform hover:cursor-pointer hover:scale-[102%] active:scale-95', | ||
colorsLookup[slug as keyof typeof colorsLookup], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a type to avoid any
. slug
is cast to the type keyof typeof colorsLookup
, telling TS that the slug
is a key of the colorsLookup
object.
@@ -0,0 +1,31 @@ | |||
import { IContentType } from './content'; | |||
|
|||
export const contentTypesMap: Map<IContentType, any> = new Map([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed variable CONTENT_TYPES_MAP
to use camelCase
import fs from 'node:fs'; | ||
import path from 'node:path'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the imports from import fs form 'fs'
to import fs form 'node:fs'
. The same for path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these node: changes you added can be added to a 3rd new separate PR to the upstream vickonrails repo - then our repo doesn't diverge as much
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a PR for the upstream changes
tags?: string[]; | ||
category?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add tags
and category
to type IContent
since these values can be optional and this type is used on multiple occasions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be PRed to upstream vickonrails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a PR in upstream
* Sorts content by their dates | ||
* @param a {Date} - Date of post 1 | ||
* @param b {Date} - Date of post 2 | ||
*/ | ||
|
||
export const sortByDate = (a: { date?: Date }, b: { date?: Date }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved the function up to avoid 'sortByDate' being used before it was defined.
.map((contentFile) => { | ||
const filePath = `${contentDir}/${contentFile}`; | ||
const rawContent = fs.readFileSync(filePath, { | ||
.map((contentItem) => { | ||
const contentPath = `${contentDir}/${contentItem}`; | ||
const rawContent = fs.readFileSync(contentPath, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the variable names since they were already declared in line 2 and line 196
id: uuid(), | ||
}; | ||
} as IContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added type assertion because for TS the type returned had previewImage
and id
but this was wrong because in lines 207-209 we spread the data
object and added previewImage
and id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, let's try to avoid a type assertion if possible (for all type assertions)
usually it means that the types need to be more strict somewhere
eg. maybe the data
type:
@@ -221,15 +253,12 @@ export const getContentWithTag = (tag: string, contentType: IContentType) => { | |||
...data, | |||
previewImage: data.previewImage || '/images/image-placeholder.png', | |||
id: uuid(), | |||
}; | |||
} as IContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added type assertion because for TS the type returned had previewImage
and id
but this was wrong because in lines 253-255 we spread the data
object and added previewImage
and id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, let's try to avoid a type assertion if possible (for all type assertions)
usually it means that the types need to be more strict somewhere
eg. maybe the data
type:
const rawContent = fs.readFileSync(filePath, { | ||
.filter((content) => content.endsWith('.md')) | ||
.map((content) => { | ||
const contentPath = `${contentDir}/${content}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed the variable names since it was already declared
@@ -277,15 +306,16 @@ export const getContentInCategory = ( | |||
...data, | |||
previewImage: data.previewImage || '/images/image-placeholder.png', | |||
id: uuid(), | |||
}; | |||
} as IContent; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added type assertion because for TS the type returned had previewImage
and id
but this was wrong because in lines 306-308 we spread the data
object and added previewImage
and id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, wonder why we need this... What are the properties in the data
object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The initial type when hovering over data is
const data: {
[key: string]: any;
}
These are the properties that data
can have, some properties are optional
title: string;
slug: string;
basePath: string;
date: Date;
draft?: boolean;
selectedWork?: boolean;
description?: string;
previewImage?: string;
tags?: string[];
category?: string;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't data
this type? maybe it should have this type applied to it instead?
}); | ||
|
||
articlesContent.sort(sortByDate).forEach((contentItem: IContent) => { | ||
const { title, previewImage, date, slug, description } = contentItem; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed id
, because it was declared but never used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anything unused - eg. a destructured property like this or an unused import - can be PRed to upstream in a separate new PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created a PR in upstream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving to unblock merging before we finish the feedback - I'll finish the remaining feedback afterwards and we can do follow-up PRs if necessary
Closes #152
This PR migrates the portfolio to Next.js 14 and the app directory structure. It imports the necessary changes from the original portfolio and fixes any errors encountered during the process.
TODO
Compare the current changes with the upstream repo:
https://github.com/vickonrails/next-starter-peacock/compare/vickonrails:next-starter-peacock:master...upleveled:next-starter-peacock:update-to-next-14?diff=unified&w=