mirror of https://github.com/wekan/wekan
The Open Source kanban (built with Meteor). Keep variable/table/field names camelCase. For translations, only add Pull Request changes to wekan/i18n/en.i18n.json , other translations are done at https://transifex.com/wekan/wekan only.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.8 KiB
54 lines
1.8 KiB
import { WebApp } from 'meteor/webapp';
|
|
import { WebAppInternals } from 'meteor/webapp';
|
|
import Settings from '/models/settings';
|
|
|
|
Meteor.startup(() => {
|
|
// Use Meteor's official API to modify the HTML boilerplate
|
|
WebAppInternals.registerBoilerplateDataCallback('wekan-custom-head', (request, data) => {
|
|
try {
|
|
const setting = Settings.findOne();
|
|
|
|
// Initialize head array if it doesn't exist
|
|
if (!data.head) {
|
|
data.head = '';
|
|
}
|
|
|
|
// Always set title tag based on productName
|
|
const productName = (setting && setting.productName) ? setting.productName : 'Wekan';
|
|
data.head += `\n <title>${productName}</title>\n`;
|
|
|
|
// Only add custom head tags if enabled
|
|
if (!setting || !setting.customHeadEnabled) {
|
|
return data;
|
|
}
|
|
|
|
let injection = '';
|
|
// Add custom link tags (except manifest if custom manifest is enabled)
|
|
if (setting.customHeadLinkTags && setting.customHeadLinkTags.trim()) {
|
|
let linkTags = setting.customHeadLinkTags;
|
|
if (setting.customManifestEnabled) {
|
|
// Remove any manifest links from custom link tags to avoid duplicates
|
|
linkTags = linkTags.replace(/<link[^>]*rel=["\']?manifest["\']?[^>]*>/gi, '');
|
|
}
|
|
if (linkTags.trim()) {
|
|
injection += linkTags + '\n';
|
|
}
|
|
}
|
|
|
|
// Add manifest link if custom manifest is enabled
|
|
if (setting.customManifestEnabled) {
|
|
injection += ' <link rel="manifest" href="/site.webmanifest" crossorigin="use-credentials">\n';
|
|
}
|
|
|
|
if (injection.trim()) {
|
|
// Append custom head content to the existing head
|
|
data.head += injection;
|
|
}
|
|
|
|
return data;
|
|
} catch (e) {
|
|
console.error('[Custom Head] Error in boilerplate callback:', e.message, e.stack);
|
|
return data;
|
|
}
|
|
});
|
|
});
|
|
|