This commit is contained in:
Daniel Kluge 2022-01-14 17:17:55 +01:00
parent 7ac2a6a663
commit 36b0b16059
4 changed files with 10 additions and 10 deletions

View File

@ -1,7 +1,7 @@
{ {
"extends": "next/core-web-vitals", "extends": "next/core-web-vitals",
"rules": { "rules": {
"semi": ["warn", "always"], "semi": ["warn", "always", { "omitLastInOneLineBlock": true }],
"quotes": ["warn", "double"], "quotes": ["warn", "double"],
"eqeqeq": "error" "eqeqeq": "error"
} }

View File

@ -34,30 +34,30 @@ const ProjectModal: NextPage<ModalInput> = ({ project, visible, setVisible }) =>
} }
}); });
}); });
} else if (project === "") setProjectData(projectEmpty) } else if (project === "") setProjectData(projectEmpty);
}, [project]) }, [project, projectEmpty, projectNotFoundHtml, projectServerErrorHtml]);
useEffect(() => { useEffect(() => {
if (projectData && containerRef.current && projectData !== "") { if (projectData && containerRef.current && projectData !== "") {
containerRef.current.innerHTML = projectData; containerRef.current.innerHTML = projectData;
} }
}, [projectData, visible]) }, [projectData, visible]);
const onEscClose = (e: React.KeyboardEvent) => { const onEscClose = (e: React.KeyboardEvent) => {
if (e.key === "Escape") { if (e.key === "Escape") {
e.preventDefault(); e.preventDefault();
setVisible(false); setVisible(false);
} }
} };
if (!visible) return <></> if (!visible) return <></>;
return <div className={styles.modal} onKeyDown={onEscClose}> return <div className={styles.modal} onKeyDown={onEscClose}>
<div ref={containerRef} className={styles.modalContainer}> <div ref={containerRef} className={styles.modalContainer}>
</div> </div>
</div> </div>;
} };
export default ProjectModal; export default ProjectModal;

View File

@ -19,7 +19,7 @@ export default function handler(req: NextApiRequest, res: NextApiResponse<string
const project = req.query.projectName; const project = req.query.projectName;
try { try {
const path = resolve("./public", "projects", `${project}.adoc`) const path = resolve("./public", "projects", `${project}.adoc`);
const data = readFileSync(path).toString(); const data = readFileSync(path).toString();
console.debug(`[API/get_project]\tRequest for ${project}`); console.debug(`[API/get_project]\tRequest for ${project}`);
res.status(200).send(data); res.status(200).send(data);

View File

@ -19,7 +19,7 @@ const Home: NextPage = () => {
e.preventDefault(); e.preventDefault();
setModalVisible(false); setModalVisible(false);
} }
} };
return (<main onKeyDown={hideModalOnEsc}> return (<main onKeyDown={hideModalOnEsc}>
<Head> <Head>