refactor: use shared getIconCode and ThemeKey from community packages

This commit is contained in:
saberzero1 2026-04-03 15:07:49 +02:00
parent 03500637ef
commit 0ce1e8930f
No known key found for this signature in database
6 changed files with 10 additions and 90 deletions

19
dist/index.d.ts vendored
View file

@ -1,25 +1,8 @@
import { SatoriOptions } from 'satori';
import { QuartzEmitterPlugin, GlobalConfiguration, FullSlug } from '@quartz-community/types';
import { QuartzEmitterPlugin, ThemeKey, GlobalConfiguration, FullSlug } from '@quartz-community/types';
export { QuartzEmitterPlugin } from '@quartz-community/types';
import { JSX } from 'preact';
interface ColorScheme {
light: string;
lightgray: string;
gray: string;
darkgray: string;
dark: string;
secondary: string;
tertiary: string;
highlight: string;
textHighlight: string;
}
interface Colors {
lightMode: ColorScheme;
darkMode: ColorScheme;
}
type ThemeKey = keyof Colors;
type Frontmatter = {
title?: string;
description?: string;

22
dist/index.js vendored
View file

@ -5,6 +5,7 @@ import { styleText } from 'util';
import sharp from 'sharp';
import { joinSegments } from '@quartz-community/types';
import { unescapeHTML } from '@quartz-community/utils';
import { getIconCode } from '@quartz-community/utils/emoji';
import { jsxs, Fragment, jsx } from 'preact/jsx-runtime';
const require$1 = createRequire(import.meta.url);
@ -23788,27 +23789,6 @@ function getFontSpecificationName(spec) {
}
// src/emoji.ts
var U200D = String.fromCharCode(8205);
var UFE0Fg = /\uFE0F/g;
function getIconCode(char) {
return toCodePoint(char.indexOf(U200D) < 0 ? char.replace(UFE0Fg, "") : char);
}
function toCodePoint(unicodeSurrogates) {
const r = [];
let c2 = 0, p = 0, i = 0;
while (i < unicodeSurrogates.length) {
c2 = unicodeSurrogates.charCodeAt(i++);
if (p) {
r.push((65536 + (p - 55296 << 10) + (c2 - 56320)).toString(16));
p = 0;
} else if (55296 <= c2 && c2 <= 56319) {
p = c2;
} else {
r.push(c2.toString(16));
}
}
return r.join("-");
}
var emojimap = void 0;
async function loadEmoji(code) {
if (!emojimap) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

19
package-lock.json generated
View file

@ -1118,7 +1118,7 @@
},
"node_modules/@quartz-community/types": {
"version": "0.2.1",
"resolved": "git+ssh://git@github.com/quartz-community/types.git#5786c30b02188ebcccb6f0479205bd6751336015",
"resolved": "git+ssh://git@github.com/quartz-community/types.git#b1dc9ac610c253d0673d1c8c9a695cd4c5aac0ae",
"license": "MIT",
"engines": {
"node": ">=22",
@ -1139,7 +1139,7 @@
},
"node_modules/@quartz-community/utils": {
"version": "0.1.0",
"resolved": "git+ssh://git@github.com/quartz-community/utils.git#8d2e14bcb9efe83ec8085dd0c4f848f3f25a9c78",
"resolved": "git+ssh://git@github.com/quartz-community/utils.git#8b6e32ba07b62500dce10f0c79ca43bb7d7e55bc",
"license": "MIT",
"dependencies": {
"@quartz-community/types": "github:quartz-community/types"
@ -1589,7 +1589,6 @@
"integrity": "sha512-oH72nZRfDv9lADUBSo104Aq7gPHpQZc4BTx38r9xf9pg5LfP6EzSyH2n7qFmmxRQXh7YlUXODcYsg6PuTDSxGg==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"undici-types": "~7.16.0"
}
@ -1641,7 +1640,6 @@
"integrity": "sha512-4Z+L8I2OqhZV8qA132M4wNL30ypZGYOQVBfMgxDH/K5UX0PNqTu1c6za9ST5r9+tavvHiTWmBnKzpCJ/GlVFtg==",
"dev": true,
"license": "BSD-2-Clause",
"peer": true,
"dependencies": {
"@typescript-eslint/scope-manager": "7.18.0",
"@typescript-eslint/types": "7.18.0",
@ -1935,7 +1933,6 @@
"integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==",
"dev": true,
"license": "MIT",
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@ -2512,7 +2509,6 @@
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"peer": true,
"bin": {
"esbuild": "bin/esbuild"
},
@ -2575,7 +2571,6 @@
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@eslint-community/eslint-utils": "^4.2.0",
"@eslint-community/regexpp": "^4.6.1",
@ -2960,8 +2955,7 @@
"resolved": "https://registry.npmjs.org/github-slugger/-/github-slugger-2.0.0.tgz",
"integrity": "sha512-IaOQ9puYtjrkq7Y0Ygl9KDZnrf/aiUJYUpVf89y8kyaxbRG7Y1SrX/jaumrv81vc61+kiMempujsM3Yw7w5qcw==",
"devOptional": true,
"license": "ISC",
"peer": true
"license": "ISC"
},
"node_modules/glob": {
"version": "7.2.3",
@ -3082,7 +3076,6 @@
"integrity": "sha512-zl6s8LwNyo1P9uw+XJGvZtdFF1GdAkOg8ujOw+4Pyb76874fLps4ueHXDhXWdk6YHQ6OgUtinliG7RsYvCbbBg==",
"devOptional": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@types/estree": "^1.0.0",
"@types/hast": "^3.0.0",
@ -4407,7 +4400,6 @@
}
],
"license": "MIT",
"peer": true,
"dependencies": {
"nanoid": "^3.3.11",
"picocolors": "^1.1.1",
@ -4472,7 +4464,6 @@
"resolved": "https://registry.npmjs.org/preact/-/preact-10.28.3.tgz",
"integrity": "sha512-tCmoRkPQLpBeWzpmbhryairGnhW9tKV6c6gr/w+RhoRoKEJwsjzipwp//1oCpGPOchvSLaAPlpcJi9MwMmoPyA==",
"license": "MIT",
"peer": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/preact"
@ -5041,7 +5032,6 @@
"integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"node": ">=12"
},
@ -5225,7 +5215,6 @@
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
"dev": true,
"license": "Apache-2.0",
"peer": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
@ -5348,7 +5337,6 @@
"integrity": "sha512-KzIbH/9tXat2u30jf+smMwFCsno4wHVdNmzFyL+T/L3UGqqk6JKfVqOFOZEpZSHADH1k40ab6NUIXZq422ov3Q==",
"devOptional": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@types/unist": "^3.0.0",
"vfile-message": "^4.0.0"
@ -5379,7 +5367,6 @@
"integrity": "sha512-o5a9xKjbtuhY6Bi5S3+HvbRERmouabWbyUcpXXUA1u+GNUKoROi9byOJ8M0nHbHYHkYICiMlqxkg1KkYmm25Sw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"esbuild": "^0.21.3",
"postcss": "^8.4.43",

View file

@ -15,13 +15,10 @@ import type {
import { joinSegments } from "@quartz-community/types";
import { unescapeHTML } from "@quartz-community/utils";
import type { JSX } from "preact";
import {
type FontSpecification,
type Theme,
type ThemeKey,
getFontSpecificationName,
} from "./theme.js";
import { loadEmoji, getIconCode } from "./emoji.js";
import { type ThemeKey } from "@quartz-community/types";
import { getIconCode } from "@quartz-community/utils/emoji";
import { type FontSpecification, type Theme, getFontSpecificationName } from "./theme.js";
import { loadEmoji } from "./emoji.js";
const QUARTZ = "quartz";

View file

@ -1,30 +1,3 @@
const U200D = String.fromCharCode(8205);
const UFE0Fg = /\uFE0F/g;
export function getIconCode(char: string) {
return toCodePoint(char.indexOf(U200D) < 0 ? char.replace(UFE0Fg, "") : char);
}
function toCodePoint(unicodeSurrogates: string) {
const r: string[] = [];
let c = 0,
p = 0,
i = 0;
while (i < unicodeSurrogates.length) {
c = unicodeSurrogates.charCodeAt(i++);
if (p) {
r.push((65536 + ((p - 55296) << 10) + (c - 56320)).toString(16));
p = 0;
} else if (55296 <= c && c <= 56319) {
p = c;
} else {
r.push(c.toString(16));
}
}
return r.join("-");
}
type EmojiMap = {
codePointToName: Record<string, string>;
nameToBase64: Record<string, string>;