mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-29 07:29:07 +00:00
Update mod.js to work with the new icons repo
This commit is contained in:
parent
62e6b05fd6
commit
bcbd1690bb
@ -9,8 +9,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const { createElement } = require('../../pkg/helpers.js'),
|
const { createElement } = require('../../pkg/helpers.js'),
|
||||||
fs = require('fs-extra'),
|
fs = require('fs-extra');
|
||||||
path = require('path');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
id: '2d1f4809-9581-40dd-9bf3-4239db406483',
|
id: '2d1f4809-9581-40dd-9bf3-4239db406483',
|
||||||
@ -37,14 +36,22 @@ module.exports = {
|
|||||||
hacks: {
|
hacks: {
|
||||||
'renderer/preload.js'(store, __exports) {
|
'renderer/preload.js'(store, __exports) {
|
||||||
let garbageCollector = [];
|
let garbageCollector = [];
|
||||||
|
const iconsUrl = 'https://raw.githubusercontent.com/notion-enhancer/icons/main/';
|
||||||
|
|
||||||
|
function getAsync(urlString, callback) {
|
||||||
|
let httpReq = new XMLHttpRequest();
|
||||||
|
httpReq.onreadystatechange = function() {
|
||||||
|
if (httpReq.readyState == 4 && httpReq.status == 200) callback(httpReq.responseText);
|
||||||
|
};
|
||||||
|
httpReq.open('GET', urlString, true);
|
||||||
|
httpReq.send(null);
|
||||||
|
}
|
||||||
|
|
||||||
// Retrieve Icons data
|
// Retrieve Icons data
|
||||||
let notionIconsData;
|
let notionIconsData;
|
||||||
(async () => {
|
getAsync(iconsUrl + 'icons.json', iconsData => {
|
||||||
notionIconsData = JSON.parse(
|
notionIconsData = JSON.parse(iconsData);
|
||||||
await fs.readFile( path.resolve(`${__dirname}/icons.json`) )
|
});
|
||||||
);
|
|
||||||
})();
|
|
||||||
|
|
||||||
// Retrieve custom Icons data
|
// Retrieve custom Icons data
|
||||||
let customIconsData;
|
let customIconsData;
|
||||||
@ -258,7 +265,7 @@ module.exports = {
|
|||||||
|
|
||||||
if (notionIconsData && notionIconsData.icons) {
|
if (notionIconsData && notionIconsData.icons) {
|
||||||
notionIconsData.icons.forEach(i => {
|
notionIconsData.icons.forEach(i => {
|
||||||
i.sourceUrl = i.sourceUrl || (notionIconsData.sourceUrl + i.source);
|
i.sourceUrl = i.sourceUrl || (iconsUrl + i.source);
|
||||||
iconSets.push( renderIconSet(i) );
|
iconSets.push( renderIconSet(i) );
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user