Compare commits
No commits in common. "c53ca6440c1620b6426ad73b541d98a7c1662101" and "d96b78a7e5616f017611f78bd9e0e7780b04d3e8" have entirely different histories.
c53ca6440c
...
d96b78a7e5
@ -37,18 +37,12 @@ interface DirListProps {
|
||||
}
|
||||
const natsortCompare = natsort();
|
||||
|
||||
function toSorted<T>(arr: T[], compareFn: (a:T,b:T) => number): T[]{
|
||||
const ret = Array.from(arr);
|
||||
ret.sort(compareFn);
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function DirList(props: DirListProps) {
|
||||
const data = props;
|
||||
const [files, setFiles] = useState(
|
||||
toSorted(data.files,(
|
||||
data.files.toSorted(
|
||||
(a,b)=> natsortCompare(a.name,b.name)
|
||||
))
|
||||
)
|
||||
);
|
||||
|
||||
return (
|
||||
|
@ -179,6 +179,7 @@ export default function DirLists(props: PageProps<DirOrFileProps>) {
|
||||
cover = searchFiles(data.files, (f) => isImageFile(f.name));
|
||||
index = searchFiles(data.files, (f) => f.name === "index.html");
|
||||
const contentFilenameCandidate = [
|
||||
"SUMMARY.md",
|
||||
"README.md",
|
||||
"readme.md",
|
||||
"README.txt",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Head, asset } from "$fresh/runtime.ts";
|
||||
import { Head } from "$fresh/runtime.ts";
|
||||
import { HandlerContext, Handlers, PageProps, Status } from "$fresh/server.ts";
|
||||
import DocSearch from "../../islands/DocSearch.tsx";
|
||||
import { Doc } from "../../src/collect.ts";
|
||||
@ -24,7 +24,6 @@ export default function Docs(props: PageProps<{ docs: Doc[] }>) {
|
||||
<>
|
||||
<Head>
|
||||
<title>Simple file server - Doc</title>
|
||||
<link rel="stylesheet" href={asset("/base.css")} />
|
||||
</Head>
|
||||
<div class="p-4 mx-auto max-w-screen-md">
|
||||
<DocSearch docs={docs}></DocSearch>
|
||||
|
@ -24,13 +24,6 @@ export interface DocCollectorOptions {
|
||||
dropContent?: boolean;
|
||||
}
|
||||
|
||||
function isDESCFile(filename: string): boolean {
|
||||
const filenameUpperCase = filename.toUpperCase();
|
||||
return (filenameUpperCase === "README.MD" ||
|
||||
filenameUpperCase === "DESCRIPTION.MD")
|
||||
}
|
||||
|
||||
|
||||
export class DocCollector {
|
||||
private doc_map: Map<string, Doc>;
|
||||
private options: DocCollectorOptions;
|
||||
@ -66,15 +59,12 @@ export class DocCollector {
|
||||
fileList.push(entry);
|
||||
}
|
||||
|
||||
const entryName = fileList.find(x => {
|
||||
return isDESCFile(x.name) && x.isFile
|
||||
}
|
||||
if (fileList.some((entry) => entry.name === "SUMMARY.md")) {
|
||||
const { content, metadata } = await readMarkdownDoc(
|
||||
join(path, "SUMMARY.md"),
|
||||
);
|
||||
if (entryName) {
|
||||
const readmePath = join(path, entryName.name);
|
||||
const { content, metadata } = await readMarkdownDoc(readmePath);
|
||||
this.setDoc({
|
||||
path: readmePath,
|
||||
path: join(path, "SUMMARY.md"),
|
||||
content: content,
|
||||
attributes: metadata,
|
||||
});
|
||||
@ -162,7 +152,7 @@ export class DocCollector {
|
||||
for (const path of event.paths) {
|
||||
const relpath = relative(Deno.cwd(), path);
|
||||
const filename = basename(relpath);
|
||||
if (isDESCFile(filename)) {
|
||||
if (filename === "SUMMARY.md") {
|
||||
if (event.kind === "remove") {
|
||||
this.doc_map.delete(relpath);
|
||||
await onRemove(relpath);
|
||||
|
Loading…
Reference in New Issue
Block a user