fix landingpage icons

This commit is contained in:
Stijnus
2025-01-30 22:50:42 +01:00
parent fab0cdd04e
commit 1eae44dd14
2 changed files with 6 additions and 11 deletions

View File

@@ -2,7 +2,6 @@ import { globSync } from 'fast-glob';
import fs from 'node:fs/promises';
import { basename, join } from 'node:path';
import { defineConfig, presetIcons, presetUno, transformerDirectives } from 'unocss';
import type { IconifyJSON } from '@iconify/types';
// Debug: Log the current working directory and icon paths
console.log('CWD:', process.cwd());
@@ -16,12 +15,11 @@ const customIconCollection = {
[collectionName]: iconPaths.reduce(
(acc, iconPath) => {
const [iconName] = basename(iconPath).split('.');
console.log(`Loading icon: ${iconName} from ${iconPath}`); // Debug log
console.log(`Loading icon: ${iconName} from ${iconPath}`);
acc[iconName] = async () => {
try {
const content = await fs.readFile(iconPath, 'utf8');
// Simplified SVG processing
return content
.replace(/fill="[^"]*"/g, 'fill="currentColor"')
.replace(/fill='[^']*'/g, "fill='currentColor'")
@@ -120,7 +118,7 @@ const COLOR_PRIMITIVES = {
export default defineConfig({
safelist: [
// Explicitly safelist all icon combinations with both formats
// Explicitly safelist all icon combinations
...Object.keys(customIconCollection[collectionName] || {}).map((x) => `i-${collectionName}-${x}`),
...Object.keys(customIconCollection[collectionName] || {}).map((x) => `i-${collectionName}-${x.toLowerCase()}`),
],
@@ -265,11 +263,7 @@ export default defineConfig({
presetIcons({
warn: true,
collections: {
bolt: customIconCollection.bolt,
ph: async () => {
const icons = await import('@iconify-json/ph/icons.json');
return icons.default as IconifyJSON;
},
[collectionName]: customIconCollection[collectionName],
},
extraProperties: {
display: 'inline-block',
@@ -278,7 +272,8 @@ export default defineConfig({
height: '24px',
},
scale: 1,
cdn: 'https://esm.sh/',
unit: 'px',
cdn: '',
}),
],
});