|
| 1 | +<template> |
| 2 | + <div class="p-8 space-y-6"> |
| 3 | + <h1 class="text-2xl font-bold">Commit to Emoji</h1> |
| 4 | + <div class="grid grid-cols-4 gap-6"> |
| 5 | + <div |
| 6 | + v-for="(emoji, index) in emojiResponses" |
| 7 | + :key="index" |
| 8 | + class=" |
| 9 | + flex items-center justify-center |
| 10 | + h-28 dark:bg-gray-100/5 bg-gray-200/50 rounded text-6xl hover:scale-110 hover:bg-gray-900/50 dark:hover:bg-[#cff2da]/80 |
| 11 | + transition-transform cursor-pointer focus:outline-none focus:ring-2 focus:ring-blue-500" |
| 12 | + role="button" |
| 13 | + tabindex="0" |
| 14 | + @click="$router.push(emojiMaintainers[index].path)" |
| 15 | + @keydown.enter="$router.push(emojiMaintainers[index].path)" |
| 16 | + @keydown.space.prevent="$router.push(emojiMaintainers[index].path)" |
| 17 | + > |
| 18 | + {{ emoji }} |
| 19 | + </div> |
| 20 | + </div> |
| 21 | + </div> |
| 22 | +</template> |
| 23 | + |
| 24 | +<script setup lang="ts"> |
| 25 | +import { ref, onMounted } from "vue"; |
| 26 | +import type { MaintainersCollectionItem } from "@nuxt/content"; |
| 27 | +
|
| 28 | +const { data: maintainers } = await useAsyncData("maintainers", () => { |
| 29 | + return queryCollection("maintainers").all(); |
| 30 | +}); |
| 31 | +
|
| 32 | +const emojiResponses = ref<string[]>([]); |
| 33 | +const emojiMaintainers = ref<MaintainersCollectionItem[]>([]); |
| 34 | +
|
| 35 | +onMounted(() => { |
| 36 | + if (!maintainers.value) return; |
| 37 | +
|
| 38 | + const segmenter = new Intl.Segmenter("en", { granularity: "grapheme" }); |
| 39 | +
|
| 40 | + maintainers.value.forEach((maintainer: MaintainersCollectionItem) => { |
| 41 | + const form = maintainer.body?.form || []; |
| 42 | +
|
| 43 | + const emojiAnswer = form.find((entry: any) => |
| 44 | + entry.question?.includes("one emoji"), |
| 45 | + ); |
| 46 | +
|
| 47 | + if (emojiAnswer?.response) { |
| 48 | + const segments = Array.from(segmenter.segment(emojiAnswer.response)); |
| 49 | + const firstEmoji = segments[0]?.segment; |
| 50 | +
|
| 51 | + if (firstEmoji) { |
| 52 | + emojiResponses.value.push(firstEmoji); |
| 53 | + emojiMaintainers.value.push(maintainer); |
| 54 | + } |
| 55 | + } |
| 56 | + }); |
| 57 | +}); |
| 58 | +</script> |
0 commit comments