You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// src/context/ShowcaseContext.tsximportReact,{createContext,useContext,useState}from'react';import{Project,TagType}from'../types/showcase';interfaceShowcaseContextType{searchQuery: string;setSearchQuery: (query: string)=>void;selectedTags: TagType[];toggleTag: (tag: TagType)=>void;filteredProjects: Project[];}constShowcaseContext=createContext<ShowcaseContextType|undefined>(undefined);exportconstShowcaseProvider: React.FC<{children: React.ReactNode}>=({children})=>{// Implementation};exportconstuseShowcaseContext=(): ShowcaseContextType=>{constcontext=useContext(ShowcaseContext);if(context===undefined){thrownewError('useShowcaseContext must be used within a ShowcaseProvider');}returncontext;};
4. API Type Safety
If the site communicates with external APIs, define types for request/response data
Consider using TypeScript utility types like Partial<T>, Pick<T>, and Omit<T>
Recommendations for i18n Implementation
1. Multi-Language Support
Extend Docusaurus i18n configuration to support multiple languages:
Replace hardcoded strings with translation functions:
// BeforefunctionShowcaseHeader(){return(<sectionclassName="margin-top--lg margin-bottom--lg text--center"><Headingas="h1">{TITLE}</Heading><p>{DESCRIPTION}</p></section>);}// Afterimport{translate}from'@docusaurus/Translate';functionShowcaseHeader(){return(<sectionclassName="margin-top--lg margin-bottom--lg text--center"><Headingas="h1">{translate({id: 'showcase.header.title',message: 'THP-Lab projects showcase',})}</Heading><p>{translate({id: 'showcase.header.description',message: 'List of projects people from THP-lab are working on',})}</p></section>);}
3. Create Translation JSON Files
Run npm run write-translations to generate translation files in the i18n folder
Translate content by editing the generated JSON files for each locale
4. Language Switcher
Add a language dropdown in the navbar:
// In docusaurus.config.jsnavbar: {items: [// ...existing items{type: 'localeDropdown',position: 'right',},],},
5. Localized Route Structure
Create localized versions of documentation in /i18n/<locale>/docusaurus-plugin-content-docs/...
Use the Docusaurus CLI to manage translations: npm run start -- --locale fr