@riebeckite/plugin-icons 0.0.0-stage → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +168 -2
- package/README_ja.md +169 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1735 -0
- package/dist/src/color.d.ts +3 -0
- package/dist/src/emoji.d.ts +2 -0
- package/dist/src/iconic.d.ts +13 -0
- package/dist/src/iconize.d.ts +12 -0
- package/dist/src/remark.d.ts +11 -0
- package/dist/src/render.d.ts +15 -0
- package/dist/src/resolve.d.ts +20 -0
- package/dist/src/settings.d.ts +29 -0
- package/dist/src/types.d.ts +132 -0
- package/package.json +61 -3
- package/style.css +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright Rerurate_514
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,169 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @riebeckite/plugin-icons
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<!-- Generated from docs/docs/plugins/icons.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
|
|
4
|
+
|
|
5
|
+
[日本語](./README_ja.md)
|
|
6
|
+
|
|
7
|
+
Reads the icons you already configured in Obsidian Iconize and Iconic and
|
|
8
|
+
renders them on the static site. Icons are resolved once at build time and
|
|
9
|
+
passed to navigation, folder pages, search, article headers, tag listings, and
|
|
10
|
+
property panels as structured data.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @riebeckite/plugin-icons
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { icons } from "@riebeckite/plugin-icons";
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
plugins: [icons()],
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
No configuration is required. The plugin looks for
|
|
29
|
+
`.obsidian/plugins/obsidian-icon-folder/data.json` and
|
|
30
|
+
`.obsidian/plugins/iconic/data.json` in the Obsidian vault. When the content
|
|
31
|
+
directory is a subdirectory of the vault, its vault-relative prefix is inferred
|
|
32
|
+
automatically.
|
|
33
|
+
|
|
34
|
+
## Where icons appear
|
|
35
|
+
|
|
36
|
+
- navigation items and folder-only navigation entries
|
|
37
|
+
- generated folder pages and their page/folder lists
|
|
38
|
+
- the article title, when the note has a file icon
|
|
39
|
+
- search results
|
|
40
|
+
- tags in the article metadata and taxonomy tag pages
|
|
41
|
+
- property keys in the properties panel
|
|
42
|
+
|
|
43
|
+
Inline icons in Markdown are rendered wherever prose is rendered: headings,
|
|
44
|
+
paragraphs, lists, tables, and blockquotes. Code blocks, inline code, links,
|
|
45
|
+
URLs, raw HTML, and escaped colons are left untouched.
|
|
46
|
+
|
|
47
|
+
## Iconize
|
|
48
|
+
|
|
49
|
+
Supported settings and data:
|
|
50
|
+
|
|
51
|
+
- file and folder icons keyed by vault-relative path
|
|
52
|
+
- custom rules with order, basename or full-path matching, color, and the
|
|
53
|
+
`everything` / `files` / `folders` scope
|
|
54
|
+
- frontmatter icons and colors, including custom field names
|
|
55
|
+
- inline icons using the configured identifier (default `:`)
|
|
56
|
+
- Lucide icons such as `LiRocket`
|
|
57
|
+
- folder-based custom icon packs under the configured icon packs directory
|
|
58
|
+
- per-icon colors, rule colors, and the global icon color
|
|
59
|
+
|
|
60
|
+
A direct path entry wins over a custom rule, matching Iconize. Rules are
|
|
61
|
+
evaluated in ascending `order`; invalid regular expressions fall back to a
|
|
62
|
+
substring match. Literal emoji values are rendered as emoji.
|
|
63
|
+
|
|
64
|
+
## Iconic
|
|
65
|
+
|
|
66
|
+
Supported settings and data:
|
|
67
|
+
|
|
68
|
+
- file and folder icons keyed by vault-relative path
|
|
69
|
+
- `fileRules` and `folderRules`
|
|
70
|
+
- rule icons and colors, including the nine named theme colors
|
|
71
|
+
- `tagIcons` and `propertyIcons`
|
|
72
|
+
- conditions for name, filename, extension, tree, path, tags, properties,
|
|
73
|
+
links, embeds, created, and modified
|
|
74
|
+
- `is`, `contains`, `startsWith`, `endsWith`, `matches`, `hasValue`,
|
|
75
|
+
`hasProperty`, boolean and numeric operators, array operators, `!` negation,
|
|
76
|
+
and `all` / `any` / `none` groups
|
|
77
|
+
|
|
78
|
+
Iconic rules are evaluated in array order and the first enabled match wins. A
|
|
79
|
+
matching rule overrides a manually assigned file icon, as it does in Obsidian.
|
|
80
|
+
|
|
81
|
+
## Inline icons
|
|
82
|
+
|
|
83
|
+
The default syntax is `:name:`.
|
|
84
|
+
|
|
85
|
+
- `:rocket:`, `:smile:`, `:warning:`, and `:book:` resolve to emoji.
|
|
86
|
+
- An unknown emoji name falls back to the Lucide icon with the same name.
|
|
87
|
+
- `:LiRocket:` resolves a Lucide icon directly.
|
|
88
|
+
- A custom pack prefix such as `:MyPackRocket:` resolves the pack icon.
|
|
89
|
+
- Unknown names stay as literal text.
|
|
90
|
+
|
|
91
|
+
Icons inherit the surrounding font size and color. When no color is configured
|
|
92
|
+
they use `currentColor`, so light and dark themes work without extra CSS. Icons
|
|
93
|
+
are decorative and marked `aria-hidden="true"` so screen readers do not
|
|
94
|
+
announce them twice.
|
|
95
|
+
|
|
96
|
+
## Precedence
|
|
97
|
+
|
|
98
|
+
When more than one source has an icon, the default order is:
|
|
99
|
+
|
|
100
|
+
1. explicit `overrides` option
|
|
101
|
+
2. note frontmatter
|
|
102
|
+
3. Iconic
|
|
103
|
+
4. Iconize
|
|
104
|
+
|
|
105
|
+
The order is configurable. Inside each source, the upstream rules still apply:
|
|
106
|
+
Iconize uses direct entry before custom rule, and Iconic uses the first matching
|
|
107
|
+
rule before the manual icon.
|
|
108
|
+
|
|
109
|
+
## Options
|
|
110
|
+
|
|
111
|
+
| Option | Type | Default | Description |
|
|
112
|
+
| --- | --- | --- | --- |
|
|
113
|
+
| `sources` | `("iconize" \| "iconic")[]` | both | Icon sources to read. |
|
|
114
|
+
| `inline` | `boolean` | `true` | Resolve inline icon syntax in Markdown. |
|
|
115
|
+
| `frontmatter` | `boolean` | `true` | Read icons from note frontmatter. |
|
|
116
|
+
| `colors` | `boolean` | `true` | Apply configured icon colors. |
|
|
117
|
+
| `precedence` | `("config" \| "frontmatter" \| "iconic" \| "iconize")[]` | `["config", "frontmatter", "iconic", "iconize"]` | Source order for a single icon. |
|
|
118
|
+
| `overrides` | `Record<string, string \| { icon: string; color?: string }>` | `{}` | Explicit icons keyed by vault path or slug. |
|
|
119
|
+
| `vaultRoot` | `string` | auto-detected | Obsidian vault root. |
|
|
120
|
+
| `vaultPrefix` | `string` | inferred | Vault-relative prefix of the content directory. |
|
|
121
|
+
| `iconize` | `{ enabled?, dataFile?, iconPacks? }` | auto | Iconize overrides. |
|
|
122
|
+
| `iconic` | `{ enabled?, dataFile? }` | auto | Iconic overrides. |
|
|
123
|
+
|
|
124
|
+
Example for a vault and site that live in separate repositories:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
icons({
|
|
128
|
+
vaultRoot: "../notes",
|
|
129
|
+
vaultPrefix: "content/",
|
|
130
|
+
iconize: { dataFile: "../notes/.obsidian/plugins/obsidian-icon-folder/data.json" },
|
|
131
|
+
iconic: { dataFile: "../notes/.obsidian/plugins/iconic/data.json" },
|
|
132
|
+
});
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
Explicit data files must stay inside the vault root (or the working directory
|
|
136
|
+
when no vault root is set).
|
|
137
|
+
|
|
138
|
+
## Supported icon packs
|
|
139
|
+
|
|
140
|
+
Lucide is read on demand from `lucide-static`; only icons that are actually
|
|
141
|
+
referenced are emitted. Folder-based Iconize packs are read from the configured
|
|
142
|
+
icon packs directory. Zip-only packs are not read; extract them into folders
|
|
143
|
+
under that directory. Iconize's `twemoji` emoji style is not bundled, so native
|
|
144
|
+
emoji are used instead.
|
|
145
|
+
|
|
146
|
+
## Unsupported and constrained behavior
|
|
147
|
+
|
|
148
|
+
- Iconic `clock`, `headings`, `bookmarks`, and now-relative date/time conditions
|
|
149
|
+
cannot be evaluated during a static build. They never match, and a diagnostic
|
|
150
|
+
explains why. Absolute date comparisons on `created` and `modified` work when
|
|
151
|
+
file metadata is available.
|
|
152
|
+
- Iconic emoji colors are not reproduced with CSS filters; emoji render in the
|
|
153
|
+
platform's native colors.
|
|
154
|
+
- Obsidian UI icons (ribbon, tabs, menus, bookmarks) are intentionally ignored.
|
|
155
|
+
- Icons for unpublished notes are not emitted into public HTML.
|
|
156
|
+
- A missing or malformed settings file is reported as a warning and never fails
|
|
157
|
+
the build.
|
|
158
|
+
|
|
159
|
+
## Security
|
|
160
|
+
|
|
161
|
+
The plugin reads only the known Obsidian settings files and the configured icon
|
|
162
|
+
packs directory. It does not execute plugin JavaScript, does not copy
|
|
163
|
+
`.obsidian` into the output, and does not scan the vault for arbitrary files.
|
|
164
|
+
Settings and pack paths are restricted to the vault root, symlinks are skipped,
|
|
165
|
+
and file sizes are capped.
|
|
166
|
+
|
|
167
|
+
Custom SVG and Lucide SVG pass through an allowlist sanitizer that removes
|
|
168
|
+
scripts, event handlers, styles, external references, and unsafe URL schemes
|
|
169
|
+
before any HTML is emitted. No client-side JavaScript renders icons.
|
package/README_ja.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# @riebeckite/plugin-icons
|
|
2
|
+
|
|
3
|
+
<!-- Generated from docs/docs/plugins/icons.ja.md. Edit the canonical documentation in docs/docs/plugins and run `pnpm docs:sync`. -->
|
|
4
|
+
|
|
5
|
+
[English](./README.md)
|
|
6
|
+
|
|
7
|
+
Obsidian の Iconize と Iconic で設定済みのアイコンを読み取り、静的サイトに
|
|
8
|
+
表示するプラグインです。アイコンはビルド時に一度だけ解決され、ナビゲーション、
|
|
9
|
+
フォルダページ、検索、記事タイトル、タグ一覧、プロパティパネルへ構造化データ
|
|
10
|
+
として渡されます。
|
|
11
|
+
|
|
12
|
+
## インストール
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pnpm add @riebeckite/plugin-icons
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## 使い方
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { icons } from "@riebeckite/plugin-icons";
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
plugins: [icons()],
|
|
25
|
+
};
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
設定は不要です。Obsidian vault の
|
|
29
|
+
`.obsidian/plugins/obsidian-icon-folder/data.json` と
|
|
30
|
+
`.obsidian/plugins/iconic/data.json` を探します。コンテンツディレクトリが
|
|
31
|
+
vault のサブディレクトリにある場合は、vault からの相対パスも自動で推定します。
|
|
32
|
+
|
|
33
|
+
## アイコンの表示箇所
|
|
34
|
+
|
|
35
|
+
- ナビゲーション項目と、ページを持たないフォルダ項目
|
|
36
|
+
- 自動生成されるフォルダページと、そのページ・フォルダ一覧
|
|
37
|
+
- ノートにファイルアイコンがある場合の記事タイトル
|
|
38
|
+
- 検索結果
|
|
39
|
+
- 記事メタデータのタグと、タクソノミーのタグページ
|
|
40
|
+
- プロパティパネルのプロパティ名
|
|
41
|
+
|
|
42
|
+
Markdown のインラインアイコンは、見出し、段落、リスト、テーブル、引用内で
|
|
43
|
+
表示されます。コードブロック、インラインコード、リンク、URL、生の HTML、
|
|
44
|
+
エスケープしたコロンは変更しません。
|
|
45
|
+
|
|
46
|
+
## Iconize
|
|
47
|
+
|
|
48
|
+
次の設定とデータに対応します。
|
|
49
|
+
|
|
50
|
+
- vault 相対パスをキーにしたファイル・フォルダアイコン
|
|
51
|
+
- 順序、ファイル名またはフルパス一致、色、`everything` / `files` /
|
|
52
|
+
`folders` の対象範囲を持つカスタムルール
|
|
53
|
+
- frontmatter のアイコンと色(フィールド名の変更を含む)
|
|
54
|
+
- 設定した識別子(既定は `:`)によるインラインアイコン
|
|
55
|
+
- `LiRocket` のような Lucide アイコン
|
|
56
|
+
- 設定したアイコンパックディレクトリ配下のフォルダ型カスタムパック
|
|
57
|
+
- アイコン単位の色、ルールの色、グローバルなアイコン色
|
|
58
|
+
|
|
59
|
+
パスに直接設定したアイコンはカスタムルールより優先されます。これは Iconize
|
|
60
|
+
と同じ挙動です。ルールは `order` の昇順で評価し、正規表現が不正な場合は部分
|
|
61
|
+
文字列一致にフォールバックします。値が絵文字そのものであれば絵文字として
|
|
62
|
+
表示します。
|
|
63
|
+
|
|
64
|
+
## Iconic
|
|
65
|
+
|
|
66
|
+
次の設定とデータに対応します。
|
|
67
|
+
|
|
68
|
+
- vault 相対パスをキーにしたファイル・フォルダアイコン
|
|
69
|
+
- `fileRules` と `folderRules`
|
|
70
|
+
- ルールのアイコンと色(9 種類の名前付きテーマ色を含む)
|
|
71
|
+
- `tagIcons` と `propertyIcons`
|
|
72
|
+
- 名前、ファイル名、拡張子、ツリー、パス、タグ、プロパティ、リンク、
|
|
73
|
+
埋め込み、作成日時、更新日時を対象にした条件
|
|
74
|
+
- `is`、`contains`、`startsWith`、`endsWith`、`matches`、`hasValue`、
|
|
75
|
+
`hasProperty`、真偽値・数値・配列の演算子、`!` による否定、
|
|
76
|
+
`all` / `any` / `none` の条件グループ
|
|
77
|
+
|
|
78
|
+
Iconic のルールは配列順に評価し、有効な最初の一致を採用します。一致した
|
|
79
|
+
ルールは手動設定のファイルアイコンを上書きします。Obsidian と同じ挙動です。
|
|
80
|
+
|
|
81
|
+
## インラインアイコン
|
|
82
|
+
|
|
83
|
+
既定の構文は `:name:` です。
|
|
84
|
+
|
|
85
|
+
- `:rocket:`、`:smile:`、`:warning:`、`:book:` は絵文字になります。
|
|
86
|
+
- 絵文字名が見つからない場合は、同じ名前の Lucide アイコンを使います。
|
|
87
|
+
- `:LiRocket:` は Lucide アイコンを直接指定します。
|
|
88
|
+
- `:MyPackRocket:` のようにパック名を付けると、カスタムパックのアイコンを
|
|
89
|
+
使います。
|
|
90
|
+
- 解決できない名前はそのままの文字列で残します。
|
|
91
|
+
|
|
92
|
+
アイコンは周囲のフォントサイズと色を継承します。色が未設定のときは
|
|
93
|
+
`currentColor` を使うため、ライトテーマとダークテーマの両方で追加の CSS は
|
|
94
|
+
不要です。アイコンは装飾として `aria-hidden="true"` を付け、スクリーン
|
|
95
|
+
リーダーが二重に読み上げないようにしています。
|
|
96
|
+
|
|
97
|
+
## 優先順位
|
|
98
|
+
|
|
99
|
+
複数のソースにアイコンがある場合、既定の順序は次のとおりです。
|
|
100
|
+
|
|
101
|
+
1. `overrides` オプション
|
|
102
|
+
2. ノートの frontmatter
|
|
103
|
+
3. Iconic
|
|
104
|
+
4. Iconize
|
|
105
|
+
|
|
106
|
+
順序は変更できます。ソース内部では上流の規則を維持します。Iconize は直接
|
|
107
|
+
設定をカスタムルールより優先し、Iconic は最初に一致したルールを手動設定より
|
|
108
|
+
優先します。
|
|
109
|
+
|
|
110
|
+
## オプション
|
|
111
|
+
|
|
112
|
+
| オプション | 型 | 既定値 | 説明 |
|
|
113
|
+
| --- | --- | --- | --- |
|
|
114
|
+
| `sources` | `("iconize" \| "iconic")[]` | 両方 | 読み取るアイコンソース。 |
|
|
115
|
+
| `inline` | `boolean` | `true` | Markdown のインラインアイコンを解決する。 |
|
|
116
|
+
| `frontmatter` | `boolean` | `true` | frontmatter のアイコンを読む。 |
|
|
117
|
+
| `colors` | `boolean` | `true` | 設定されたアイコンの色を適用する。 |
|
|
118
|
+
| `precedence` | `("config" \| "frontmatter" \| "iconic" \| "iconize")[]` | `["config", "frontmatter", "iconic", "iconize"]` | 1 つのアイコンを決めるときのソース順。 |
|
|
119
|
+
| `overrides` | `Record<string, string \| { icon: string; color?: string }>` | `{}` | vault パスまたは slug をキーにした明示的なアイコン。 |
|
|
120
|
+
| `vaultRoot` | `string` | 自動検出 | Obsidian vault のルート。 |
|
|
121
|
+
| `vaultPrefix` | `string` | 自動推定 | コンテンツディレクトリの vault 相対プレフィックス。 |
|
|
122
|
+
| `iconize` | `{ enabled?, dataFile?, iconPacks? }` | 自動 | Iconize の上書き設定。 |
|
|
123
|
+
| `iconic` | `{ enabled?, dataFile? }` | 自動 | Iconic の上書き設定。 |
|
|
124
|
+
|
|
125
|
+
vault とサイトが別リポジトリにある場合の例です。
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
icons({
|
|
129
|
+
vaultRoot: "../notes",
|
|
130
|
+
vaultPrefix: "content/",
|
|
131
|
+
iconize: { dataFile: "../notes/.obsidian/plugins/obsidian-icon-folder/data.json" },
|
|
132
|
+
iconic: { dataFile: "../notes/.obsidian/plugins/iconic/data.json" },
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
明示したデータファイルは vault ルート(vault ルートを指定しない場合は作業
|
|
137
|
+
ディレクトリ)の内側になければなりません。
|
|
138
|
+
|
|
139
|
+
## 対応アイコンパック
|
|
140
|
+
|
|
141
|
+
Lucide は `lucide-static` から必要なときだけ読み込み、実際に参照された
|
|
142
|
+
アイコンだけを出力します。フォルダ型の Iconize パックは、設定されたアイコン
|
|
143
|
+
パックディレクトリから読み込みます。Zip のみのパックには対応しません。その
|
|
144
|
+
場合はディレクトリへ展開してください。Iconize の `twemoji` は同梱していない
|
|
145
|
+
ため、ネイティブ絵文字で表示します。
|
|
146
|
+
|
|
147
|
+
## 未対応・制約
|
|
148
|
+
|
|
149
|
+
- Iconic の `clock`、`headings`、`bookmarks`、現在時刻に依存する日時条件は
|
|
150
|
+
静的ビルドでは評価できません。一致しないものとして扱い、理由を診断に
|
|
151
|
+
出力します。ファイルメタデータがある場合、`created` と `modified` の
|
|
152
|
+
絶対日時比較は利用できます。
|
|
153
|
+
- Iconic の絵文字色は CSS フィルターで再現しません。絵文字はプラット
|
|
154
|
+
フォーム標準の色で表示されます。
|
|
155
|
+
- Obsidian の UI アイコン(リボン、タブ、メニュー、ブックマーク)は対象外
|
|
156
|
+
です。
|
|
157
|
+
- 非公開ノートのアイコンは公開 HTML に出力しません。
|
|
158
|
+
- 設定ファイルがない場合や壊れている場合は警告を出し、ビルドは継続します。
|
|
159
|
+
|
|
160
|
+
## セキュリティ
|
|
161
|
+
|
|
162
|
+
既知の Obsidian 設定ファイルと、設定されたアイコンパックディレクトリだけを
|
|
163
|
+
読みます。プラグインの JavaScript は実行せず、`.obsidian` を出力へコピーせず、
|
|
164
|
+
vault 全体を任意に走査しません。設定とパックのパスは vault ルート内に制限し、
|
|
165
|
+
シンボリックリンクを除外し、ファイルサイズに上限を設けています。
|
|
166
|
+
|
|
167
|
+
カスタム SVG と Lucide SVG は許可リスト方式のサニタイザを通し、スクリプト、
|
|
168
|
+
イベントハンドラ、スタイル、外部参照、危険な URL スキームを除去してから
|
|
169
|
+
HTML を出力します。アイコンの描画にクライアント側 JavaScript は使いません。
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IconsOptions } from "./src/types.js";
|
|
2
|
+
export type { IconOverride, IconPrecedence, IconSource, IconsOptions, ResolvedIconsOptions, } from "./src/types.js";
|
|
3
|
+
export declare function icons(options?: IconsOptions): import("@riebeckite/core").RiebeckitePlugin<IconsOptions>;
|