-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
92 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<script setup lang="ts"> | ||
const password = ref('') | ||
const loading = ref(false) | ||
const isAuthorized = useState<boolean>('authorized', () => false) | ||
const { data: notes, error, execute } = await useAsyncData('notes', () => | ||
queryCollection('content') | ||
.where('path', 'LIKE', '%/notes/%') | ||
.order('date', 'DESC').all(), { | ||
immediate: isAuthorized.value | ||
}) | ||
if (!notes.value || !error.value) createError({ statusCode: 404 }) | ||
const { data, refresh } = useFetch('/api/verify', { | ||
method: 'POST', | ||
body: { | ||
password | ||
}, | ||
watch: false, | ||
immediate: false | ||
}) | ||
async function verifyPassword() { | ||
loading.value = true | ||
try { | ||
await refresh() | ||
if (data.value?.status === 200) { | ||
await execute() | ||
isAuthorized.value = true | ||
toast.success('Welcome to my hidden notes!') | ||
} else { | ||
toast.error('Invalid password') | ||
password.value = '' | ||
} | ||
} catch (error) { | ||
toast.error('Invalid password') | ||
} | ||
loading.value = false | ||
} | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-8"> | ||
<span v-if="!isAuthorized" class="font-newsreader text-lg font-light italic"> | ||
You've stumbled upon my private notes section. If you know me, you might figure out the password. | ||
If not, well... these thoughts are probably not meant for you anyway. But hey, feel free to try. | ||
</span> | ||
<form v-if="!isAuthorized" class="flex gap-4" @submit.prevent="verifyPassword"> | ||
<input v-model="password" type="password" placeholder="Password" class="input"> | ||
<MButton class="flex items-center cursor-pointer justify-center gap-2 bg-accent hover:bg-accent/90 px-2 text-white" type="submit" rounded="none" label="Verify" :loading /> | ||
</form> | ||
<div v-if="isAuthorized" class="mt-6 flex flex-col gap-8"> | ||
<NuxtLink | ||
v-for="(post, index) in notes" | ||
:key="post.title" | ||
:to="post.path" | ||
class="group relative max-w-prose" | ||
data-animate | ||
:aria-label="`Read ${post.title}`" | ||
:style="{ '--stagger': index }" | ||
> | ||
<div class="font-newsreader text-lg italic opacity-75"> | ||
{{ post.date }} | ||
</div> | ||
<h3 class="text-2xl font-newsreader font-medium italic decoration-accent group-hover:underline"> | ||
{{ post.title }} | ||
</h3> | ||
<p | ||
class="!text-sm" | ||
> | ||
{{ post.description }} | ||
</p> | ||
</NuxtLink> | ||
</div> | ||
</div> | ||
</template> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: Notes | ||
description: Some thoughts are meant to be discovered, not shown.. | ||
--- | ||
|
||
::section-item{:number='1' title="Notes"} | ||
:::notes | ||
::: | ||
:: |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters