Skip to content

Commit f73d361

Browse files
🐛 ensure the pwa tags are preserved when using custom branding
1 parent 573712f commit f73d361

File tree

1 file changed

+72
-13
lines changed

1 file changed

+72
-13
lines changed

server/utils/boot/MetaGenerator.js

Lines changed: 72 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -194,19 +194,78 @@ class MetaGenerator {
194194
if (customTitle === null && faviconURL === null) {
195195
this.#customConfig = this.#defaultMeta();
196196
} else {
197-
this.#customConfig = [
198-
{
199-
tag: "link",
200-
props: { rel: "icon", href: this.#validUrl(faviconURL) },
201-
},
202-
{
203-
tag: "title",
204-
props: null,
205-
content:
206-
customTitle ??
207-
"AnythingLLM | Your personal LLM trained on anything",
208-
},
209-
];
197+
// When custom settings exist, include all default meta tags but override specific ones
198+
this.#customConfig = this.#defaultMeta().map((tag) => {
199+
// Override favicon link
200+
if (tag.tag === "link" && tag.props?.rel === "icon") {
201+
return {
202+
tag: "link",
203+
props: { rel: "icon", href: this.#validUrl(faviconURL) },
204+
};
205+
}
206+
// Override page title
207+
if (tag.tag === "title") {
208+
return {
209+
tag: "title",
210+
props: null,
211+
content:
212+
customTitle ??
213+
"AnythingLLM | Your personal LLM trained on anything",
214+
};
215+
}
216+
// Override meta title
217+
if (tag.tag === "meta" && tag.props?.name === "title") {
218+
return {
219+
tag: "meta",
220+
props: {
221+
name: "title",
222+
content:
223+
customTitle ??
224+
"AnythingLLM | Your personal LLM trained on anything",
225+
},
226+
};
227+
}
228+
// Override og:title
229+
if (tag.tag === "meta" && tag.props?.property === "og:title") {
230+
return {
231+
tag: "meta",
232+
props: {
233+
property: "og:title",
234+
content:
235+
customTitle ??
236+
"AnythingLLM | Your personal LLM trained on anything",
237+
},
238+
};
239+
}
240+
// Override twitter:title
241+
if (tag.tag === "meta" && tag.props?.property === "twitter:title") {
242+
return {
243+
tag: "meta",
244+
props: {
245+
property: "twitter:title",
246+
content:
247+
customTitle ??
248+
"AnythingLLM | Your personal LLM trained on anything",
249+
},
250+
};
251+
}
252+
// Override apple-touch-icon if custom favicon is set
253+
if (
254+
tag.tag === "link" &&
255+
tag.props?.rel === "apple-touch-icon" &&
256+
faviconURL
257+
) {
258+
return {
259+
tag: "link",
260+
props: {
261+
rel: "apple-touch-icon",
262+
href: this.#validUrl(faviconURL),
263+
},
264+
};
265+
}
266+
// Return original tag for everything else (including PWA tags)
267+
return tag;
268+
});
210269
}
211270

212271
return this.#customConfig;

0 commit comments

Comments
 (0)