Skip to content

Commit 3db33e7

Browse files
committed
chore: アイコンの auto-import を追加
1 parent dee86e1 commit 3db33e7

7 files changed

Lines changed: 41 additions & 12 deletions

File tree

astro.config.mjs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ import rehypeExternalLinks from "rehype-external-links";
1313
import wikiLinkPlugin from "remark-wiki-link-plus";
1414
import starlightScrollToTop from "starlight-scroll-to-top";
1515
import starlightSidebarTopics from "starlight-sidebar-topics";
16+
import AutoImportAstro from "unplugin-auto-import/astro";
17+
import AutoImport from "unplugin-auto-import/vite";
18+
import IconsResolver from "unplugin-icons/resolver";
1619
import Icons from "unplugin-icons/vite";
1720

1821
// https://astro.build/config
@@ -109,6 +112,14 @@ export default defineConfig({
109112
],
110113
}),
111114
react(),
115+
AutoImportAstro({
116+
resolvers: [
117+
IconsResolver({
118+
prefix: "Icon",
119+
extension: "jsx",
120+
}),
121+
],
122+
}),
112123
],
113124
site: "https://learn.sysken.net",
114125
image: {
@@ -132,9 +143,19 @@ export default defineConfig({
132143
},
133144
vite: {
134145
plugins: [
146+
// NOTE: インポートなしにアイコンを使用できるようにするための設定
147+
// ref: https://github.com/unplugin/unplugin-icons/blob/3831eb07d96e94d503df62f45512f3ca3e50cc26/README.md#auto-importing
148+
AutoImport({
149+
resolvers: [
150+
IconsResolver({
151+
prefix: "Icon",
152+
extension: "jsx",
153+
}),
154+
],
155+
}),
135156
Icons({
136-
compiler: "jsx",
137157
autoInstall: true,
158+
compiler: "jsx",
138159
jsx: "react",
139160
}),
140161
],

auto-imports.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* eslint-disable */
2+
/* prettier-ignore */
3+
// @ts-nocheck
4+
// noinspection JSUnusedGlobalSymbols
5+
// Generated by unplugin-auto-import
6+
// biome-ignore lint: disable
7+
export {}
8+
declare global {
9+
const IconMaterialSymbolsBook4Spark: typeof import('~icons/material-symbols/book4-spark.jsx')['default']
10+
const IconMaterialSymbolsChecklist: typeof import('~icons/material-symbols/checklist.jsx')['default']
11+
const IconMdiBookCheck: typeof import('~icons/mdi/book-check.jsx')['default']
12+
const IconMdiBookCheckBookCheck: typeof import('~icons/mdi/book-check-book-check.jsx')['default']
13+
}

bun.lockb

632 KB
Binary file not shown.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"@css-modules-kit/codegen": "^0.4.1",
5353
"@css-modules-kit/eslint-plugin": "^0.2.1",
5454
"@eslint-react/eslint-plugin": "^1.52.2",
55-
"@iconify/json": "^2.2.354",
55+
"@iconify/json": "^2.2.375",
5656
"@svgr/core": "^8.1.0",
5757
"@svgr/plugin-jsx": "^8.1.0",
5858
"cspell": "^9.1.2",
@@ -68,6 +68,7 @@
6868
"sharp": "^0.34.2",
6969
"typescript": "^5.8.3",
7070
"typescript-eslint": "^8.35.1",
71-
"unplugin-icons": "^22.1.0"
71+
"unplugin-auto-import": "^20.0.0",
72+
"unplugin-icons": "^22.2.0"
7273
}
7374
}

src/components/Checkpoint.astro

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
---
2-
import Checklist from "~icons/material-symbols/checklist";
3-
---
4-
51
<script>
62
document.addEventListener("DOMContentLoaded", () => {
73
const checkpointElems = document.querySelectorAll<HTMLElement>(".comp-checkpoint");
@@ -40,7 +36,7 @@ document.addEventListener("DOMContentLoaded", () => {
4036

4137
<div class="container comp-checkpoint">
4238
<div class="title">
43-
<Checklist height="100%" width="100%" />
39+
<IconMaterialSymbolsChecklist height="100%" width="100%" />
4440
<p>チェックポイント!</p>
4541
</div>
4642
<slot />

src/components/ReadTextbookBadge.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import type { ReactElement } from "react";
22
import { useEffect, useRef, useState } from "react";
3-
import BookCheck from "~icons/mdi/book-check";
43
import { appendReadTextbookId, removeReadTextbookId } from "@/lib/stores/read-textbook-ids";
54
import { waitMs } from "@/lib/utils";
65
import styles from "./ReadTextbookBadge.module.css";
@@ -33,7 +32,7 @@ export function ReadTextbookBadge({ textbookId }: { textbookId: string }): React
3332
return (
3433
<div className={styles.badgeContainer} ref={badgeContainerRef}>
3534
<div className={styles.badge}>
36-
<BookCheck />
35+
<IconMdiBookCheck />
3736
<span>最後まで読み終えました! えらい!</span>
3837
</div>
3938
<button

src/components/starlight/PageTitle.astro

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
import type { ComponentProps } from "astro/types";
33
import Default from "@astrojs/starlight/components/PageTitle.astro";
4-
import Book4Spark from "~icons/material-symbols/book-4-spark";
54
65
const { data: { description } } = Astro.locals.starlightRoute.entry;
76
@@ -11,7 +10,7 @@ type Props = ComponentProps<typeof Default>;
1110
<Default {...Astro.props} />
1211
{description && (
1312
<div class="container">
14-
<Book4Spark height="100%" width="100%" />
13+
<IconMaterialSymbolsBook4Spark height="100%" width="100%" />
1514
<p>{description}</p>
1615
</div>
1716
)}

0 commit comments

Comments
 (0)