feat: Allow injection of raw HTML strings inside <head>

This commit is contained in:
Zlendy 2025-04-11 18:13:38 +02:00
parent 965ba1ef76
commit ce26d8d3cb
No known key found for this signature in database
GPG key ID: A9B6E750D846FC91
3 changed files with 15 additions and 0 deletions

View file

@ -138,6 +138,10 @@ type Source = {
}; };
websocketCompression?: boolean; websocketCompression?: boolean;
customHtml?: {
head?: string;
}
}; };
export type Config = { export type Config = {
@ -257,6 +261,10 @@ export type Config = {
}; };
websocketCompression?: boolean; websocketCompression?: boolean;
customHtml: {
head: string;
}
}; };
export type FulltextSearchProvider = 'sqlLike' | 'sqlPgroonga' | 'meilisearch' | 'sqlTsvector'; export type FulltextSearchProvider = 'sqlLike' | 'sqlPgroonga' | 'meilisearch' | 'sqlTsvector';
@ -406,6 +414,9 @@ export function loadConfig(): Config {
maxAge: config.activityLogging?.maxAge ?? (1000 * 60 * 60 * 24 * 30), maxAge: config.activityLogging?.maxAge ?? (1000 * 60 * 60 * 24 * 30),
}, },
websocketCompression: config.websocketCompression ?? false, websocketCompression: config.websocketCompression ?? false,
customHtml: {
head: config.customHtml?.head ?? '',
},
}; };
} }
@ -558,4 +569,5 @@ function applyEnvOverrides(config: Source) {
_apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature', 'setupPassword']]); _apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature', 'setupPassword']]);
_apply_top(['logging', 'sql', ['disableQueryTruncation', 'enableQueryParamLogging']]); _apply_top(['logging', 'sql', ['disableQueryTruncation', 'enableQueryParamLogging']]);
_apply_top(['activityLogging', ['enabled', 'preSave', 'maxAge']]); _apply_top(['activityLogging', ['enabled', 'preSave', 'maxAge']]);
_apply_top(['customHtml', ['head']]);
} }

View file

@ -521,6 +521,7 @@ export class ClientServerService {
url: this.config.url, url: this.config.url,
title: this.meta.name ?? 'Sharkey', title: this.meta.name ?? 'Sharkey',
desc: this.meta.description, desc: this.meta.description,
customHead: this.config.customHtml.head,
...await this.generateCommonPugData(this.meta), ...await this.generateCommonPugData(this.meta),
...data, ...data,
}); });

View file

@ -45,6 +45,8 @@ html
link(rel='stylesheet' href=`/static-assets/fonts/sharkey-icons/style.css?version=${version}`) link(rel='stylesheet' href=`/static-assets/fonts/sharkey-icons/style.css?version=${version}`)
link(rel='modulepreload' href=`/vite/${entry.file}`) link(rel='modulepreload' href=`/vite/${entry.file}`)
| !{customHead}
if !config.frontendManifestExists if !config.frontendManifestExists
script(type="module" src="/vite/@vite/client") script(type="module" src="/vite/@vite/client")