simple-fs-server/islands/FileViewer.tsx

19 lines
541 B
TypeScript
Raw Normal View History

2023-01-05 18:18:07 +09:00
import RenderView from "./ContentRenderer.tsx";
import UpList from "./UpList.tsx";
import { extname } from "path/mod.ts";
2023-01-06 18:17:36 +09:00
import { encodePath } from "../util/util.ts";
2023-01-05 18:18:07 +09:00
export default function FileViewer(props: { path: string }) {
2023-01-06 18:24:27 +09:00
const { path } = props;
2023-01-06 22:17:45 +09:00
const srcPath = `/dir/${encodePath(path)}`;
2023-01-06 18:24:27 +09:00
return (
<div class="p-4 mx-auto max-w-screen-md">
<UpList path={path} />
<a href={srcPath}>Direct link</a>
<div class="p-2 border-2 rounded-lg">
<RenderView src={srcPath} />
</div>
</div>
);
}