Skip to content

Commit

Permalink
Added setting so static asset suffix.
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov committed Mar 9, 2024
1 parent ec98d97 commit 53c20ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/publishing/htmlPagePublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ export class HtmlPagePublisher {
document.head.appendChild(charsetMetaElement);

this.appendMetaTag(document, "viewport", "width=device-width,minimum-scale=1,initial-scale=1");
this.appendStyleLink(document, { src: `/styles/theme.${this.staticAssetSuffix}.css` });
this.appendScriptLink(document, { src: `/scripts/theme.${this.staticAssetSuffix}.js` });
this.appendStyleLink(document, { src: Utils.appendSuffixToFileName(`/styles/theme.css`, this.staticAssetSuffix) });
this.appendScriptLink(document, { src: Utils.appendSuffixToFileName(`/scripts/theme.js`, this.staticAssetSuffix) });
}

private appendMetaTag(document: Document, name: string, content: string): void {
Expand Down
4 changes: 4 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,10 @@ export function debounce(func: () => Promise<void>): () => Promise<void> {
}

export function appendSuffixToFileName(fileName: string, suffix: string): string {
if (!suffix) {
return fileName;
}

const extensionPosition = fileName.lastIndexOf(".");
const suffixedFileName = [fileName.slice(0, extensionPosition), `.${suffix}`, fileName.slice(extensionPosition)].join("");

Expand Down

0 comments on commit 53c20ec

Please sign in to comment.