mirror of
https://github.com/GenderDysphoria/GenderDysphoria.fyi.git
synced 2025-01-31 07:16:17 +00:00
Added support for svgs
This commit is contained in:
parent
514acab9ee
commit
a83bbdd885
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const { pick, each } = require('lodash');
|
const { pick } = require('lodash');
|
||||||
const actions = require('./actions');
|
const actions = require('./actions');
|
||||||
const File = require('./file');
|
const File = require('./file');
|
||||||
const { TYPE } = require('./resolve');
|
const { TYPE } = require('./resolve');
|
||||||
@ -56,7 +56,7 @@ module.exports = exports = class Asset extends File {
|
|||||||
height,
|
height,
|
||||||
} ];
|
} ];
|
||||||
|
|
||||||
if (this.preprocessed) {
|
if (this.preprocessed || this.ext === '.svg') {
|
||||||
this._tasks = [ {
|
this._tasks = [ {
|
||||||
output: this.out,
|
output: this.out,
|
||||||
input: this.input,
|
input: this.input,
|
||||||
|
@ -1,3 +1,10 @@
|
|||||||
|
|
||||||
var { promisify } = require('util');
|
var { promisify } = require('util');
|
||||||
module.exports = exports = promisify(require('image-size'));
|
var { extname } = require('path');
|
||||||
|
var svgDim = promisify(require('svg-dimensions').get);
|
||||||
|
var imgDim = promisify(require('image-size'));
|
||||||
|
|
||||||
|
module.exports = exports = async (fpath) => {
|
||||||
|
if (extname(fpath) === '.svg') return svgDim(fpath);
|
||||||
|
return imgDim(fpath);
|
||||||
|
};
|
||||||
|
@ -28,6 +28,7 @@ const EXT = exports.EXT = {
|
|||||||
JPEG: '.jpeg',
|
JPEG: '.jpeg',
|
||||||
PNG: '.png',
|
PNG: '.png',
|
||||||
GIF: '.gif',
|
GIF: '.gif',
|
||||||
|
SVG: '.svg',
|
||||||
MP4: '.mp4',
|
MP4: '.mp4',
|
||||||
M4V: '.m4v',
|
M4V: '.m4v',
|
||||||
MD: '.md',
|
MD: '.md',
|
||||||
@ -45,6 +46,7 @@ const {
|
|||||||
JPEG,
|
JPEG,
|
||||||
PNG,
|
PNG,
|
||||||
GIF,
|
GIF,
|
||||||
|
SVG,
|
||||||
MP4,
|
MP4,
|
||||||
M4V,
|
M4V,
|
||||||
MD,
|
MD,
|
||||||
@ -70,7 +72,7 @@ const normalizedExt = exports.normalizedExt = (ext) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isVideo = exports.isVideo = is(MP4, M4V);
|
const isVideo = exports.isVideo = is(MP4, M4V);
|
||||||
const isImage = exports.isImage = is(JPG, JPEG, PNG, GIF);
|
const isImage = exports.isImage = is(JPG, JPEG, PNG, GIF, SVG);
|
||||||
const isHandybars = exports.isHandybars = is(XML, HBS, HTML);
|
const isHandybars = exports.isHandybars = is(XML, HBS, HTML);
|
||||||
const isMarkdown = exports.isMarkdown = is(MD);
|
const isMarkdown = exports.isMarkdown = is(MD);
|
||||||
const isPage = exports.isPage = is(isHandybars, isMarkdown);
|
const isPage = exports.isPage = is(isHandybars, isMarkdown);
|
||||||
|
9
package-lock.json
generated
9
package-lock.json
generated
@ -12288,6 +12288,15 @@
|
|||||||
"es6-symbol": "^3.1.1"
|
"es6-symbol": "^3.1.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"svg-dimensions": {
|
||||||
|
"version": "1.0.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/svg-dimensions/-/svg-dimensions-1.0.2.tgz",
|
||||||
|
"integrity": "sha1-s1oDW91X/tJxaJMbmz1bC7VebtI=",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"xml2js": "^0.4.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
"svgo": {
|
"svgo": {
|
||||||
"version": "0.7.2",
|
"version": "0.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/svgo/-/svgo-0.7.2.tgz",
|
"resolved": "https://registry.npmjs.org/svgo/-/svgo-0.7.2.tgz",
|
||||||
|
@ -88,6 +88,7 @@
|
|||||||
"serve-index": "~1.9.1",
|
"serve-index": "~1.9.1",
|
||||||
"slugify": "~1.4.7",
|
"slugify": "~1.4.7",
|
||||||
"string-strip-html": "~8.2.3",
|
"string-strip-html": "~8.2.3",
|
||||||
|
"svg-dimensions": "~1.0.2",
|
||||||
"terser": "~5.6.0",
|
"terser": "~5.6.0",
|
||||||
"twemoji": "~13.0.1",
|
"twemoji": "~13.0.1",
|
||||||
"twitter-lite": "~1.1.0",
|
"twitter-lite": "~1.1.0",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user