Skip to content

Commit

Permalink
Replace NodeJS methods with native javascript
Browse files Browse the repository at this point in the history
Fixes #50

When fixing the path generation for "msapplication-TileImage" #48 NodeJS methods were used.
This commit fixes the usage of NodeJS which is not available in the browser.
  • Loading branch information
hendrikbursian committed Aug 16, 2020
1 parent 3790e26 commit fb4621f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions gridsome.client.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const { parse } = require('path');
const { register } = require('register-service-worker');

const clientConfig = function (Vue, options, context) {
Expand Down Expand Up @@ -30,9 +29,17 @@ const clientConfig = function (Vue, options, context) {
})
}

const iconsDir = 'assets/static/';
const iconPathParsed = parse(options.icon);
const msTileImage = `/${iconsDir}${iconPathParsed.name}-144x144${iconPathParsed.ext}`;
const iconsDir = '/assets/static/';
const iconName = options.icon.split('/').slice(-1)[0];
const iconNameDotIdx = iconName.lastIndexOf('.');

var msTileImage = iconsDir;

if(iconNameDotIdx > -1) {
msTileImage += `${iconName.substring(0, iconNameDotIdx)}-144x144${iconName.substring(iconNameDotIdx)}`
} else {
msTileImage += `${iconName}-144x144`
}

head.link.push({
rel: 'manifest',
Expand Down

0 comments on commit fb4621f

Please sign in to comment.