Skip to content

Commit

Permalink
Rename appendHtmlSuffix to cleanUrls
Browse files Browse the repository at this point in the history
  • Loading branch information
ektrah committed May 18, 2023
1 parent 4d37e0b commit c28bd06
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
3 changes: 2 additions & 1 deletion explorer/rdfconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"favicon.ico": "favicon.ico",
"robots.txt": "robots.txt"
},
"outDir": "public"
"outDir": "public",
"cleanUrls": true
}
}
10 changes: 5 additions & 5 deletions packages/cli/src/commands/make-site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class Website implements RenderContext {
readonly outputs: Record<string, string> = {};
readonly rootClasses: ReadonlySet<string> | null;

constructor(readonly title: string, readonly baseURL: string, readonly appendHtmlSuffix: boolean, rootClasses?: Iterable<string>) {
constructor(readonly title: string, readonly baseURL: string, readonly cleanUrls: boolean, rootClasses?: Iterable<string>) {
this.graph = Graph.from(this.dataset);
this.schema = Schema.decompile(this.dataset, this.graph);
this.prefixes = new PrefixTable(this.namespaces);
Expand Down Expand Up @@ -112,7 +112,7 @@ class Website implements RenderContext {
for (const term of terms) {
const prefixedName = this.prefixes.lookup(term.value);
if (prefixedName) {
this.outputs[term.value] = path.join(prefixedName.prefixLabel, prefixedName.localName) + (this.appendHtmlSuffix ? ".html" : "");
this.outputs[term.value] = path.join(prefixedName.prefixLabel, prefixedName.localName) + (this.cleanUrls ? "" : ".html");
}
else {
const string = term.value;
Expand All @@ -122,7 +122,7 @@ class Website implements RenderContext {
hash = ((hash << 5) - hash) + char;
hash = hash & hash;
}
this.outputs[term.value] = (hash & ((1 << 31) - 1)).toString().padStart(10, "0") + (this.appendHtmlSuffix ? ".html" : "");
this.outputs[term.value] = (hash & ((1 << 31) - 1)).toString().padStart(10, "0") + (this.cleanUrls ? "" : ".html");
}
}
}
Expand Down Expand Up @@ -222,7 +222,7 @@ export default function main(options: Options): void {
const icons = project.json.siteOptions?.icons || [];
const assets = project.json.siteOptions?.assets || {};

const context = new Website(project.json.siteOptions?.title || DEFAULT_TITLE, new URL(options.base || project.json.siteOptions?.baseURL || DEFAULT_BASE, DEFAULT_BASE).href, !!project.json.siteOptions?.appendHtmlSuffix, project.json.siteOptions?.roots);
const context = new Website(project.json.siteOptions?.title || DEFAULT_TITLE, new URL(options.base || project.json.siteOptions?.baseURL || DEFAULT_BASE, DEFAULT_BASE).href, !!project.json.siteOptions?.cleanUrls, project.json.siteOptions?.roots);
const site = new Workspace(project.package.resolve(options.output || project.json.siteOptions?.outDir || "public"));

context.beforecompile();
Expand Down Expand Up @@ -263,6 +263,6 @@ export default function main(options: Options): void {
site.write(ERROR_FILE_NAME, Buffer.from("<!DOCTYPE html>\n" + renderHTML(render404(context, links, scripts, navigation))));

for (const iri in context.outputs) {
site.write(context.outputs[iri] + (context.appendHtmlSuffix ? "" : ".html"), Buffer.from("<!DOCTYPE html>\n" + renderHTML(renderPage(iri, context, links, scripts, navigation))));
site.write(context.outputs[iri] + (context.cleanUrls ? ".html" : ""), Buffer.from(" < !DOCTYPE html >\n" + renderHTML(renderPage(iri, context, links, scripts, navigation))));
}
}
4 changes: 2 additions & 2 deletions packages/cli/src/model/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface SiteConfig {
baseURL?: string;
outDir?: string;
roots?: Array<string>;
appendHtmlSuffix?: boolean;
cleanUrls?: boolean;
}

export namespace SiteConfig {
Expand All @@ -45,7 +45,7 @@ export namespace SiteConfig {
&& (Is.undefined(candidate.baseURL) || Is.string(candidate.baseURL))
&& (Is.undefined(candidate.outDir) || Is.string(candidate.outDir))
&& (Is.undefined(candidate.roots) || Is.typedArray(candidate.roots, Is.string))
&& (Is.undefined(candidate.appendHtmlSuffix) || Is.boolean(candidate.appendHtmlSuffix));
&& (Is.undefined(candidate.cleanUrls) || Is.boolean(candidate.cleanUrls));
}
}

Expand Down

0 comments on commit c28bd06

Please sign in to comment.