Skip to content

Commit 7f9cbc1

Browse files
committed
Add vuetify and WIP sorting UI
1 parent cf0a572 commit 7f9cbc1

File tree

4 files changed

+76
-15
lines changed

4 files changed

+76
-15
lines changed

.vitepress/config.mts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export default defineConfig({
2323
generateMembersPlugin(),
2424
generatePublicationsPlugin(),
2525
generateProjectsPlugin(),
26-
]
27-
}
26+
],
27+
ssr: {
28+
noExternal: [/\.css$/, /\?vue&type=style/, /^vuetify/],
29+
}
30+
},
2831
})

.vitepress/theme/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import DefaultTheme from 'vitepress/theme'
22
import './custom.css'
3+
import 'vuetify/styles'
4+
import '@mdi/font/css/materialdesignicons.css'
5+
import * as components from 'vuetify/components'
6+
import * as directives from 'vuetify/directives'
7+
import { createVuetify } from 'vuetify'
8+
9+
const vuetify = createVuetify({ components, directives })
310

411
// Dynamically import all Vue components from the layouts directory
512
const layouts = import.meta.glob('../../layouts/*.vue')
@@ -8,6 +15,9 @@ export default {
815
Layout: DefaultTheme.Layout,
916
extends: DefaultTheme,
1017
enhanceApp({ app }) {
18+
// Use Vuetify
19+
app.use(vuetify)
20+
1121
// Register each layout component
1222
for (const path in layouts) {
1323
layouts[path]().then((module) => {

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"devDependencies": {
3+
"@mdi/font": "^7.4.47",
34
"ts-node": "^10.9.2",
45
"vite": "^5.4.8",
56
"vitepress": "^1.4.0",
@@ -11,6 +12,7 @@
1112
"preview": "vitepress build && vitepress preview"
1213
},
1314
"dependencies": {
14-
"front-matter": "^4.0.2"
15+
"front-matter": "^4.0.2",
16+
"vuetify": "^3.7.6"
1517
}
1618
}

pages/publications.md

Lines changed: 58 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ import { ref, onMounted, computed } from 'vue'
77

88
const SORT_OPTIONS = {
99
sort: ["year", "author", "title", "conference"],
10-
order: ["ascending", "descending"]
10+
ascending: false // boolean for ascending/descending order, true = ascending
1111
}
1212

1313
const publications = ref([])
1414

1515
const sorting = ref({
16-
sort: "year",
17-
order: "descending"
16+
sort: "author",
17+
ascending: false
1818
})
1919

2020
// helper
@@ -29,13 +29,13 @@ function sortByAuthor(a, b, order) {
2929
const sortedPublications = computed(() => {
3030
return [...publications.value].sort((a, b) => {
3131
const sortKey = sorting.value.sort
32-
const order = sorting.value.order === "ascending" ? 1 : -1
32+
const order = sorting.value.ascending ? 1 : -1
3333

3434
if (sortKey === "year") {
3535
if (a.year !== b.year) {
36-
return (b.year - a.year)
36+
return (b.year - a.year) * order
3737
}
38-
return sortByAuthor(a, b, order)
38+
return sortByAuthor(a, b, 1)
3939
}
4040

4141
if (sortKey === "author") {
@@ -54,6 +54,20 @@ const sortedPublications = computed(() => {
5454
})
5555
})
5656

57+
function handleSortToggle(v) {
58+
// console.log(sorting.value.sort, v)
59+
// if (sorting.value.sort == v) {
60+
// sorting.value.ascending = !sorting.value.ascending
61+
// }
62+
// else {
63+
// sorting.value.ascending = false
64+
// }
65+
}
66+
67+
function handleSortOptionChange(v, e) {
68+
console.log(v,e)
69+
}
70+
5771
onMounted(async () => {
5872
const response = await fetch('/assets/publications.json')
5973
publications.value = await response.json()
@@ -68,9 +82,9 @@ onMounted(async () => {
6882
}
6983

7084
.publication img {
71-
max-width: 200px;
85+
max-width: 150px;
7286
height: auto; /* Maintain aspect ratio */
73-
margin-left: 20px;
87+
margin-right: 20px;
7488
object-fit: contain; /* Ensure the image fits within the container while maintaining aspect ratio */
7589
}
7690

@@ -84,21 +98,53 @@ onMounted(async () => {
8498
}
8599

86100
.publication img {
87-
margin-left: 0;
101+
margin-right: 0;
88102
margin-bottom: 10px;
89103
}
90104
}
91105
</style>
92106

107+
<v-row
108+
justify="space-between"
109+
class="mb-4"
110+
>
111+
93112
# Publications
94113

114+
<v-btn-toggle
115+
:value="sorting.sort"
116+
@change="handleSortOptionChange(sorting, $event)"
117+
mandatory
118+
group
119+
>
120+
<v-btn value="year" @click="() => handleSortToggle('year')">
121+
Year
122+
<v-icon v-if="sorting.sort === 'year'" class="opacity-60">
123+
{{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
124+
</v-icon>
125+
</v-btn>
126+
<v-btn value="author" @click="() => handleSortToggle('author')">
127+
Author
128+
<v-icon v-if="sorting.sort === 'author'" class="opacity-60">
129+
{{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
130+
</v-icon>
131+
</v-btn>
132+
<v-btn value="title" @click="() => handleSortToggle('title')">
133+
Title
134+
<v-icon v-if="sorting.sort === 'title'" class="opacity-60">
135+
{{ (sorting.ascending) ? "mdi-arrow-up" : "mdi-arrow-down" }}
136+
</v-icon>
137+
</v-btn>
138+
</v-btn-toggle>
139+
</v-row>
140+
95141
<div class="container">
96142
<div v-for="publication in sortedPublications" :key="publication.title" class="publication">
143+
<img v-if="publication.image" :src="`../assets/images/publications/${publication.image.src}`" :alt="publication.image.alt">
97144
<div class="publication-info">
98-
<a :href="publication.link" target="_blank">{{ publication.title }}</a>
99145
<p>{{ publication.authors }}</p>
146+
<a :href="publication.link" target="_blank">{{ publication.title }}</a>
100147
<p>{{ publication.conference }} ({{ publication.year }})</p>
101148
</div>
102-
<img v-if="publication.image" :src="`../assets/images/publications/${publication.image.src}`" :alt="publication.image.alt">
103149
</div>
104-
</div>
150+
</div>

0 commit comments

Comments
 (0)