mirror of https://github.com/iconify/api.git
fix: update code for css, support color
This commit is contained in:
parent
9bb45c8bcf
commit
6e9abebfe5
|
|
@ -1,18 +1,18 @@
|
||||||
{
|
{
|
||||||
"name": "@iconify/api",
|
"name": "@iconify/api",
|
||||||
"version": "3.0.0-beta.1",
|
"version": "3.0.0-beta.2",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@iconify/api",
|
"name": "@iconify/api",
|
||||||
"version": "3.0.0-beta.1",
|
"version": "3.0.0-beta.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/formbody": "^7.4.0",
|
"@fastify/formbody": "^7.4.0",
|
||||||
"@iconify/tools": "^2.2.0",
|
"@iconify/tools": "^2.2.0",
|
||||||
"@iconify/types": "^2.0.0",
|
"@iconify/types": "^2.0.0",
|
||||||
"@iconify/utils": "^2.0.9",
|
"@iconify/utils": "^2.0.11",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"fastify": "^4.11.0"
|
"fastify": "^4.11.0"
|
||||||
},
|
},
|
||||||
|
|
@ -246,9 +246,9 @@
|
||||||
"integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg=="
|
"integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg=="
|
||||||
},
|
},
|
||||||
"node_modules/@iconify/utils": {
|
"node_modules/@iconify/utils": {
|
||||||
"version": "2.0.9",
|
"version": "2.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-2.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-2.0.11.tgz",
|
||||||
"integrity": "sha512-ropNqaeamoxZvXxvaTJXrI0MrqdWdDVIs/mW7/sEQbNi0aXYUGL2iuLs1da3QR163gyG63kiyTsqw2oQYamw3Q==",
|
"integrity": "sha512-oEBZkHpkgySHcMZi80ycoJ+ZdLoJhmbN0+gUK8qNPY79ndus8fBHKPyjjwz5kIvr5U9yiym+xBTTnZOB3m5/Pw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antfu/install-pkg": "^0.1.1",
|
"@antfu/install-pkg": "^0.1.1",
|
||||||
"@antfu/utils": "^0.7.2",
|
"@antfu/utils": "^0.7.2",
|
||||||
|
|
@ -3086,9 +3086,9 @@
|
||||||
"integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg=="
|
"integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg=="
|
||||||
},
|
},
|
||||||
"@iconify/utils": {
|
"@iconify/utils": {
|
||||||
"version": "2.0.9",
|
"version": "2.0.11",
|
||||||
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-2.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/@iconify/utils/-/utils-2.0.11.tgz",
|
||||||
"integrity": "sha512-ropNqaeamoxZvXxvaTJXrI0MrqdWdDVIs/mW7/sEQbNi0aXYUGL2iuLs1da3QR163gyG63kiyTsqw2oQYamw3Q==",
|
"integrity": "sha512-oEBZkHpkgySHcMZi80ycoJ+ZdLoJhmbN0+gUK8qNPY79ndus8fBHKPyjjwz5kIvr5U9yiym+xBTTnZOB3m5/Pw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@antfu/install-pkg": "^0.1.1",
|
"@antfu/install-pkg": "^0.1.1",
|
||||||
"@antfu/utils": "^0.7.2",
|
"@antfu/utils": "^0.7.2",
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
"author": "Vjacheslav Trushkin",
|
"author": "Vjacheslav Trushkin",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "3.0.0-beta.2",
|
"version": "3.0.0-beta.3",
|
||||||
"bugs": "https://github.com/iconify/api/issues",
|
"bugs": "https://github.com/iconify/api/issues",
|
||||||
"homepage": "https://github.com/iconify/api",
|
"homepage": "https://github.com/iconify/api",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
"@fastify/formbody": "^7.4.0",
|
"@fastify/formbody": "^7.4.0",
|
||||||
"@iconify/tools": "^2.2.0",
|
"@iconify/tools": "^2.2.0",
|
||||||
"@iconify/types": "^2.0.0",
|
"@iconify/types": "^2.0.0",
|
||||||
"@iconify/utils": "^2.0.9",
|
"@iconify/utils": "^2.0.11",
|
||||||
"dotenv": "^16.0.3",
|
"dotenv": "^16.0.3",
|
||||||
"fastify": "^4.11.0"
|
"fastify": "^4.11.0"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -97,12 +97,7 @@ export async function startHTTPServer() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Stylesheet: /prefix/style.css, /prefix.css
|
// Stylesheet: /prefix.css
|
||||||
server.get('/:prefix(' + iconNameRoutePartialRegEx + ')/style.css', (req, res) => {
|
|
||||||
runWhenLoaded(() => {
|
|
||||||
generateIconsStyleResponse((req.params as PrefixParams).prefix, req.query, res);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
server.get('/:prefix(' + iconNameRoutePartialRegEx + ').css', (req, res) => {
|
server.get('/:prefix(' + iconNameRoutePartialRegEx + ').css', (req, res) => {
|
||||||
runWhenLoaded(() => {
|
runWhenLoaded(() => {
|
||||||
generateIconsStyleResponse((req.params as PrefixParams).prefix, req.query, res);
|
generateIconsStyleResponse((req.params as PrefixParams).prefix, req.query, res);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import type { FastifyReply, FastifyRequest } from 'fastify';
|
import type { FastifyReply, FastifyRequest } from 'fastify';
|
||||||
|
import { stringToColor } from '@iconify/utils/lib/colors';
|
||||||
import { getIconsCSS } from '@iconify/utils/lib/css/icons';
|
import { getIconsCSS } from '@iconify/utils/lib/css/icons';
|
||||||
import { getStoredIconsData } from '../../data/icon-set/utils/get-icons';
|
import { getStoredIconsData } from '../../data/icon-set/utils/get-icons';
|
||||||
import { iconSets } from '../../data/icon-sets';
|
import { iconSets } from '../../data/icon-sets';
|
||||||
|
|
@ -53,6 +54,13 @@ export function generateIconsStyleResponse(prefix: string, query: FastifyRequest
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 'color': string
|
||||||
|
// Sets color for monotone images
|
||||||
|
const color = qOptions.color;
|
||||||
|
if (typeof color === 'string' && stringToColor(color)) {
|
||||||
|
options.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
// 'mode': string
|
// 'mode': string
|
||||||
// Forces mode
|
// Forces mode
|
||||||
// Alias for 'background': 'bg'
|
// Alias for 'background': 'bg'
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue