diff --git a/.config/example.yml b/.config/example.yml
index f3caa0d676..08a5680c41 100644
--- a/.config/example.yml
+++ b/.config/example.yml
@@ -425,3 +425,11 @@ attachLdSignatureForRelays: true
# If you're not using jemalloc, this may cause memory fragmentation and performance issues! (https://www.npmjs.com/package/ws#websocket-compression)
# jemalloc is used by default in the Sharkey Docker image and may be set up manually otherwise: https://github.com/jemalloc/jemalloc/wiki/getting-started
websocketCompression: false
+
+# Inject arbitrary HTML tags to customize Sharkey without having to fork it
+#customHtml:
+# head: |
+#
+#
+#
+#
diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts
index 067672fd79..9bbd50cac5 100644
--- a/packages/backend/src/config.ts
+++ b/packages/backend/src/config.ts
@@ -138,6 +138,10 @@ type Source = {
};
websocketCompression?: boolean;
+
+ customHtml?: {
+ head?: string;
+ }
};
export type Config = {
@@ -257,6 +261,10 @@ export type Config = {
};
websocketCompression?: boolean;
+
+ customHtml: {
+ head: string;
+ }
};
export type FulltextSearchProvider = 'sqlLike' | 'sqlPgroonga' | 'meilisearch' | 'sqlTsvector';
@@ -406,6 +414,9 @@ export function loadConfig(): Config {
maxAge: config.activityLogging?.maxAge ?? (1000 * 60 * 60 * 24 * 30),
},
websocketCompression: config.websocketCompression ?? false,
+ customHtml: {
+ head: config.customHtml?.head ?? '',
+ },
};
}
@@ -558,4 +569,5 @@ function applyEnvOverrides(config: Source) {
_apply_top([['signToActivityPubGet', 'checkActivityPubGetSignature', 'setupPassword']]);
_apply_top(['logging', 'sql', ['disableQueryTruncation', 'enableQueryParamLogging']]);
_apply_top(['activityLogging', ['enabled', 'preSave', 'maxAge']]);
+ _apply_top(['customHtml', ['head']]);
}
diff --git a/packages/backend/src/server/web/ClientServerService.ts b/packages/backend/src/server/web/ClientServerService.ts
index 3ed811e737..437a6802b8 100644
--- a/packages/backend/src/server/web/ClientServerService.ts
+++ b/packages/backend/src/server/web/ClientServerService.ts
@@ -521,6 +521,7 @@ export class ClientServerService {
url: this.config.url,
title: this.meta.name ?? 'Sharkey',
desc: this.meta.description,
+ customHead: this.config.customHtml.head,
...await this.generateCommonPugData(this.meta),
...data,
});
diff --git a/packages/backend/src/server/web/views/base.pug b/packages/backend/src/server/web/views/base.pug
index f57dbbbf4e..f7b0377b22 100644
--- a/packages/backend/src/server/web/views/base.pug
+++ b/packages/backend/src/server/web/views/base.pug
@@ -45,6 +45,8 @@ html
link(rel='stylesheet' href=`/static-assets/fonts/sharkey-icons/style.css?version=${version}`)
link(rel='modulepreload' href=`/vite/${entry.file}`)
+ | !{customHead}
+
if !config.frontendManifestExists
script(type="module" src="/vite/@vite/client")