mirror of
https://github.com/jaronpate/folio.git
synced 2026-10-18 17:06:56 +00:00
Fixed up the curl response a little
This commit is contained in:
@@ -110,7 +110,6 @@ onMounted(() => {
|
|||||||
>
|
>
|
||||||
GitHub
|
GitHub
|
||||||
</a>
|
</a>
|
||||||
<a href="/resume" class="basic-link">Resume</a>
|
|
||||||
<NuxtLink to="/writing" class="basic-link">
|
<NuxtLink to="/writing" class="basic-link">
|
||||||
Writing
|
Writing
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
|
|||||||
+104
-22
@@ -1,5 +1,61 @@
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
|
|
||||||
|
function box(def: {
|
||||||
|
title: string;
|
||||||
|
text: string;
|
||||||
|
footer?: [string, string];
|
||||||
|
padding?: [number, number];
|
||||||
|
}) {
|
||||||
|
const [LINE_WIDTH_PADDING, LINE_HEIGHT_PADDING] = def.padding ?? [0, 0];
|
||||||
|
const lineHeight = def.text.split('\n').length;
|
||||||
|
const lineWidth = def.text
|
||||||
|
.split('\n')
|
||||||
|
.reduce((agg, cur) => Math.max(agg, cur.length), 0);
|
||||||
|
|
||||||
|
let rendered =
|
||||||
|
chalk.dim(`${GLYPHS.BOX.ROUND.TOP_LEFT}${GLYPHS.BOX.ROUND.XEDGE}`) +
|
||||||
|
chalk.reset(` ${def.title} `) +
|
||||||
|
chalk.dim(
|
||||||
|
`${GLYPHS.BOX.ROUND.XEDGE.repeat(lineWidth - def.title.length - 3 + LINE_WIDTH_PADDING * 2)}${GLYPHS.BOX.ROUND.TOP_RIGHT}\n`,
|
||||||
|
);
|
||||||
|
rendered += (
|
||||||
|
chalk.dim(GLYPHS.BOX.ROUND.YEDGE) +
|
||||||
|
`${' '.repeat(LINE_WIDTH_PADDING)}${' '.repeat(lineWidth)}${' '.repeat(LINE_WIDTH_PADDING)}` +
|
||||||
|
chalk.dim(GLYPHS.BOX.ROUND.YEDGE) +
|
||||||
|
'\n'
|
||||||
|
).repeat(LINE_HEIGHT_PADDING);
|
||||||
|
|
||||||
|
for (const line of def.text.split('\n')) {
|
||||||
|
const padding = lineWidth - line.length;
|
||||||
|
rendered +=
|
||||||
|
chalk.dim(GLYPHS.BOX.ROUND.YEDGE) +
|
||||||
|
`${' '.repeat(LINE_WIDTH_PADDING)}${line}${' '.repeat(padding)}${' '.repeat(LINE_WIDTH_PADDING)}` +
|
||||||
|
chalk.dim(GLYPHS.BOX.ROUND.YEDGE) +
|
||||||
|
'\n';
|
||||||
|
}
|
||||||
|
|
||||||
|
rendered += (
|
||||||
|
chalk.dim(GLYPHS.BOX.ROUND.YEDGE) +
|
||||||
|
`${' '.repeat(LINE_WIDTH_PADDING)}${' '.repeat(lineWidth)}${' '.repeat(LINE_WIDTH_PADDING)}` +
|
||||||
|
chalk.dim(GLYPHS.BOX.ROUND.YEDGE) +
|
||||||
|
'\n'
|
||||||
|
).repeat(LINE_HEIGHT_PADDING);
|
||||||
|
rendered += chalk.dim(
|
||||||
|
`${GLYPHS.BOX.ROUND.BOTTOM_LEFT}${GLYPHS.BOX.ROUND.XEDGE.repeat(lineWidth + LINE_WIDTH_PADDING * 2)}${GLYPHS.BOX.ROUND.BOTTOM_RIGHT}`,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (def.footer) {
|
||||||
|
rendered += '\n\n';
|
||||||
|
const [left, right] = def.footer;
|
||||||
|
const padding = lineWidth - left.length - right.length;
|
||||||
|
rendered += chalk.dim(
|
||||||
|
`${' '.repeat(LINE_WIDTH_PADDING)} ${left}${' '.repeat(padding)}${right} ${' '.repeat(LINE_WIDTH_PADDING)}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rendered;
|
||||||
|
}
|
||||||
|
|
||||||
export default defineEventHandler(async (event) => {
|
export default defineEventHandler(async (event) => {
|
||||||
const userAgent = getRequestHeader(event, 'user-agent') || '';
|
const userAgent = getRequestHeader(event, 'user-agent') || '';
|
||||||
|
|
||||||
@@ -12,30 +68,56 @@ export default defineEventHandler(async (event) => {
|
|||||||
'content-type',
|
'content-type',
|
||||||
'text/plain; charset=utf-8',
|
'text/plain; charset=utf-8',
|
||||||
);
|
);
|
||||||
const padding = chalk.reset(' ');
|
let res = '\n';
|
||||||
return (
|
|
||||||
chalk.bgGray(`\
|
|
||||||
|
|
||||||
${padding}░█░█░█▀▀░█░░░█░░░█▀█░░░░░░░▀█▀░▀░█▄█░░░▀▀█░█▀█░█▀▄░█▀█░█▀█
|
res += `\
|
||||||
${padding}░█▀█░█▀▀░█░░░█░░░█░█░░░░░░░░█░░░░█░█░░░░░█░█▀█░█▀▄░█░█░█░█
|
░█░█░█▀▀░█░░░█░░░█▀█░░░░░░░▀█▀░▀░█▄█░░░▀▀█░█▀█░█▀▄░█▀█░█▀█
|
||||||
${padding}░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▄▀░░░░▀▀▀░░░▀░▀░░░▀▀░░▀░▀░▀░▀░▀▀▀░▀░▀
|
░█▀█░█▀▀░█░░░█░░░█░█░░░░░░░░█░░░░█░█░░░░░█░█▀█░█▀▄░█░█░█░█
|
||||||
${padding}
|
░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀▀▀░▄▀░░░░▀▀▀░░░▀░▀░░░▀▀░░▀░▀░▀░▀░▀▀▀░▀░▀\n`;
|
||||||
${padding}┌ About ─────────────────────────────────────────────────────────────────────┐
|
res += '\n';
|
||||||
${padding}│ │
|
res += box({
|
||||||
${padding}│ I build things to solve problems from the ground up. │
|
title: 'About',
|
||||||
${padding}│ │
|
text: `\
|
||||||
${padding}│ I left school and my job at Chick-fil-A in 2022 to write code full time. │
|
I build things to solve problems from the ground up.
|
||||||
${padding}│ It's definitely one of the best decisions I've ever made. │
|
|
||||||
${padding}│ I've learned a lot since then and still have so much more to learn. │
|
I left school and my job at Chick-fil-A in 2022 to write code full time.
|
||||||
${padding}│ │
|
It's definitely one of the best decisions I've ever made.
|
||||||
${padding}│ If you want to build something cool or connect hit me up │
|
I've learned a lot since then and still have so much more to learn.
|
||||||
${padding}│ we'll grab a coffee or beer in you're in Austin! │
|
|
||||||
${padding}│ │
|
If you want to build something cool or connect hit me up
|
||||||
${padding}└────────────────────────────────────────────────────────────────────────────┘
|
we'll grab a coffee or beer in you're in Austin! 🤠🦇`,
|
||||||
${padding}
|
footer: ['Austin, TX', 'yo@jp.wtf'],
|
||||||
${padding} Austin, TX yo@jp.wtf
|
padding: [2, 1],
|
||||||
`) + '\n'
|
});
|
||||||
|
const padding = chalk.reset(' ');
|
||||||
|
|
||||||
|
return (
|
||||||
|
res
|
||||||
|
.split('\n')
|
||||||
|
.map((l) => padding + l)
|
||||||
|
.join('\n') + '\n'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const GLYPHS = {
|
||||||
|
BOX: {
|
||||||
|
DEFAULT: {
|
||||||
|
TOP_LEFT: '┌',
|
||||||
|
TOP_RIGHT: '┐',
|
||||||
|
BOTTOM_LEFT: '└',
|
||||||
|
BOTTOM_RIGHT: '┘',
|
||||||
|
XEDGE: '─',
|
||||||
|
YEDGE: '│',
|
||||||
|
},
|
||||||
|
ROUND: {
|
||||||
|
TOP_LEFT: '╭',
|
||||||
|
TOP_RIGHT: '╮',
|
||||||
|
BOTTOM_LEFT: '╰',
|
||||||
|
BOTTOM_RIGHT: '╯',
|
||||||
|
XEDGE: '─',
|
||||||
|
YEDGE: '│',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user