-
-
Notifications
You must be signed in to change notification settings - Fork 562
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: use seti ui repo to generate file icons (#2648)
- Loading branch information
Showing
3 changed files
with
71 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
import { writeDefinitionsAndSVGs } from './utils/file'; | ||
import { getIconSvgPaths } from './utils/font'; | ||
import { fetchFont, fetchMapping, parseMapping } from './utils/seti'; | ||
import { deleteRepo, parseMapping, setupRepo } from './utils/seti'; | ||
|
||
/** | ||
* Script generating definitions used by the Starlight `<FileTree>` component and associated SVGs. | ||
* | ||
* To do so, it fetches the Seti UI icon mapping file and font from GitHub, parses the mapping to | ||
* generate the definitions and a list of icons to extract as SVGs, and finally extracts the SVGs | ||
* from the font and writes the definitions and SVGs to the Starlight package in a file ready to be | ||
* consumed by Starlight. | ||
* To do so, it clones the Seti UI repository, installs dependencies, generates icons, parses the | ||
* mapping to generate the definitions and a list of icons to extract as SVGs, and finally extracts | ||
* the SVGs from the font and writes the definitions and SVGs to the Starlight package in a file | ||
* ready to be consumed by Starlight. | ||
* | ||
* @see {@link file://./config.ts} for the configuration used by this script. | ||
* @see {@link file://../starlight/user-components/file-tree-icons.ts} for the generated file. | ||
* @see {@link https://opentype.js.org/glyph-inspector.html} for a font glyph inspector. | ||
*/ | ||
|
||
const mapping = await fetchMapping(); | ||
const { definitions, icons } = parseMapping(mapping); | ||
const repoPath = await setupRepo(); | ||
|
||
const font = await fetchFont(); | ||
const svgPaths = getIconSvgPaths(icons, definitions, font); | ||
try { | ||
const { definitions, icons } = await parseMapping(repoPath); | ||
|
||
await writeDefinitionsAndSVGs(definitions, svgPaths); | ||
const svgPaths = await getIconSvgPaths(repoPath, icons, definitions); | ||
|
||
await writeDefinitionsAndSVGs(definitions, svgPaths); | ||
} finally { | ||
await deleteRepo(repoPath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters