Skip to content

Commit 0640f88

Browse files
committed
refactoring and slight visual tweaks
1 parent 5612a6c commit 0640f88

File tree

5 files changed

+24
-31
lines changed

5 files changed

+24
-31
lines changed

app.vue

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,23 +32,26 @@
3232

3333
<script setup>
3434
import projects from 'assets/projects';
35-
import redirects from 'assets/links';
35+
import links from 'assets/links';
3636
3737
const projectIndex = useCookie('projectIndex', {
3838
default: () => Math.floor(Math.random() * projects.length),
3939
})
40+
41+
42+
const project = ref(projects[projectIndex.value])
43+
provide('project', project)
4044
onMounted(() => {
4145
projectIndex.value += 1
4246
projectIndex.value %= projects.length
4347
project.value = projects[projectIndex.value]
4448
})
4549
46-
const project = ref(projects[projectIndex.value])
47-
provide('project', project)
48-
4950
const route = useRoute()
5051
onMounted(() => {
51-
let redirect = redirects.filter(redirect => !redirect.page).find(r => r.path === route.path)
52+
let redirect = links
53+
.filter(link => !link.page)
54+
.find(link => link.path === route.path)
5255
if (!redirect) return
5356
window.location.href = redirect.target
5457
})

nuxt.config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import fs from 'node:fs'
2-
import redirects from "./assets/links";
2+
import links from "./assets/links";
33

44
// https://nuxt.com/docs/api/configuration/nuxt-config
55
export default defineNuxtConfig({
@@ -12,11 +12,12 @@ export default defineNuxtConfig({
1212
},
1313
hooks: {
1414
"build:done"() {
15-
const file = redirects.filter(redirect => !redirect.page).map((redirect) => {
16-
return `${redirect.path} ${redirect.target} 301`;
17-
}).join("\n");
15+
const file = links
16+
.filter(link => !link.page)
17+
.map(link => `${link.path} ${link.target} 301`)
18+
.join("\n");
1819

19-
fs.writeFileSync("public/_redirects", file);
20+
fs.writeFileSync("public/_redirects", `# Generated by Nuxt \n${file}`);
2021
},
2122
}
2223
});

pages/index.vue

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,20 @@
22
<section class="links">
33
<h2>Links</h2>
44
<ul>
5-
<template v-for="redirect in redirects" :key="redirect.path">
6-
<template v-if="redirect.page">
7-
<NuxtLink :to="redirect.path">
8-
<li class="redirect">
9-
<main>{{ redirect.title }}</main>
10-
<aside>{{ redirect.path }} </aside>
11-
</li>
12-
</NuxtLink>
13-
</template>
14-
<template v-else>
15-
<a :href="redirect.target">
16-
<li class="redirect">
17-
<main>{{ redirect.title }}</main>
18-
<aside>{{ redirect.path }} </aside>
19-
</li>
20-
</a>
21-
</template>
5+
<template v-for="{ page, path, target, title } in links" :key="path">
6+
<NuxtLink :to="page ? path : target">
7+
<li class="redirect">
8+
<main>{{ title }}</main>
9+
<aside>{{ path }} </aside>
10+
</li>
11+
</NuxtLink>
2212
</template>
2313
</ul>
2414
</section>
2515
</template>
2616

2717
<script setup>
28-
import redirects from 'assets/links';
18+
import links from 'assets/links';
2919
3020
</script>
3121

@@ -40,6 +30,7 @@ import redirects from 'assets/links';
4030
color: white;
4131
border-radius: 2px;
4232
transition: 0.2s ease-in-out;
33+
display: flex;
4334
4435
aside {
4536
font-size: 0.8em;

public/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Generated by Nuxt
12
/meetup https://www.meetup.com/creativecodeberlin/ 301
23
/ccs https://funprogramming.org/pad/p/ccs 301
34
/ccs2 https://files.creativecode.berlin/s/fZaqsM25kroFfzz 301

server/tsconfig.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)