Skip to content

Commit 1e23cbf

Browse files
committed
feat: add starter code
0 parents  commit 1e23cbf

20 files changed

+8111
-0
lines changed

.gitignore

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
node_modules
2+
*.log*
3+
.nuxt
4+
.nitro
5+
.cache
6+
.output
7+
.env
8+
dist
9+
.DS_Store
10+
node_modules

.npmrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
shamefully-hoist=true
2+
strict-peer-dependencies=false

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Nuxt 3 Middleware (Vue Mastery Course)
2+
3+
## Setup
4+
5+
Make sure to install the dependencies:
6+
7+
```bash
8+
# npm
9+
npm install
10+
```
11+
12+
## Development Server
13+
14+
Start the development server on http://localhost:3000
15+
16+
```bash
17+
npm run dev
18+
```
19+
20+
## Production
21+
22+
Build the application for production:
23+
24+
```bash
25+
npm run build
26+
```
27+
28+
Locally preview production build:
29+
30+
```bash
31+
npm run preview
32+
```
33+
34+
Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.

app.vue

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<script setup>
2+
useHead({
3+
link: [
4+
{ rel: 'stylesheet', href: '/css/pico.min.css' },
5+
{ rel: 'stylesheet', href: '/css/custom.css' }
6+
]
7+
})
8+
</script>
9+
10+
<template>
11+
<NuxtLayout>
12+
<NuxtPage />
13+
</NuxtLayout>
14+
</template>

components/LoginForm.vue

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<script setup lang="ts">
2+
const isAuthenticated = useCookie('is-authenticated')
3+
const currentUser = useCookie('current-user')
4+
5+
const router = useRouter()
6+
7+
const userInput = ref({
8+
username: '',
9+
password: ''
10+
})
11+
12+
const loginUser = () => {
13+
if (
14+
userInput.value.username.length > 0 &&
15+
userInput.value.password.length > 0
16+
) {
17+
isAuthenticated.value = 'true'
18+
currentUser.value = userInput.value.username
19+
router.push('/profile/' + userInput.value.username)
20+
}
21+
}
22+
</script>
23+
24+
<template>
25+
<form @submit.prevent>
26+
<input
27+
v-model="userInput.username"
28+
type="text"
29+
name="username"
30+
placeholder="Username"
31+
aria-label="Username"
32+
autocomplete="username"
33+
required
34+
/>
35+
<input
36+
v-model="userInput.password"
37+
type="password"
38+
name="password"
39+
placeholder="Password"
40+
aria-label="Password"
41+
autocomplete="current-password"
42+
required
43+
/>
44+
<button @click="loginUser" type="submit" class="contrast">Login</button>
45+
</form>
46+
</template>
47+
48+
<style lang="scss" scoped></style>

components/TheFooter.vue

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script setup lang="ts"></script>
2+
3+
<template>
4+
<footer class="container-fluid">
5+
<small>
6+
Built with <a href="https://picocss.com" class="secondary">Pico</a> •
7+
<a href="" class="secondary"> Source code </a>
8+
</small>
9+
</footer>
10+
</template>
11+
12+
<style lang="scss" scoped></style>

components/TheHeader.vue

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<script setup lang="ts"></script>
2+
3+
<template>
4+
<nav class="container-fluid">
5+
<ul>
6+
<li>
7+
<nuxt-link to="/" class="contrast">
8+
<strong>Vue Mastery's Nuxt 3 Middleware</strong>
9+
</nuxt-link>
10+
</li>
11+
</ul>
12+
</nav>
13+
</template>
14+
15+
<style lang="scss" scoped></style>

layouts/default.vue

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<template>
2+
<div id="default-layout">
3+
<TheHeader />
4+
<main class="container">
5+
<slot />
6+
</main>
7+
<TheFooter />
8+
</div>
9+
</template>

nuxt.config.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// https://nuxt.com/docs/api/configuration/nuxt-config
2+
export default defineNuxtConfig({})

0 commit comments

Comments
 (0)