diff --git a/src/utils/generateTagIndex.ts b/src/utils/generateTagIndex.ts new file mode 100644 index 00000000..333c649e --- /dev/null +++ b/src/utils/generateTagIndex.ts @@ -0,0 +1,9 @@ +const NUM_TAG_COLORS = 16; + +const generateTagIndex = (tag: string) => { + const asciiList = tag.split('').map((c) => c.charCodeAt(0)); + const sum = asciiList.reduce((a, b) => a + b, 0); + return sum % NUM_TAG_COLORS; +}; + +export default generateTagIndex;