Skip to content

Commit

Permalink
feat: add starter code
Browse files Browse the repository at this point in the history
  • Loading branch information
bencodezen committed Apr 2, 2023
0 parents commit 1e23cbf
Show file tree
Hide file tree
Showing 20 changed files with 8,111 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
node_modules
*.log*
.nuxt
.nitro
.cache
.output
.env
dist
.DS_Store
node_modules
2 changes: 2 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
shamefully-hoist=true
strict-peer-dependencies=false
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Nuxt 3 Middleware (Vue Mastery Course)

## Setup

Make sure to install the dependencies:

```bash
# npm
npm install
```

## Development Server

Start the development server on http://localhost:3000

```bash
npm run dev
```

## Production

Build the application for production:

```bash
npm run build
```

Locally preview production build:

```bash
npm run preview
```

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
14 changes: 14 additions & 0 deletions app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup>
useHead({
link: [
{ rel: 'stylesheet', href: '/css/pico.min.css' },
{ rel: 'stylesheet', href: '/css/custom.css' }
]
})
</script>

<template>
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
</template>
48 changes: 48 additions & 0 deletions components/LoginForm.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<script setup lang="ts">
const isAuthenticated = useCookie('is-authenticated')
const currentUser = useCookie('current-user')
const router = useRouter()
const userInput = ref({
username: '',
password: ''
})
const loginUser = () => {
if (
userInput.value.username.length > 0 &&
userInput.value.password.length > 0
) {
isAuthenticated.value = 'true'
currentUser.value = userInput.value.username
router.push('/profile/' + userInput.value.username)
}
}
</script>

<template>
<form @submit.prevent>
<input
v-model="userInput.username"
type="text"
name="username"
placeholder="Username"
aria-label="Username"
autocomplete="username"
required
/>
<input
v-model="userInput.password"
type="password"
name="password"
placeholder="Password"
aria-label="Password"
autocomplete="current-password"
required
/>
<button @click="loginUser" type="submit" class="contrast">Login</button>
</form>
</template>

<style lang="scss" scoped></style>
12 changes: 12 additions & 0 deletions components/TheFooter.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script setup lang="ts"></script>

<template>
<footer class="container-fluid">
<small>
Built with <a href="https://picocss.com" class="secondary">Pico</a> •
<a href="" class="secondary"> Source code </a>
</small>
</footer>
</template>

<style lang="scss" scoped></style>
15 changes: 15 additions & 0 deletions components/TheHeader.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<script setup lang="ts"></script>

<template>
<nav class="container-fluid">
<ul>
<li>
<nuxt-link to="/" class="contrast">
<strong>Vue Mastery's Nuxt 3 Middleware</strong>
</nuxt-link>
</li>
</ul>
</nav>
</template>

<style lang="scss" scoped></style>
9 changes: 9 additions & 0 deletions layouts/default.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div id="default-layout">
<TheHeader />
<main class="container">
<slot />
</main>
<TheFooter />
</div>
</template>
2 changes: 2 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({})
Loading

0 comments on commit 1e23cbf

Please sign in to comment.