Skip to content

Commit e64f3e9

Browse files
committed
Preview - improve format detection
Format may be a string or a complex object. Look at both. fixes #8662
1 parent 078cac0 commit e64f3e9

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/project/serve/serve.ts

+22-1
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,31 @@ export async function serveProject(
140140
throw new Error(`${target} is not a project`);
141141
}
142142

143+
format?: string | Record<string, unknown> | unknown,
144+
) => {
145+
if (!format) {
146+
return false;
147+
}
148+
149+
if (typeof format === "string") {
150+
return format === "docusaurus-md";
151+
} else if (typeof format === "object") {
152+
const formats = Object.keys(format);
153+
if (formats.length > 0) {
154+
const firstFormat = Object.keys(format)[0];
155+
return firstFormat === "docusaurus-md";
156+
} else {
157+
return false;
158+
}
159+
} else {
160+
return false;
161+
}
162+
};
163+
143164
// Default project types can't be served
144165
const projType = projectType(project?.config?.project?.[kProjectType]);
145166
if (
146-
projType.type === "default" && project?.config?.format !== "docusaurus-md"
167+
projType.type === "default" && !isDocusaurusMd(project?.config?.format)
147168
) {
148169
const hasIndex = project.files.input.some((file) => {
149170
let relPath = file;

0 commit comments

Comments
 (0)