Skip to content

Commit

Permalink
(docs) add cal command
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Oct 27, 2024
1 parent 8663f45 commit 6e675ca
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"@fingerprintjs/fingerprintjs": "^3.4.2",
"@mdx-js/react": "^3.0.0",
"@supabase/supabase-js": "^2.45.6",
"ascii-calendar": "^0.2.2",
"clsx": "^2.0.0",
"cowsay": "^1.6.0",
"figlet": "^1.7.0",
Expand Down
19 changes: 19 additions & 0 deletions docs/src/components/Terminal/cal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { JQueryTerminal } from 'jquery.terminal';

import cal from 'ascii-calendar';

function calendar(callback: (day: string) => string) {
var today = new Date().getDate();
var padded_day = today.toString().padStart(2, ' ');
// regex that match day but not inside the year
var re = new RegExp(`(?<!20)(${padded_day})`);
return cal().replace(re, function(_, g) {
return callback(g);
})
}

export default function jargon(this: JQueryTerminal) {
return calendar(function(day: string) {
return `[[;#000;#ccc;;]${day}]`;
});
};
2 changes: 2 additions & 0 deletions docs/src/components/Terminal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import cowsay from './cowsay';
import fortune from './fortune';
import figlet from './figlet';
import jargon from './jargon';
import cal from './cal';

const languages = [
'markdown',
Expand Down Expand Up @@ -83,6 +84,7 @@ export default function Interpreter(): JSX.Element {
fortune,
figlet,
jargon,
cal,
theme,
record,
size(num: string) {
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/Terminal/lolcat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { delay } from '@site/src/constants';
export default async function command(this: JQueryTerminal, ...args: string[]) {
const $ = (globalThis as any).$ as JQueryStatic;
const { a, animation } = $.terminal.parse_options(args);
let input = await this.read('');
let input = $.terminal.strip(await this.read(''));
const options = a || animation ? {typing: true, delay } : undefined;
this.echo(rainbow(input), options);
}
Expand Down

0 comments on commit 6e675ca

Please sign in to comment.