WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 81fa1d4

Browse files
authored
Merge pull request #4 from louisescher/simple-icons
Add simple icons, empty search field placeholder
2 parents a975bf4 + 3aa4b06 commit 81fa1d4

File tree

15 files changed

+130
-50
lines changed

15 files changed

+130
-50
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# v1.0.1 (Jan. 03, 2025)
2+
3+
- Added a "No results found" text when pagefind doesn't find any results
4+
- Added [simple icons](https://simpleicons.org) since Lucide is phasing out brand icons
5+
- Fixed a bug where the (development-only) mock-endpoint for pagefind would error out due to an invalid mime-type

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "spectre",
33
"type": "module",
4-
"version": "0.0.1",
4+
"version": "1.0.1",
55
"scripts": {
66
"dev": "astro dev",
77
"build": "astro build",
@@ -15,8 +15,9 @@
1515
"@astrojs/node": "^9.0.0",
1616
"@astrojs/sitemap": "^3.2.1",
1717
"@iconify-json/lucide": "^1.2.20",
18+
"@iconify-json/simple-icons": "^1.2.18",
1819
"@iconify/utils": "^2.2.1",
19-
"astro": "^5.1.1",
20+
"astro": "^5.1.2",
2021
"astro-expressive-code": "^0.38.3",
2122
"sharp": "^0.33.5"
2223
},

pnpm-lock.yaml

Lines changed: 24 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/Icon.astro

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,47 @@
11
---
2-
import { icons } from '@iconify-json/lucide';
3-
import type { icons as iconsJson } from '@iconify-json/lucide/icons.json';
2+
import { icons as lucideIconsJSON } from '@iconify-json/lucide';
3+
import { icons as simpleIconsJSON } from '@iconify-json/simple-icons';
4+
import type { icons as lucideIcons } from '@iconify-json/lucide/icons.json';
5+
import type { icons as simpleIcons } from '@iconify-json/simple-icons/icons.json';
46
import { getIconData, iconToSVG, replaceIDs } from '@iconify/utils';
7+
import { AstroError } from 'astro/errors';
58
import type { HTMLAttributes } from 'astro/types';
69
710
interface SVGAttributes extends HTMLAttributes<'svg'> {
811
// biome-ignore lint/suspicious/noExplicitAny: Allow any string index
912
[key: string]: any;
1013
}
1114
12-
interface Props extends HTMLAttributes<'svg'> {
13-
name: keyof typeof iconsJson;
15+
interface LucideProps extends HTMLAttributes<'svg'> {
16+
type: 'lucide';
17+
name: keyof typeof lucideIcons;
1418
}
1519
16-
const { name, ...props } = Astro.props;
20+
interface SimpleIconsProps extends HTMLAttributes<'svg'> {
21+
type: 'simple-icons';
22+
name: keyof typeof simpleIcons;
23+
}
24+
25+
type Props = LucideProps | SimpleIconsProps;
26+
27+
const { type, name, ...props } = Astro.props;
1728
const attributes = props as SVGAttributes;
18-
const iconData = getIconData(icons, name);
29+
30+
if (type !== 'lucide' && type !== 'simple-icons') {
31+
throw new AstroError(`Invalid icon type "${type}"`);
32+
}
33+
34+
// biome-ignore lint/suspicious/noExplicitAny: Needed type not exported
35+
let iconData: any;
36+
37+
if (type === 'lucide') {
38+
iconData = getIconData(lucideIconsJSON, name);
39+
} else {
40+
iconData = getIconData(simpleIconsJSON, name);
41+
}
1942
2043
if (!iconData) {
21-
throw new Error(`Icon "${name}" is missing`);
44+
throw new AstroError(`Icon "${name}" is missing`);
2245
}
2346
2447
const renderData = iconToSVG(iconData, {

src/components/Navbar.astro

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ const path = Astro.url.pathname;
2020
</li>
2121
</ul>
2222
<button class="mobile-nav-toggle">
23-
<Icon name="menu" width={24} height={24} class="menu-closed" />
24-
<Icon name="x" width={24} height={24} class="menu-open" />
23+
<Icon type="lucide" name="menu" width={24} height={24} class="menu-closed" />
24+
<Icon type="lucide" name="x" width={24} height={24} class="menu-open" />
2525
</button>
2626
</nav>
2727
<script is:inline>
@@ -120,7 +120,11 @@ const path = Astro.url.pathname;
120120
`;
121121
}
122122

123-
results.classList.toggle('active', search.results.length > 0);
123+
if (search.results.length === 0 && e.target.value.length > 0) {
124+
results.innerHTML = '<p style="margin-top: 0;">No results found</p>';
125+
}
126+
127+
results.classList.add('active');
124128
});
125129

126130
navToggle?.addEventListener('click', () => {

src/content.config.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
import { file, glob } from "astro/loaders";
22
import { defineCollection, z, reference } from "astro:content";
3-
import type { icons as iconsJson } from '@iconify-json/lucide/icons.json';
3+
import type { icons as lucideIcons } from '@iconify-json/lucide/icons.json';
4+
import type { icons as simpleIcons } from '@iconify-json/simple-icons/icons.json';
45

56
const other = defineCollection({
67
loader: glob({ base: "src/content/other", pattern: "**/*.{md,mdx}" }),
78
});
89

10+
const lucideIconSchema = z.object({
11+
type: z.literal("lucide"),
12+
name: z.custom<keyof typeof lucideIcons>(),
13+
});
14+
15+
const simpleIconSchema = z.object({
16+
type: z.literal("simple-icons"),
17+
name: z.custom<keyof typeof simpleIcons>(),
18+
});
19+
920
const quickInfo = defineCollection({
1021
loader: file("src/content/info.json"),
1122
schema: z.object({
1223
id: z.number(),
13-
icon: z.custom<keyof typeof iconsJson>(),
24+
icon: z.union([lucideIconSchema, simpleIconSchema]),
1425
text: z.string(),
1526
})
1627
});
@@ -19,7 +30,7 @@ const socials = defineCollection({
1930
loader: file("src/content/socials.json"),
2031
schema: z.object({
2132
id: z.number(),
22-
icon: z.custom<keyof typeof iconsJson>(),
33+
icon: z.union([lucideIconSchema, simpleIconSchema]),
2334
text: z.string(),
2435
link: z.string().url(),
2536
})
@@ -69,7 +80,7 @@ const projects = defineCollection({
6980
info: z.array(
7081
z.object({
7182
text: z.string(),
72-
icon: z.custom<keyof typeof iconsJson>(),
83+
icon: z.union([lucideIconSchema, simpleIconSchema]),
7384
link: z.string().url().optional(),
7485
})
7586
)

src/content/info.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
11
[
22
{
33
"id": 1,
4-
"icon": "cake",
4+
"icon": {
5+
"type": "lucide",
6+
"name": "cake"
7+
},
58
"text": "1 year old"
69
},
710
{
811
"id": 2,
9-
"icon": "earth",
12+
"icon": {
13+
"type": "lucide",
14+
"name": "earth"
15+
},
16+
"type": "lucide",
1017
"text": "Made in Germany"
1118
}
1219
]

src/content/posts/getting-started.mdx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,15 @@ The `info.json` file contains the quick info you can see below your profile pict
146146
```jsonc title="info.json"
147147
{
148148
"id": 1, // The ID. Has to be unique for Astro's content collections to work.
149-
"icon": "cake", // The icon to display next to the text.
149+
"icon": {
150+
"type": "lucide", // The icon lib, either "lucide" or "simple-icons".
151+
"name": "cake" // The name of the icon.
152+
},
150153
"text": "1 year old" // The text to display.
151154
}
152155
```
153156

154-
The icons come from [Lucide](https://lucide.dev), so pick one you like and place it's name there!
157+
Spectre supports both [Lucide](https://lucide.dev) and [Simple Icons](https://simpleicons.org).
155158

156159
### Socials
157160

@@ -160,7 +163,10 @@ The `socials.json` file is similar to the `info.json` file in terms of structure
160163
```jsonc title="socials.json"
161164
{
162165
"id": 1, // The ID, has to be unique.
163-
"icon": "github", // The icon to display next to the link.
166+
"icon": {
167+
"type": "lucide", // The icon lib, either "lucide" or "simple-icons".
168+
"name": "github" // The name of the icon.
169+
},
164170
"text": "GitHub", // The text in the link
165171
"link": "https://github.com/louisescher/spectre" // The actual destination of the link
166172
}
@@ -224,9 +230,11 @@ date: 12-29-2024 # Date of publication
224230
description: Spectre is a terminal-inspired theme for Astro, built using Astro and TypeScript. # Description of the project
225231
image: ../assets/spectre.png # The image to be used as the OG image, referenced with a relative path
226232
info: # A TOML-like list of information about the project
227-
- icon: github # Icon for this info
228-
text: GitHub # Text for this info
233+
- text: GitHub # Text for this info
229234
link: https://github.com/louisescher/spectre # Optional if you want to link to somewhere
235+
icon:
236+
type: lucide # Icon library, either "lucide" or "simple-icons"
237+
name: github # The name of the icon
230238
---
231239
```
232240

src/content/projects/spectre.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ date: 12-29-2024
44
description: Spectre is a terminal-inspired theme for Astro, built using Astro and TypeScript.
55
image: ../assets/spectre.png
66
info:
7-
- icon: github
8-
text: GitHub
7+
- text: GitHub
98
link: https://github.com/louisescher/spectre
9+
icon:
10+
type: lucide
11+
name: github
1012
---
1113

1214
Spectre is a terminal-inspired theme for Astro, built using Astro and TypeScript.

src/content/socials.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
[
22
{
33
"id": 1,
4-
"icon": "github",
4+
"icon": {
5+
"type": "lucide",
6+
"name": "github"
7+
},
58
"text": "GitHub",
69
"link": "https://github.com/louisescher/spectre"
710
}

0 commit comments

Comments
 (0)