Skip to content

Commit 65ffcae

Browse files
authored
Merge pull request #66 from CreativeCodeBerlin/layout-rewrite
Layout rewrite
2 parents a867043 + 831d16a commit 65ffcae

File tree

7 files changed

+50
-33
lines changed

7 files changed

+50
-33
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;

pages/submit.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
For images in can be on your own website, or on a service like <a
2222
href="https://imgur.com">Imgur</a>.<br>
2323
For websites you could use a service like <a href="https://www.netlify.com/">Netlify</a>.
24-
For video it can be on your own website, or on a service like <a href="https://vimeo.com">Vimeo</a> or
24+
For video it can be on your own website, or on a service like <a href="https://vimeo.com">Vimeo</a>
25+
or
2526
<a href="https://youtube.com">Youtube</a>.<br>
2627
Tip: When generating an embed code with an iFrame tag, use the url from the src attribute.
2728

@@ -93,10 +94,15 @@ watch([url, author, author_url, color, scale], () => {
9394

9495
<style lang="scss" scoped>
9596
.submit {
97+
background: var(--background);
9698
9799
padding: var(--pad2);
98100
padding-top: calc(var(--pad2) * 2);
99-
min-width: 400px;
101+
102+
@media screen and (min-width: 800px) {
103+
min-width: 400px;
104+
}
105+
100106
position: absolute;
101107
102108
label {
@@ -118,6 +124,7 @@ select {
118124
width: 100%;
119125
padding: var(--pad);
120126
font-size: 1.2em;
127+
box-sizing: border-box;
121128
}
122129
123130
textarea {

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

public/logo.svg

Lines changed: 17 additions & 0 deletions
Loading

server/tsconfig.json

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

0 commit comments

Comments
 (0)