feat: add links to docs and dotio

This commit is contained in:
2023-12-16 12:46:20 +01:00
parent 256daec412
commit ea3192d4e6
9 changed files with 39 additions and 150 deletions

2
src/env.d.ts vendored
View File

@@ -10,6 +10,8 @@ interface ImportMetaEnv {
readonly VITE_HOMEPAGE_URL: string
readonly VITE_BUGS_URL: string
readonly VITE_DOCS_URL: string
readonly VIET_LEARN_URL: string
}
interface ImportMeta {

View File

@@ -46,6 +46,16 @@
><span class="icon">bug_report</span> File an issue</a
>
</li>
<li>
<a href={import.meta.env.VITE_DOCS_URL} rel="noreferrer" target="_blank"
><span class="icon">description</span> Read the docs</a
>
</li>
<li>
<a href={import.meta.env.VITE_LEARN_URL} rel="noreferrer" target="_blank"
><span class="icon">school</span> Training</a
>
</li>
</ul>
<div>
{#if !$serialPort}

6
src/tools/icons-config.d.ts vendored Normal file
View File

@@ -0,0 +1,6 @@
export interface IconsConfig {
codePoints: Record<string, string>
inputPath: string
outputPath: string
icons: string[]
}

View File

@@ -16,11 +16,15 @@
import {openSync} from "fontkit"
import {exec} from "child_process"
import config from "../../icons.config.js"
import {statSync, existsSync} from "fs"
import {statSync} from "fs"
import {readFile} from "fs/promises"
import {glob} from "glob"
async function run(command: string[] | string): Promise<string> {
/**
* @param {string[] | string} command
* @returns {Promise<string>}
*/
async function run(command) {
const fullCommand = Array.isArray(command) ? command.join(" ") : command
console.log(`>> ${fullCommand}`)
@@ -51,7 +55,8 @@ const font = openSync(config.inputPath)
const glyphs = ["5f-7a", "30-39"]
for (const icon of icons) {
const iconGlyphs: Array<{id: string}> = font.layout(icon).glyphs
/** @type {Array<{id: string}>} */
const iconGlyphs = font.layout(icon).glyphs
if (iconGlyphs.length === 0) {
console.error(`${icon} not found in font. Typo?`)
process.exit(-1)
@@ -99,8 +104,9 @@ console.log(
/**
* Bytes to respective units
* @param {number} value
*/
function toByteUnit(value: number) {
function toByteUnit(value) {
if (value < 1024) {
return `${value}B`
} else if (value < 1024 * 1024) {