-
-
Notifications
You must be signed in to change notification settings - Fork 11
956-feat: Implement 2 separate routes RU/EN #967
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
b07940f
refactor: remove unused data
Quiddlee 787a4bd
fix: 956 - link tests
Quiddlee d953c3b
fix: 956 - typescript errors
Quiddlee 5700765
chore: 956 - resolve merge conflicts
Quiddlee cfef091
feat: 956 - improve lang switcher design
Quiddlee 90bd5b5
chore: 956 - resolve merge conflicts
Quiddlee ff258a4
fix: 956 - mobile tap highlight
Quiddlee 01381fa
fix: 956 - playwright tests
Quiddlee 23ea9b1
chore: 956 - resolve merge conflicts
Quiddlee 2965506
chore: 956 - merge main
Quiddlee 9d573f4
chore: 956 - fix ci env variables
Quiddlee 8c5eb32
refactor: 956 - move lang switcher next to close button
Quiddlee 909cbe0
feat: 956 - translate menu items
Quiddlee 029909e
feat: 956 - translate desktop menu content
Quiddlee f5f008f
feat: 956 - translate mobile menu
Quiddlee bef44dc
feat: 956 - localize all dates
Quiddlee ec6d2fc
fix: 956 - scss directives
Quiddlee 7163e2a
fix: 956 - review fixes
Quiddlee f589da9
feat: 956 - add locale resolver
Quiddlee 3cb9096
fix: 956 - constant typo
Quiddlee b078301
fix: 956 - tests mocks
Quiddlee 544def9
fix: 956 - anchor links
Quiddlee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { PAGE_TYPE, pageStore, resolvePageLocale } from '@/entities/page'; | ||
| import { generateLangParams } from '@/entities/page/helpers/generate-lang-params'; | ||
| import { PagePropsOg } from '@/entities/page/types'; | ||
| import { createPageTree } from '@/shared/og/view/pages-tree/generate-pages-tree'; | ||
|
|
||
| export { DYNAMIC as dynamic } from '@/shared/constants'; | ||
|
|
||
| export const generateStaticParams = generateLangParams; | ||
|
|
||
| export async function GET(_request: Request, { params }: PagePropsOg) { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { seoOgImageTitle: title, seoOgImageDescription: description } = | ||
| await pageStore.loadPage(PAGE_TYPE.COMMUNITY, locale); | ||
|
|
||
| return createPageTree({ | ||
| title, | ||
| description, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { Metadata } from 'next'; | ||
|
|
||
| import { resolvePageLocale } from '@/entities/page'; | ||
| import { PAGE_TYPE } from '@/entities/page/constants'; | ||
| import { pageStore } from '@/entities/page/model/store'; | ||
| import { PageProps } from '@/entities/page/types'; | ||
| import { communityMetadata } from '@/metadata/community'; | ||
| import { generatePageMetadata } from '@/shared/helpers/generate-page-metadata'; | ||
| import Community from '@/views/community'; | ||
|
|
||
| export async function generateMetadata({ params }: PageProps): Promise<Metadata> { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { title, seoDescription: description, seoKeywords: keywords } = | ||
| await pageStore.loadPage(PAGE_TYPE.COMMUNITY, locale); | ||
|
|
||
| const { canonical, robots } = communityMetadata; | ||
|
|
||
| const metadata = generatePageMetadata({ | ||
| title, | ||
| description, | ||
| imagePath: `/${lang}/community/og.png`, | ||
| keywords, | ||
| alternates: { canonical }, | ||
| robots, | ||
| }); | ||
|
|
||
| return metadata; | ||
| } | ||
|
|
||
| export default async function CommunityRoute({ params }: PageProps) { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { sections } = await pageStore.loadPage(PAGE_TYPE.COMMUNITY, locale); | ||
|
|
||
| return <Community sections={sections} />; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import { courseStore } from '@/entities/course'; | ||
| import { resolvePageLocale } from '@/entities/page'; | ||
| import { PAGE_TYPE } from '@/entities/page/constants'; | ||
| import { pageStore } from '@/entities/page/model/store'; | ||
| import { PageProps } from '@/entities/page/types'; | ||
| import { fetchAndConvertToDataUri } from '@/shared/og/utils/fetch-and-convert-to-data-uri'; | ||
| import { loadImageAsDataUri } from '@/shared/og/utils/load-image-as-data-uri'; | ||
| import { createCourseTree } from '@/shared/og/view/courses-tree/generate-courses-tree'; | ||
|
|
||
| export const preferredRegion = 'auto'; | ||
| const fallbackPath = 'src/shared/assets/svg/rss-logo.svg'; | ||
| const logoFallbackSize = 250; | ||
|
|
||
Quiddlee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| export async function generateStaticParams({ params: { lang } }: { params: Awaited<PageProps['params']> }) { | ||
| const locale = resolvePageLocale(lang); | ||
| const pages = await pageStore.loadPagesMetadata(PAGE_TYPE.COURSE, locale); | ||
|
|
||
| return pages.map(({ slug }) => ({ | ||
| slug, | ||
| lang: 'ru', | ||
| })); | ||
| } | ||
Quiddlee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export async function GET(_request: Request, { params }: { params: PageProps['params'] }) { | ||
| const { slug, lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
|
|
||
| const { title: courseName, courseId } = await pageStore.loadPage(PAGE_TYPE.COURSE, locale, slug); | ||
|
|
||
| const course = await courseStore.loadCourse(courseId); | ||
|
|
||
| if (!course) { | ||
| throw new Error(`Course metadata not found for id="${courseId}"`); | ||
| } | ||
Quiddlee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| const logoWidth = course.iconSrc.width ?? logoFallbackSize; | ||
| const logoHeight = course.iconSrc.height ?? logoFallbackSize; | ||
| const logoCache = new Map<string, string>(); | ||
|
|
||
| let logoDataUri: string | undefined = logoCache.get(course.iconSrc.src); | ||
|
|
||
| try { | ||
| logoDataUri = await fetchAndConvertToDataUri(course.iconSrc.src); | ||
| logoCache.set(course.iconSrc.src, logoDataUri); | ||
| } catch (err) { | ||
| console.warn('Failed to load remote logo, using fallback', err); | ||
| logoDataUri = await loadImageAsDataUri(fallbackPath); | ||
| } | ||
|
|
||
| return createCourseTree({ | ||
| name: courseName, | ||
| logo: { | ||
| src: logoDataUri, | ||
| width: logoWidth, | ||
| height: logoHeight, | ||
| }, | ||
| startDate: course.startDate, | ||
| }); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import { Metadata } from 'next'; | ||
| import path from 'path'; | ||
|
|
||
Quiddlee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import { resolvePageLocale } from '@/entities/page'; | ||
| import { PAGE_TYPE } from '@/entities/page/constants'; | ||
| import { pageStore } from '@/entities/page/model/store'; | ||
| import { PageProps } from '@/entities/page/types'; | ||
| import { generatePageMetadata } from '@/shared/helpers/generate-page-metadata'; | ||
| import { Course } from '@/views/course'; | ||
|
|
||
| export async function generateMetadata({ params }: PageProps): Promise<Metadata> { | ||
| const { slug, lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
|
|
||
| const { | ||
| courseUrl, | ||
| title: courseName, | ||
| seoDescription: description, | ||
| seoKeywords: keywords, | ||
| } = await pageStore.loadPage(PAGE_TYPE.COURSE, locale, slug); | ||
|
|
||
| const title = `${courseName} Β· The Rolling Scopes School`; | ||
| const robots = { | ||
| index: true, | ||
| follow: true, | ||
| }; | ||
|
|
||
| return generatePageMetadata({ | ||
| title, | ||
| description, | ||
| imagePath: path.join(lang, 'courses', slug, 'og.png'), | ||
| keywords, | ||
| alternates: { canonical: courseUrl }, | ||
| robots, | ||
| }); | ||
| } | ||
|
|
||
| export async function generateStaticParams({ params: { lang } }: { params: Awaited<PageProps['params']> }) { | ||
| const locale = resolvePageLocale(lang); | ||
|
|
||
| return await pageStore.loadPagesMetadata(PAGE_TYPE.COURSE, locale); | ||
| } | ||
Quiddlee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export default async function CourseRoute({ params }: PageProps) { | ||
| const { slug, lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { sections, courseId } = await pageStore.loadPage(PAGE_TYPE.COURSE, locale, slug); | ||
|
|
||
| return <Course id={courseId} sections={sections} locale={locale} />; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { PAGE_TYPE, pageStore, resolvePageLocale } from '@/entities/page'; | ||
| import { generateLangParams } from '@/entities/page/helpers/generate-lang-params'; | ||
| import { PagePropsOg } from '@/entities/page/types'; | ||
| import { createPageTree } from '@/shared/og/view/pages-tree/generate-pages-tree'; | ||
|
|
||
| export { DYNAMIC as dynamic } from '@/shared/constants'; | ||
|
|
||
| export const generateStaticParams = generateLangParams; | ||
|
|
||
| export async function GET(_request: Request, { params }: PagePropsOg) { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { seoOgImageTitle: title, seoOgImageDescription: description } = | ||
| await pageStore.loadPage(PAGE_TYPE.COURSES, locale); | ||
|
|
||
| return createPageTree({ | ||
| title, | ||
| description, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { Metadata } from 'next'; | ||
|
|
||
| import { resolvePageLocale } from '@/entities/page'; | ||
| import { PAGE_TYPE } from '@/entities/page/constants'; | ||
| import { pageStore } from '@/entities/page/model/store'; | ||
| import { PageProps } from '@/entities/page/types'; | ||
| import { coursesMetadata } from '@/metadata/courses'; | ||
| import { OG_SITE_NAME } from '@/shared/constants'; | ||
| import { generatePageMetadata } from '@/shared/helpers/generate-page-metadata'; | ||
| import { Courses } from '@/views/courses'; | ||
|
|
||
| export async function generateMetadata({ params }: PageProps): Promise<Metadata> { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { | ||
| title: coursesTitle, | ||
| seoDescription: description, | ||
| seoKeywords: keywords, | ||
| } = await pageStore.loadPage(PAGE_TYPE.COURSES, locale); | ||
| const title = `${coursesTitle} Β· ${OG_SITE_NAME}`; | ||
| const { canonical, robots } = coursesMetadata; | ||
|
|
||
| const metadata = generatePageMetadata({ | ||
| title, | ||
| description, | ||
| imagePath: `/${lang}/courses/og.png`, | ||
| keywords, | ||
| alternates: { canonical }, | ||
| robots, | ||
| }); | ||
|
|
||
| return metadata; | ||
| } | ||
|
|
||
| export default async function CoursesRoute({ params }: PageProps) { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { sections } = await pageStore.loadPage(PAGE_TYPE.COURSES, locale); | ||
|
|
||
| return <Courses sections={sections} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import { PropsWithChildren } from 'react'; | ||
|
|
||
| import { DocsLayout } from '@/app/docs/components/docs-layout/docs-layout'; | ||
| import { fetchMenu } from '@/app/docs/utils/fetch-menu'; | ||
| import { PageProps } from '@/entities/page/types'; | ||
| import { Language } from '@/shared/types'; | ||
|
|
||
| export default async function RootLayout({ children, params }: { params: Promise<Pick<Awaited<PageProps['params']>, 'lang'>> } & PropsWithChildren) { | ||
| const { lang } = (await params) as { lang: Language }; | ||
| const menu = await fetchMenu(lang); | ||
|
|
||
| return ( | ||
| <DocsLayout menu={menu} lang={lang}> | ||
| {children} | ||
| </DocsLayout> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { PAGE_TYPE, pageStore, resolvePageLocale } from '@/entities/page'; | ||
| import { generateLangParams } from '@/entities/page/helpers/generate-lang-params'; | ||
| import { PagePropsOg } from '@/entities/page/types'; | ||
| import { createPageTree } from '@/shared/og/view/pages-tree/generate-pages-tree'; | ||
|
|
||
| export { DYNAMIC as dynamic } from '@/shared/constants'; | ||
|
|
||
| export const generateStaticParams = generateLangParams; | ||
|
|
||
| export async function GET(_request: Request, { params }: PagePropsOg) { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { seoOgImageTitle: title, seoOgImageDescription: description } = | ||
| await pageStore.loadPage(PAGE_TYPE.DOCS, locale); | ||
|
|
||
| return createPageTree({ | ||
| title, | ||
| description, | ||
| }); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| import { DocsContent } from '@/app/docs/components/docs-content/docs-content'; | ||
| import { fetchMarkdownContent } from '@/app/docs/utils/fetch-markdown-content'; | ||
| import { PAGE_TYPE, pageStore, resolvePageLocale } from '@/entities/page'; | ||
| import { PageProps } from '@/entities/page/types'; | ||
| import { docsLangMetadata } from '@/metadata/docs'; | ||
| import { generatePageMetadata } from '@/shared/helpers/generate-page-metadata'; | ||
|
|
||
| export async function generateMetadata({ params }: PageProps) { | ||
| const { lang } = await params; | ||
| const locale = resolvePageLocale(lang); | ||
| const { title, seoDescription: description, seoKeywords: keywords } = | ||
| await pageStore.loadPage(PAGE_TYPE.DOCS, locale); | ||
| const { canonical, robots } = docsLangMetadata; | ||
|
|
||
| const metadata = generatePageMetadata({ | ||
| title, | ||
| description, | ||
| imagePath: `/${lang}/docs/og.png`, | ||
| keywords, | ||
| alternates: { canonical }, | ||
| robots, | ||
| }); | ||
|
|
||
| return metadata; | ||
| } | ||
|
|
||
| export default async function DocsIndex({ params }: PageProps) { | ||
| const { lang } = await params; | ||
|
|
||
| const indexContent = await fetchMarkdownContent(lang); | ||
|
|
||
| return <DocsContent markdownContent={indexContent} lang={lang} />; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| import { PropsWithChildren } from 'react'; | ||
|
|
||
| import { generateLangParams } from '@/entities/page/helpers/generate-lang-params'; | ||
|
|
||
| export const generateStaticParams = generateLangParams; | ||
|
|
||
| export default function Layout({ children }: PropsWithChildren) { | ||
| return children; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.