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",
"rules": {
"semi": ["warn", "always"],
"semi": ["warn", "always", { "omitLastInOneLineBlock": true }],
"quotes": ["warn", "double"],
"eqeqeq": "error"
}

View File

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

View File

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

View File

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