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

feat: app router [CFISO-1826] #183

Merged
merged 11 commits into from
Oct 7, 2024
Merged

feat: app router [CFISO-1826] #183

merged 11 commits into from
Oct 7, 2024

Conversation

denkristoffer
Copy link
Contributor

@denkristoffer denkristoffer commented Sep 4, 2024

What will change?

  • Next.js 14 with app router
    • uses react-i18next and next-i18n-router together
  • Add live preview for draft articles

Todo

  • README updates.

Copy link

vercel bot commented Sep 4, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
template-blog-webapp-nextjs ✅ Ready (Inspect) Visit Preview Oct 7, 2024 11:33am

@andipaetzold
Copy link
Contributor

andipaetzold commented Sep 12, 2024

Why did you move from next-i18net to react-i18next?

src/app/[locale]/not-found.tsx Outdated Show resolved Hide resolved
}: TranslationProviderProps) {
const i18n = createInstance();

initTranslations({ locale, namespaces, i18nInstance: i18n, resources });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initTranslation is async. So, the instance might not be initialized on render. Is that an issue?

src/app/sitemap.ts Outdated Show resolved Hide resolved
src/app/[locale]/layout.tsx Outdated Show resolved Hide resolved
@denkristoffer
Copy link
Contributor Author

Why did you move from next-i18net to react-i18next?

@andipaetzold The previous library is built for i18n in the "old" next.js so it only works with the pages router.

@andipaetzold

This comment was marked as resolved.

@wiz-inc-38d59fb8d7
Copy link

wiz-inc-38d59fb8d7 bot commented Sep 23, 2024

Wiz Scan Summary

Scan Module Critical High Medium Low Info Total
IaC Misconfigurations 0 0 0 0 0 0
Vulnerabilities 0 4 1 0 0 5
Sensitive Data 0 0 0 0 0 0
Secrets 0 0 0 0 0 0
Total 0 4 1 0 0 5

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.

@denkristoffer
Copy link
Contributor Author

Thanks @andipaetzold, I managed to localise the 404 page and fix the link 🙂

andipaetzold
andipaetzold previously approved these changes Sep 23, 2024
Comment on lines +36 to +39
const days = 30;
const date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
document.cookie = `NEXT_LOCALE=${newLocale};expires=${date.toUTCString()};path=/`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels strange to do this manually...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, so as an explanation: The bug you found with the language switcher was that Next.js middleware doesn't run for cached pages, and the middleware is what automatically sets the language cookie. To get around the bug we can force set the cookie and then call router.refresh() to apply it.

@@ -121,9 +123,10 @@ enum AssetOrder {
}

"""
To have author-related properties [See type definition](https://app.contentful.com/spaces/nvxmqufxogry/content_types/componentAuthor)
To have author-related properties [See type definition](https://app.contentful.com/spaces/7b6c43hr18k6/content_types/componentAuthor)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which space does this new spaceId correspond to?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably my test space. Should we even be including the __generated directory? 🤔

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm it's a good question. Based on the README it seems we expect the user to only (re-)generate the GraphQL schema, types and sdk if the content model changes, while we take care of the initial generation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I re-inserted the old space ID in the newly generated files even though they were created from a different space. I hope it works after merging.

andipaetzold
andipaetzold previously approved these changes Oct 7, 2024
@denkristoffer denkristoffer merged commit 6bfed39 into main Oct 7, 2024
4 checks passed
@denkristoffer denkristoffer deleted the draft-mode branch October 7, 2024 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants