feat: generated ascii art headers
parent
5f3df33dd4
commit
458cdef53c
@ -1,29 +0,0 @@
|
||||
export default {
|
||||
index: [
|
||||
" ________ __ ",
|
||||
"| | | |.-----.| |.----.-----.--------.-----.",
|
||||
"| | | || -__|| || __| _ | | -__|",
|
||||
"|________||_____||__||____|_____|__|__|__|_____|",
|
||||
],
|
||||
|
||||
aboutMe: [
|
||||
" _______ __ __ _______ ",
|
||||
"| _ | |--.-----.--.--.| |_ | | |.-----.",
|
||||
"| | _ | _ | | || _| | || -__|",
|
||||
"|___|___|_____|_____|_____||____| |__|_|__||_____|",
|
||||
],
|
||||
|
||||
resume: [
|
||||
" ______ ",
|
||||
"| __ \.-----.-----.--.--.--------.-----.",
|
||||
"| <| -__|__ --| | | | -__|",
|
||||
"|___|__||_____|_____|_____|__|__|__|_____|",
|
||||
],
|
||||
|
||||
not_found: [
|
||||
" _____ ______ _____ ",
|
||||
"| | || | | | ",
|
||||
"|__ | -- |__ |",
|
||||
" |__||______| |__| ",
|
||||
]
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
import { FLFParser, FontLayoutManager } from '@figlet-ts/lib'
|
||||
import * as fonts from '@figlet-ts/fonts/dist/fonts'
|
||||
|
||||
function findFont(needle: string) {
|
||||
needle = needle.toLowerCase()
|
||||
for (let categoryName in fonts) {
|
||||
const category = fonts[categoryName]
|
||||
for (let name in category) {
|
||||
if (name.toLowerCase() === needle) return category[name]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getFont(name: string) {
|
||||
const font = findFont(name)
|
||||
if (!font) throw new Error(`Cannot find font "${name}"!`)
|
||||
|
||||
const flf = FLFParser.parse(atob(font._contents))
|
||||
return flf.font
|
||||
}
|
||||
|
||||
export default function useFiglet() {
|
||||
const flm = new FontLayoutManager()
|
||||
|
||||
function render(text: string, fontName: string) {
|
||||
const figFont = getFont(fontName)
|
||||
const output = flm.renderText(text, figFont)
|
||||
return output
|
||||
}
|
||||
return { render }
|
||||
}
|
Loading…
Reference in New Issue