Repository navigation
Expand file tree
/
Copy pathapp.vue
More file actions
54 lines (47 loc) · 1.56 KB
/
Copy pathapp.vue
File metadata and controls
54 lines (47 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<template>
<header>
<h1>DatoCMS + Nuxt Starter Kit</h1>
<nav>
<a href="https://www.datocms.com/docs/nuxt"> 📚 Full Integration Guide </a>
</nav>
<DraftModeToggler />
</header>
<main><NuxtPage /></main>
<!--
Enable click-to-edit overlays in draft mode only.
The ContentLink component provides two editing experiences:
1. On the standalone website: Click any content to open DatoCMS editor in a new tab
2. Inside Web Previews plugin Visual mode: Click content to instantly edit in the side panel
Only rendered in draft mode since the required stega-encoded metadata
is only included in draft content responses (see useQuery.ts).
-->
<ClientOnly>
<ContentLink v-if="draftMode" />
</ClientOnly>
</template>
<script setup lang="ts">
import type { ReactiveHead } from '@unhead/vue';
import { toHead } from 'vue-datocms';
import { TagFragment } from './lib/datocms/commonFragments';
import { graphql } from './lib/datocms/graphql';
import { DraftModeToggler } from '#components';
const draftMode = useDraftMode();
const query = graphql(
/* GraphQL */ `
query RootQuery {
_site {
faviconMetaTags {
...TagFragment
}
}
}
`,
[TagFragment],
);
const data = await useQuery(query);
useHead(() => {
// The declared return type of toHead() leaves out the tag attributes (rel, href, content...)
// it copies into every entry, which the stricter useHead() types would otherwise reject.
return toHead(data.value?._site?.faviconMetaTags || []) as unknown as ReactiveHead;
});
</script>