Advanced favicon management - Mendix Forum

Advanced favicon management

3

currently we are only able to set 1 png as favicon.

this doesn't scale very well, and when dynamically trying to configure this for multitenant, it doesn't scale.

 

https://stackoverflow.com/questions/48956465/favicon-standard-2022-svg-ico-png-and-dimensions

 

edit: currently trying to solve this with JS and injecting elements into the head tag, will post any solutions here.

asked
1 answers

add files into resources folder in your companycore

create an object you can configure per tenant.

create a nanoflow with the following jsa

// This file was generated by Mendix Studio Pro.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
import "mx-global";
import { Big } from "big.js";

// BEGIN EXTRA CODE
// END EXTRA CODE

/**
 * @param {string} str_filename
 * @returns {Promise.<void>}
 */
export async function JSA_SetFavicon(str_filename) {
	// BEGIN USER CODE
	//throw new Error("JavaScript action was not implemented");

	var location = 'resources/' + str_filename;
	var link = document.querySelector("link[rel~='icon']");
	if (!link) {
		link = document.createElement('link');
		link.rel = 'icon';
		document.getElementsByTagName('head')[0].appendChild(link);
	}
	//link.href = 'https://stackoverflow.com/favicon.ico';
	link.href = location;

	// END USER CODE
}

 

Created