Skip to content

Commit

Permalink
fix(intlayer-core): fix array intlayer
Browse files Browse the repository at this point in the history
  • Loading branch information
aymericzip committed Jun 21, 2024
1 parent 9115caa commit fb3794e
Show file tree
Hide file tree
Showing 16 changed files with 541 additions and 197 deletions.
13 changes: 13 additions & 0 deletions apps/website/src/Routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
export enum PagesRoutes {
Home = '/',
Demo = '/demo',
Doc = '/doc',
Doc_GetStarted = '/doc/get_started',
Doc_Configuration = '/doc/configuration',
Doc_Interest = '/doc/interest-of-intlayer',
Doc_IntlayerEditor = '/doc/intlayer-editor',
Doc_ContentDeclaration = '/doc/content-declaration',
Doc_ContentDeclaration_Translation = '/doc/content-declaration/translation',
Doc_ContentDeclaration_Enumeration = '/doc/content-declaration/enumeration',
Doc_ContentDeclaration_FunctionFetching = '/doc/content-declaration/function-fetching',
Doc_ContentDeclaration_NestedId = '/doc/content-declaration/nested-id',
Doc_Environment_NextJS = '/doc/environment/intlayer-with-nextjs',
Doc_Environment_CRA = '/doc/environment/intlayer-with-create-react-app',
Doc_Environment_ViteAndReact = '/doc/environment/intlayer-with-vite-and-react',

LogIn = '/auth/sign-in',
SignUp = '/auth/sign-up',
Expand Down
50 changes: 50 additions & 0 deletions apps/website/src/app/[locale]/doc/metadata.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { type IConfigLocales, getTranslationContent } from 'intlayer';
import type { Metadata } from 'next';
import type { LocalParams } from 'next-intlayer';

export const generateMetadata = ({
params: { locale },
}: LocalParams): Metadata => {
const t = <T>(content: IConfigLocales<T>) =>
getTranslationContent(content, locale);

return {
title: t<string>({
en: 'Intlayer | Documentation',
fr: 'Intlayer | Documentation',
es: 'Intlayer | Documentación',
}),
description: t<string>({
en: 'Transform your website into a multilingual application in 2 minutes. Discover the full range of Intlayer features through this online documentation.',
fr: "Transformez votre site web en application multilingue en 2 minutes. Découvrez l'ensemble des fonctionnalités de Intlayer à travers cette documentation en ligne.",
es: 'Transforme su sitio web en una aplicación multilingüe en 2 minutos. Descubra todas las funcionalidades de Intlayer a través de esta documentación en línea.',
}),
generator: undefined,
keywords: t<string[]>({
en: [
'Documentation',
'Internationalization',
'Intlayer',
'Next.js',
'JavaScript',
'React',
],
fr: [
'Documentation',
'Internationalisation',
'Intlayer',
'Next.js',
'JavaScript',
'React',
],
es: [
'Documentation',
'Internacionalización',
'Intlayer',
'Next.js',
'JavaScript',
'React',
],
}),
};
};
16 changes: 16 additions & 0 deletions apps/website/src/app/[locale]/doc/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { DocPage } from '@components/DocPage';
import { DocPageLayout } from '@components/DocPage/DocPageLayout';
import { PageLayout } from '@layouts/PageLayout';
import type { NextPageIntlayer } from 'next-intlayer';
import { generateMetadata } from './metadata';

export { generateMetadata };

const Page: NextPageIntlayer = ({ params: { locale } }) => (
<PageLayout locale={locale} editorEnabled={false}>
<DocPageLayout>
<DocPage />
</DocPageLayout>
</PageLayout>
);
export default Page;
89 changes: 89 additions & 0 deletions apps/website/src/components/DocPage/DocPageLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
'use client';

import { Container } from '@intlayer/design-system';
import { cn } from '@utils/cn';
import { usePathname, useRouter } from 'next/navigation';
import { useIntlayer } from 'next-intlayer';
import type { FC, ReactNode } from 'react';

type DocPageLayoutProps = {
children?: ReactNode;
};

export const DocPageLayout: FC<DocPageLayoutProps> = ({ children }) => {
const { navbar } = useIntlayer('doc-page');
const pathname = usePathname();
const router = useRouter();

return (
<div className="flex size-full border-b-[0.5px]">
<Container
className="h-full flex-none"
roundedSize="none"
transparency="sm"
>
<nav className="flex flex-col gap-5 px-6 py-10">
{navbar.map((section1) => (
<div key={section1.title.value}>
<button
className={cn([
'text-neutral hover:text-text dark:hover:text-text-dark cursor-pointer font-semibold transition-colors dark:text-neutral-200',
section1.url?.value === pathname,
])}
onClick={() =>
typeof section1.url?.value === 'string' &&
router.push(section1.url.value)
}
>
{section1.title}
</button>

{section1.subSections && section1.subSections.length > 0 && (
<div className="border-neutral dark:border-neutral-dark mt-4 flex flex-col gap-4 border-l-[0.5px] p-1">
{section1.subSections.map((section2) => (
<div key={section2.title.value}>
<button
className={cn([
'text-neutral hover:text-text dark:hover:text-text-dark cursor-pointer p-2 text-sm transition-colors dark:text-neutral-200',
section2.url?.value === pathname,
])}
onClick={() =>
typeof section2.url.value === 'string' &&
router.push(section2.url.value)
}
>
{section2.title}
</button>

{section2.subSections &&
section2.subSections.length > 0 && (
<div className="text-neutral hover:text-text dark:hover:text-text-dark border-neutral dark:border-neutral-dark flex flex-col items-start gap-2 border-l-[0.5px] p-1 transition-colors">
{section2.subSections.map((section3) => (
<button
className={cn([
'text-neutral hover:text-text dark:hover:text-text-dark cursor-pointer p-2 text-xs transition-colors dark:text-neutral-200',
section3.url?.value === pathname,
])}
key={section3.title.value}
onClick={() =>
typeof section3.url.value === 'string' &&
router.push(section3.url.value)
}
>
{section3.title}
</button>
))}
</div>
)}
</div>
))}
</div>
)}
</div>
))}
</nav>
</Container>
<div className="grow">{children}</div>
</div>
);
};
123 changes: 123 additions & 0 deletions apps/website/src/components/DocPage/doc-page.content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import { type DeclarationContent, t } from 'intlayer';
import { PagesRoutes } from '@/Routes';

type NavLink = {
title: string;
subSections?: NavLink[];
url?: string;
};

type NavbarContent = {
navbar: NavLink[];
};

export const navbarContent: DeclarationContent<NavbarContent> = {
id: 'doc-page',
navbar: [
{
title: t({ fr: 'Commencez', en: 'Get started', es: 'Comenzar' }),
url: PagesRoutes.Doc_GetStarted,
subSections: [],
},
{
title: t({ fr: 'Concept', en: 'Concept', es: 'Concepto' }),
subSections: [
{
title: t({
fr: 'Configuration',
en: 'Configuration',
es: 'Configuración',
}),
url: PagesRoutes.Doc_Configuration,
},
{
title: t({
fr: 'Intérêt de intlayer',
en: 'Interest of intlayer',
es: 'Interés de intlayer',
}),
url: PagesRoutes.Doc_Interest,
},
{
title: t({
fr: 'Éditeur Intlayer',
en: 'Intlayer editor',
es: 'Editor de Intlayer',
}),
url: PagesRoutes.Doc_IntlayerEditor,
},
{
title: t({
fr: 'Déclaration de contenu',
en: 'Content declaration',
es: 'Declaración de contenido',
}),
url: PagesRoutes.Doc_ContentDeclaration,
subSections: [
{
title: t({
fr: 'Traduction',
en: 'Translation',
es: 'Traducción',
}),
url: PagesRoutes.Doc_ContentDeclaration_Translation,
},
{
title: t({
fr: 'Énumération',
en: 'Enumeration',
es: 'Enumeración',
}),
url: PagesRoutes.Doc_ContentDeclaration_Enumeration,
},
{
title: t({
fr: 'Récupération de fonction',
en: 'Function fetching',
es: 'Obtención de función',
}),
url: PagesRoutes.Doc_ContentDeclaration_FunctionFetching,
},
{
title: t({
fr: 'ID imbriqué',
en: 'Nested ID',
es: 'ID anidado',
}),
url: PagesRoutes.Doc_ContentDeclaration_NestedId,
},
],
},
],
},
{
title: t({ fr: 'Environnements', en: 'Environments', es: 'Entornos' }),
subSections: [
{
title: t({
fr: 'Intlayer avec NextJS',
en: 'Intlayer with NextJS',
es: 'Intlayer con NextJS',
}),
url: PagesRoutes.Doc_Environment_NextJS,
},
{
title: t({
fr: 'Intlayer avec React (CRA)',
en: 'Intlayer with React (CRA)',
es: 'Intlayer con React (CRA)',
}),
url: PagesRoutes.Doc_Environment_CRA,
},
{
title: t({
fr: 'Intlayer avec ViteJS+React',
en: 'Intlayer with ViteJS+React',
es: 'Intlayer con ViteJS+React',
}),
url: PagesRoutes.Doc_Environment_ViteAndReact,
},
],
},
],
};
5 changes: 5 additions & 0 deletions apps/website/src/components/DocPage/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { FC } from 'react';

export const DocPage: FC = () => {
return <></>;
};
38 changes: 20 additions & 18 deletions apps/website/src/components/Navbar/navbar.content.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
import type { NavSection } from '@intlayer/design-system';
import { type DeclarationContent, t } from 'intlayer';
import { PagesRoutes } from '@/Routes';

// type SectionsContent = {
// sections: NavSection[];
// bottomSections: NavSection[];
// logo: {
// label: string;
// onClick: () => void;
// };
// profile: {
// label: string;
// };
// login: {
// text: string;
// label: string;
// onClick: () => void;
// };
// };
type SectionsContent = {
sections: Omit<NavSection, 'onClick'>[];
// bottomSections: Omit<NavSection, 'onClick'>[];
logo: {
label: string;
};
};

export const navbarContent: DeclarationContent = {
export const navbarContent: DeclarationContent<SectionsContent> = {
id: 'navbar',
logo: {
label: t({
Expand Down Expand Up @@ -51,11 +43,21 @@ export const navbarContent: DeclarationContent = {
}),
url: PagesRoutes.Demo,
label: t({
en: 'Go to demo page',
en: 'Go to the demo page',
fr: 'Aller à la page de démo',
es: 'Ir a la página de demostración',
}),
},
{
id: 'doc',
title: 'Doc',
url: PagesRoutes.Doc,
label: t({
en: 'Go to the documentation page',
fr: 'Aller à la page de documentation',
es: 'Ir a la página de documentation',
}),
},
],
// bottomSections: {
// logout: {
Expand Down
1 change: 1 addition & 0 deletions packages/@intlayer/chokidar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"glob": "^10.3.12",
"intlayer": "workspace:^",
"node-loader": "^2.0.0",
"quicktype-core": "^23.0.170",
"rimraf": "5.0.5"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit fb3794e

Please sign in to comment.