feat: add Journal index page

This commit is contained in:
Stefan Imhoff
2023-06-08 15:17:07 +02:00
parent 251e3c5300
commit 2c8d141002
8 changed files with 149 additions and 25 deletions

View File

@@ -1,4 +1,5 @@
export * from './date';
export * from './pick-two-random-colors';
export * from './remark-reading-time';
export * from './sort-by-date';
export * from './sort-by-sortkey';

View File

@@ -0,0 +1,18 @@
import colorsJson from '../data/colors-japan.json';
interface Color {
id: string;
name: string;
description: string;
color: string;
}
export const pickTwoRandomColors = (): [string, string] => {
const colors: Color[] = colorsJson;
const randomIndex1 = Math.floor(Math.random() * colors.length);
let randomIndex2 = Math.floor(Math.random() * colors.length);
while (randomIndex2 === randomIndex1) {
randomIndex2 = Math.floor(Math.random() * colors.length);
}
return [colors[randomIndex1].color, colors[randomIndex2].color];
};