Skip to content

Commit 805ea80

Browse files
committed
add search function, refactor
1 parent 12f9c2b commit 805ea80

18 files changed

+453
-49
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"markdown-it": "^13.0.2",
2222
"markdown-it-anchor": "^9.0.1",
2323
"markdown-it-named-code-blocks": "^0.2.0",
24+
"minisearch": "^7.1.0",
2425
"pinia": "^2.1.6",
2526
"vue": "^3.3.4",
2627
"vue-router": "^4.2.5"

src/App.vue

-2
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,3 @@ import { RouterView } from 'vue-router'
55
<template>
66
<router-view />
77
</template>
8-
9-
<style scoped></style>

src/assets/main.css

+6
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ body {
4848
background: #1e1e1e;
4949
}
5050

51+
input {
52+
background: none;
53+
outline: none;
54+
}
55+
5156
.dotted-line-vert {
5257
width: 1.5px;
5358
background-image: linear-gradient(to bottom, #525252 33%, rgba(82, 82, 82, 0) 0%);
@@ -62,6 +67,7 @@ body {
6267

6368
.fade-enter-active,
6469
.fade-leave-active {
70+
transition: opacity 300ms;
6571
opacity: 1;
6672
}
6773

src/components/ChalInfoCard.vue

+4-17
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,11 @@
11
<script setup lang="ts">
2-
import type { ChalInfo } from '@/types/ChalInfo'
2+
import type { ChalInfo, ChalCat } from '@/types/ChalInfo'
33
import MaterialIcon from './MaterialIcon.vue'
44
import MarkdownIt from 'markdown-it'
5+
import { catIcons } from '@/data/catIcons'
56
67
const { info } = defineProps<{ info: ChalInfo }>()
78
8-
const catIcons: { [cat: string]: string } = {
9-
web: 'language',
10-
pwn: 'bug_report',
11-
rev: 'keyboard_double_arrow_left',
12-
misc: 'help',
13-
forensics: 'quick_reference_all',
14-
crypto: 'key',
15-
mobile: 'phone_android',
16-
cloud: 'cloud',
17-
osint: 'visibility',
18-
blockchain: 'currency_bitcoin',
19-
hardware: 'memory'
20-
}
21-
229
const mdIt = new MarkdownIt()
2310
const descriptionRendered = mdIt.render(info.description)
2411
@@ -31,7 +18,7 @@ function downloadAll() {
3118

3219
<template>
3320
<div class="w-full flex flex-col items-start">
34-
<span class="text-2xl opacity-40 mb-1">{{ info.datePosted }}</span>
21+
<span class="text-xl opacity-40 mb-1">{{ info.datePosted }}</span>
3522
<h1 class="mb-7">{{ info.title }}</h1>
3623
<div class="markdown mb-7 flex flex-col gap-y-3" v-html="descriptionRendered"></div>
3724
<div class="flex flex-wrap gap-3">
@@ -40,7 +27,7 @@ function downloadAll() {
4027
:key="i"
4128
class="h-9 bg-white rounded-full flex items-center"
4229
>
43-
<material-icon sm :name="catIcons[cat]!" class="ml-3 mr-2 text-black" />
30+
<material-icon sm :name="catIcons[cat as ChalCat]!" class="ml-3 mr-2 text-black" />
4431
<span class="mr-4 text-black font-semibold">{{ cat }}</span>
4532
</div>
4633
<div class="h-9 bg-almost-black rounded-full px-5 flex items-center">

src/components/WriteupsTopBar.vue

+8-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import MenuButton from './MenuButton.vue'
55
import WriteupsList from './WriteupsList.vue'
66
import MaterialIcon from './MaterialIcon.vue'
77
import GithubIcon from './icons/GithubIcon.vue'
8+
import { useSearchModalStore } from '@/stores/searchModal'
89
910
let prevScrollOffset: number
1011
1112
const opened = ref(false)
1213
const showTopBar = ref(true)
14+
const searchModal = useSearchModalStore()
1315
1416
watch(useRoute(), () => {
1517
opened.value = false
@@ -44,9 +46,12 @@ nextTick(() => {
4446
/>
4547
<span class="text-xl font-semibold">Jia Jie's writeups</span>
4648
<div class="flex-1"></div>
47-
<!-- <button class="w-10 h-10 rounded-full grid place-items-center">
48-
<material-icon name="search" />
49-
</button> -->
49+
<button
50+
class="group w-10 h-10 rounded-full grid place-items-center"
51+
@click="searchModal.open()"
52+
>
53+
<material-icon name="search" class="transition-colors group-hover:text-primary" />
54+
</button>
5055
<a
5156
href="https://github.com/mkofdwu/ctf-writeups"
5257
target="_blank"

src/components/modals/FilterByCat.vue

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<script setup lang="ts">
2+
import MaterialIcon from '../MaterialIcon.vue'
3+
import { catIcons } from '@/data/catIcons'
4+
import type { ChalCat } from '@/types/ChalInfo'
5+
6+
defineProps<{ selectedCats: ChalCat[] }>()
7+
defineEmits(['toggleSelectCat'])
8+
</script>
9+
10+
<template>
11+
<div class="px-6 pt-5">
12+
<span class="block opacity-60 mb-4">Filter by category</span>
13+
<div class="flex flex-wrap gap-3">
14+
<button
15+
v-for="[cat, icon] in Object.entries(catIcons)"
16+
:key="cat"
17+
class="h-9 border transition-colors rounded-full flex items-center pl-3 pr-4"
18+
:class="
19+
selectedCats.includes(cat as ChalCat)
20+
? 'bg-primary border-primary text-black'
21+
: 'border-[#525252]'
22+
"
23+
@click="$emit('toggleSelectCat', cat as ChalCat)"
24+
>
25+
<material-icon
26+
sm
27+
:name="icon"
28+
class="transition-colors mr-3"
29+
:class="selectedCats.includes(cat as ChalCat) ? 'text-black' : ''"
30+
/>
31+
{{ cat }}
32+
</button>
33+
</div>
34+
</div>
35+
</template>

src/components/modals/FilterByCtf.vue

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<script setup lang="ts">
2+
import { sidebarList } from '@/data/sidebarList'
3+
4+
defineProps<{ selectedCtfs: string[] }>()
5+
defineEmits(['toggleSelectCtf'])
6+
</script>
7+
8+
<template>
9+
<div class="px-6 pt-5 pb-6">
10+
<span class="block opacity-60 mb-4">Filter by CTF</span>
11+
<div class="flex flex-wrap gap-3">
12+
<button
13+
v-for="{ name } in sidebarList"
14+
:key="name"
15+
class="h-9 border transition-colors rounded-full flex items-center px-4"
16+
:class="
17+
selectedCtfs.includes(name) ? 'bg-primary border-primary text-black' : 'border-[#525252]'
18+
"
19+
@click="$emit('toggleSelectCtf', name)"
20+
>
21+
{{ name }}
22+
</button>
23+
</div>
24+
</div>
25+
</template>

0 commit comments

Comments
 (0)