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 { pick, each } = require('lodash');
|
||||
const { pick } = require('lodash');
|
||||
const actions = require('./actions');
|
||||
const File = require('./file');
|
||||
const { TYPE } = require('./resolve');
|
||||
@ -56,7 +56,7 @@ module.exports = exports = class Asset extends File {
|
||||
height,
|
||||
} ];
|
||||
|
||||
if (this.preprocessed) {
|
||||
if (this.preprocessed || this.ext === '.svg') {
|
||||
this._tasks = [ {
|
||||
output: this.out,
|
||||
input: this.input,
|
||||
|
@ -1,3 +1,10 @@
|
||||
|
||||
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',
|
||||
PNG: '.png',
|
||||
GIF: '.gif',
|
||||
SVG: '.svg',
|
||||
MP4: '.mp4',
|
||||
M4V: '.m4v',
|
||||
MD: '.md',
|
||||
@ -45,6 +46,7 @@ const {
|
||||
JPEG,
|
||||
PNG,
|
||||
GIF,
|
||||
SVG,
|
||||
MP4,
|
||||
M4V,
|
||||
MD,
|
||||
@ -70,7 +72,7 @@ const normalizedExt = exports.normalizedExt = (ext) => {
|
||||
};
|
||||
|
||||
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 isMarkdown = exports.isMarkdown = is(MD);
|
||||
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"
|
||||
}
|
||||
},
|
||||
"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": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/svgo/-/svgo-0.7.2.tgz",
|
||||
|
@ -88,6 +88,7 @@
|
||||
"serve-index": "~1.9.1",
|
||||
"slugify": "~1.4.7",
|
||||
"string-strip-html": "~8.2.3",
|
||||
"svg-dimensions": "~1.0.2",
|
||||
"terser": "~5.6.0",
|
||||
"twemoji": "~13.0.1",
|
||||
"twitter-lite": "~1.1.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user