@@ -2,60 +2,84 @@ import type { ReactNode } from 'react';
22import { useState , useEffect , useCallback } from 'react' ;
33import clsx from 'clsx' ;
44import Heading from '@theme/Heading' ;
5+ import useBaseUrl from '@docusaurus/useBaseUrl' ;
56import styles from './styles.module.css' ;
67
78type Project = {
89 title : string ;
910 description : string ;
10- image : string ;
11+ imagePath : string ;
1112 link : string ;
1213} ;
1314
1415const projects : Project [ ] = [
1516 {
1617 title : 'CodeMirror LaTeX Language' ,
1718 description : 'Syntax highlighting and language support for LaTeX in CodeMirror 6' ,
18- image : require ( '@site/static/ img/codemirror-lang-latex.png') ,
19+ imagePath : '/ img/codemirror-lang-latex.png',
1920 link : 'https://texlyre.github.io/codemirror-lang-latex/' ,
2021 } ,
2122 {
2223 title : 'CodeMirror BibTeX Language' ,
2324 description : 'Syntax highlighting and language support for BibTeX in CodeMirror 6' ,
24- image : require ( '@site/static/ img/codemirror-lang-bib.png') ,
25+ imagePath : '/ img/codemirror-lang-bib.png',
2526 link : 'https://texlyre.github.io/codemirror-lang-bib/' ,
2627 } ,
2728 {
2829 title : 'WASM LaTeX Tools' ,
2930 description : 'WebAssembly-powered LaTeX utilities for browser-based compilation' ,
30- image : require ( '@site/static/ img/wasm-latex-tools.png') ,
31+ imagePath : '/ img/wasm-latex-tools.png',
3132 link : 'https://texlyre.github.io/wasm-latex-tools/' ,
3233 } ,
3334 {
3435 title : 'CodeMirror LaTeX Visual' ,
3536 description : 'Visual editing enhancements for LaTeX in CodeMirror' ,
36- image : require ( '@site/static/ img/codemirror-latex-visual.png') ,
37+ imagePath : '/ img/codemirror-latex-visual.png',
3738 link : 'https://texlyre.github.io/codemirror-latex-visual/' ,
3839 } ,
3940 {
4041 title : 'Vector PDF Converter' ,
4142 description : 'Convert between vector PDF formats in the browser' ,
42- image : require ( '@site/static/ img/vector-pdf-converter.png') ,
43+ imagePath : '/ img/vector-pdf-converter.png',
4344 link : 'https://texlyre.github.io/vector-pdf-converter/' ,
4445 } ,
4546 {
4647 title : 'FilePizza Client' ,
4748 description : 'Peer-to-peer file transfer directly in your browser' ,
48- image : require ( '@site/static/ img/filepizza-client.png') ,
49+ imagePath : '/ img/filepizza-client.png',
4950 link : 'https://texlyre.github.io/filepizza-client/' ,
5051 } ,
5152 {
5253 title : 'TeXlyre Templates' ,
5354 description : 'Collection of LaTeX and Typst templates for various use cases' ,
54- image : require ( '@site/static/ img/texlyre-templates.png') ,
55+ imagePath : '/ img/texlyre-templates.png',
5556 link : 'https://texlyre.github.io/texlyre-templates/' ,
5657 } ,
5758] ;
5859
60+ function ProjectSlide ( { project } : { project : Project } ) {
61+ const imageUrl = useBaseUrl ( project . imagePath ) ;
62+
63+ return (
64+ < a
65+ href = { project . link }
66+ target = "_blank"
67+ rel = "noopener noreferrer"
68+ className = { styles . slideLink }
69+ >
70+ < img
71+ src = { imageUrl }
72+ alt = { project . title }
73+ className = { styles . slideImage }
74+ />
75+ < div className = { styles . slideInfo } >
76+ < h3 className = { styles . slideTitle } > { project . title } </ h3 >
77+ < p className = { styles . slideDescription } > { project . description } </ p >
78+ </ div >
79+ </ a >
80+ ) ;
81+ }
82+
5983export default function ProjectCarousel ( ) : ReactNode {
6084 const [ currentIndex , setCurrentIndex ] = useState ( 0 ) ;
6185 const [ isAutoPlaying , setIsAutoPlaying ] = useState ( true ) ;
@@ -119,22 +143,7 @@ export default function ProjectCarousel(): ReactNode {
119143 [ styles . slideActive ] : index === currentIndex ,
120144 } ) }
121145 >
122- < a
123- href = { project . link }
124- target = "_blank"
125- rel = "noopener noreferrer"
126- className = { styles . slideLink }
127- >
128- < img
129- src = { project . image }
130- alt = { project . title }
131- className = { styles . slideImage }
132- />
133- < div className = { styles . slideInfo } >
134- < h3 className = { styles . slideTitle } > { project . title } </ h3 >
135- < p className = { styles . slideDescription } > { project . description } </ p >
136- </ div >
137- </ a >
146+ < ProjectSlide project = { project } />
138147 </ div >
139148 ) ) }
140149 </ div >
0 commit comments