Nuxt Content 3 migration #12

Merged
eggy merged 81 commits from js into master 2022-08-10 18:38:39 -04:00
10 changed files with 79 additions and 19 deletions
Showing only changes of commit c9398ebfb0 - Show all commits

46
components/Hamburger.vue Normal file
View File

@ -0,0 +1,46 @@
<script setup lang="ts">
import IconHamburger from "@/assets/images/hamburger.svg?component";
import { navItems } from "@/data/navItems";
</script>
<template>
<div class="hamburger">
<label class="checkbox-label" for="checkbox"><IconHamburger /></label>
<input class="checkbox" type="checkbox" id="checkbox" />
<div class="drawer">
<li v-for="(item, index) in navItems" :key="index">
<a :href="item.href">{{ item.title }}</a>
</li>
</div>
</div>
</template>
<style scoped>
input.checkbox {
outline: none;
width: 0;
opacity: 0;
}
label.checkbox-label {
cursor: pointer;
}
input.checkbox ~ .drawer {
opacity: 0;
position: absolute;
transform: scale(0);
}
input.checkbox:checked ~ .drawer,
input.checkbox:hover ~ .drawer,
.drawer:hover {
opacity: 1;
transform: scale(1) translateY(1rem);
}
.drawer {
transition: transform var(--trans), opacity var(--trans);
padding: 1rem;
margin-right: 1rem;
}
</style>

View File

@ -1,19 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import ColourPicker from "./ColourPicker.vue"; import ColourPicker from "./ColourPicker.vue";
import IconHamburger from "@/assets/images/hamburger.svg?component"; import { navItems } from "@/data/navItems";
</script> </script>
<template> <template>
<nav class="flex items-center justify-between"> <nav class="flex items-center justify-between">
<ul> <ul>
<li class="home-text"><a href="/">Eggworld</a></li> <li class="home-text"><a href="/">Eggworld</a></li>
<li><a href="/about">About</a></li> <li v-for="(item, index) in navItems" :key="index">
<li><a href="/blog">Blog</a></li> <a :href="item.href">{{ item.title }}</a>
<li><a href="/stories">Stories</a></li> </li>
</ul> </ul>
<div class="flex items-center"> <div class="flex items-center">
<ColourPicker /> <ColourPicker />
<div class="hamburger"> <div class="hamburger">
<IconHamburger /> <Hamburger />
</div> </div>
</div> </div>
</nav> </nav>
@ -42,29 +43,24 @@ li.home-text {
} }
.hamburger { .hamburger {
height: 1px; transform: scale(0);
width: 1px;
opacity: 0; opacity: 0;
} }
* { * {
--trans: 0.2s ease; --trans: 0.2s ease;
transition: opacity var(--trans), height var(--trans), width var(--trans), transition: opacity var(--trans), transform var(--trans);
padding-left var(--trans);
} }
@media screen and (max-width: 510px) { @media screen and (max-width: 510px) {
.hamburger { .hamburger {
display: flex; display: flex;
padding-left: 1rem; transform: none;
height: unset;
width: unset;
opacity: 1; opacity: 1;
} }
li:not(.home-text) { li:not(.home-text) {
height: 1px; transform: scale(0);
width: 1px;
opacity: 0; opacity: 0;
/* accessibility? screw accessibility /* accessibility? screw accessibility
* i want my pretty animations * i want my pretty animations

7
composables/metadata.ts Normal file
View File

@ -0,0 +1,7 @@
/**
* Set the page title in the format [title] | Eggworld.
* @param title The title string.
*/
export function useTitle(title: string) {
useHead({ title: `${title} | Eggworld` });
}

7
data/navItems.ts Normal file
View File

@ -0,0 +1,7 @@
export const navItems = [
{ href: "/about", title: "About" },
{ href: "/blog", title: "Blog" },
{ href: "/stories", title: "Stories" },
];
export default navItems;

View File

@ -58,7 +58,7 @@ html.dark::before {
main { main {
width: 80%; width: 80%;
max-width: 60rem; max-width: 60rem;
height: 100%; min-height: 100%;
margin: auto; margin: auto;
padding-top: 2rem; padding-top: 2rem;
} }

View File

@ -1,3 +1,5 @@
<script setup lang="ts"></script>
<template> <template>
<ContentDoc tag="article" class="prose dark:prose-invert"> <ContentDoc tag="article" class="prose dark:prose-invert">
<template #not-found> <template #not-found>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
useHead({ title: "About | Eggworld" }); useTitle("About");
</script> </script>
<template> <template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
useHead({ title: "Blog | Eggworld" }); useTitle("Blog");
</script> </script>
<template></template> <template></template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
useHead({ title: "Home | Eggworld" }); useTitle("Home");
</script> </script>
<template> <template>
@ -11,6 +11,8 @@ useHead({ title: "Home | Eggworld" });
<HomeStatBox>Latest story</HomeStatBox> <HomeStatBox>Latest story</HomeStatBox>
<HomeStatBox>Latest commit w/details</HomeStatBox> <HomeStatBox>Latest commit w/details</HomeStatBox>
</div> </div>
<p>SERVICES</p>
<p>ABOUT</p>
</main> </main>
</template> </template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
useHead({ title: "Stories | Eggworld" }); useTitle("Stories");
</script> </script>
<template></template> <template></template>