-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
73 composables return asyncdata like usefetch (#78)
* make composables return AsyncData like useFetch #73 * fix two small lint reported issues * chore(deps):
- Loading branch information
1 parent
6a4a24f
commit aa88548
Showing
26 changed files
with
3,828 additions
and
1,841 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,9 @@ | ||
{ | ||
// https://nuxt.com/docs/guide/concepts/typescript | ||
"extends": "./.nuxt/tsconfig.json" | ||
"extends": "./.nuxt/tsconfig.json", | ||
"exclude": [ | ||
"node_modules", | ||
"dist", | ||
".nuxt", | ||
] | ||
} |
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 |
---|---|---|
@@ -1,63 +1,16 @@ | ||
<script setup lang="ts"> | ||
import type { Menu } from '#graphql-operations' | ||
import { useRuntimeConfig, ref, watch, getCurrentUserName, useMenu, isStaging } from '#imports' | ||
import { isStaging } from '#imports' | ||
const config = useRuntimeConfig() | ||
const stagingUrl = config.public.wpNuxt.stagingUrl | ||
const menu: Menu = await useMenu('main') | ||
const userName = ref<string>() | ||
userName.value = getCurrentUserName() | ||
watch(() => getCurrentUserName(), (newVal) => { | ||
userName.value = newVal | ||
}) | ||
const wpLinks = menu?.map(page => ({ | ||
label: page.label, | ||
to: page.uri, | ||
})) | ||
const links = [ | ||
...wpLinks, | ||
{ | ||
label: 'Test', | ||
to: '/test', | ||
}, | ||
{ | ||
label: 'Auth', | ||
to: '/auth', | ||
}, | ||
] | ||
const staging = await isStaging() | ||
</script> | ||
|
||
<template> | ||
<StagingBanner v-if="staging" /> | ||
<div :class="staging ? 'mt-[34px]' : 'mt-0'"> | ||
<UHeader :links="links"> | ||
<template #logo> | ||
<WPNuxtLogo /> <span class="text-lg">playground</span> | ||
</template> | ||
<template #right> | ||
<UColorModeButton variant="soft" /> | ||
<UButton | ||
v-if="!staging" | ||
:to="stagingUrl" | ||
icon="i-heroicons-pencil" | ||
variant="soft" | ||
size="sm" | ||
> | ||
Staging | ||
</UButton> | ||
</template> | ||
</UHeader> | ||
<HeaderComponent /> | ||
<UMain> | ||
<NuxtPage /> | ||
</UMain> | ||
<UFooter :links="links"> | ||
<template #left> | ||
<span class="text-sm">a Proof of Concept by <NuxtLink | ||
href="https://vernaillen.dev" | ||
target="_blank" | ||
>Wouter Vernaillen</NuxtLink></span> | ||
</template> | ||
</UFooter> | ||
<UFooter /> | ||
</div> | ||
</template> |
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,36 @@ | ||
<script setup lang="ts"> | ||
import { useMenu } from '#imports' | ||
const { data: menu } = await useMenu('main') | ||
const wpLinks = menu.value?.map(link => ({ | ||
label: link.label, | ||
to: link.uri, | ||
})) | ||
const links = [ | ||
...wpLinks, | ||
{ | ||
label: 'Test', | ||
to: '/test', | ||
}, | ||
{ | ||
label: 'Auth', | ||
to: '/auth', | ||
}, | ||
{ | ||
label: 'Error Handling', | ||
to: '/errorHandling', | ||
}, | ||
] | ||
</script> | ||
|
||
<template> | ||
<UHeader :links="links"> | ||
<template #logo> | ||
<WPNuxtLogo /> <span class="text-lg">playground</span> | ||
</template> | ||
<template #right> | ||
<UColorModeButton /> | ||
</template> | ||
</UHeader> | ||
</template> |
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,34 @@ | ||
<script setup lang="ts"> | ||
import type { PropType } from 'vue' | ||
import type { NuxtError } from '#app' | ||
import { isStaging } from '#imports' | ||
const props = defineProps({ | ||
error: { | ||
type: Object as PropType<NuxtError>, | ||
required: true, | ||
}, | ||
}) | ||
if (props.error.statusCode !== 404) { | ||
console.error(props.error.message) | ||
} | ||
const staging = await isStaging() | ||
</script> | ||
|
||
<template> | ||
<div :class="staging ? 'mt-[34px]' : 'mt-0'"> | ||
<HeaderComponent /> | ||
<UMain> | ||
<UContainer> | ||
<UPage> | ||
<UPageError | ||
:status="error.statusCode" | ||
:name="error.statusMessage" | ||
:message="error.message" | ||
/> | ||
</UPage> | ||
</UContainer> | ||
</UMain> | ||
<UFooter /> | ||
</div> | ||
</template> |
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,17 @@ | ||
<script setup lang="ts"> | ||
import { createError, usePostByUri } from '#imports' | ||
const { data: post } = await usePostByUri('missingUriForTesting') | ||
if (!post.value) { | ||
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true }) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<UContainer class="prose dark:prose-invert pt-5"> | ||
You should never see this<br> | ||
{{ post }} | ||
</UContainer> | ||
</div> | ||
</template> |
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,32 @@ | ||
<script setup lang="ts"> | ||
import { usePages } from '#imports' | ||
const { data: pages } = await usePages() | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<ULandingSection | ||
title="Pages" | ||
headline="testing the usePages() composable" | ||
> | ||
<UPageGrid> | ||
<ULandingCard | ||
v-for="post, index in pages" | ||
:key="index" | ||
:title="post.title" | ||
:description="post.date?.split('T')[0]" | ||
:to="post.uri" | ||
> | ||
<img | ||
v-if="post?.featuredImage?.node?.sourceUrl" | ||
:src="post.featuredImage.node.sourceUrl" | ||
class="w-full rounded-md" | ||
> | ||
<!-- eslint-disable-next-line vue/no-v-html --> | ||
<span v-html="post.excerpt" /> | ||
</ULandingCard> | ||
</UPageGrid> | ||
</ULandingSection> | ||
</div> | ||
</template> |
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
Oops, something went wrong.