Skip to content

Commit

Permalink
seo improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Oct 16, 2023
1 parent 56c5f98 commit cf72c56
Show file tree
Hide file tree
Showing 20 changed files with 56 additions and 29 deletions.
19 changes: 10 additions & 9 deletions app.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
<script setup lang="ts">
import { debounce } from 'perfect-debounce'
import type { ParsedContent } from '@nuxt/content/dist/runtime/types'
const search = ref(null)
const colorMode = useColorMode()
const { headerLinks, searchGroups, searchLinks } = useNavigation()
const color = computed(() => colorMode.value === 'dark' ? '#18181b' : 'white')
const { data: navigation } = await useLazyAsyncData('navigation', () => fetchContentNavigation(), { default: () => [] })
const { data: files } = useLazyFetch<ParsedContent[]>('/api/search.json', {
default: () => [],
server: false
})
// Computed
const color = computed(() => colorMode.value === 'dark' ? '#18181b' : 'white')
// Head
useHead({
titleTemplate: title => title ? `${title} - Nuxt` : 'Nuxt: The Intuitive Web Framework',
titleTemplate: title => title ? `${title} · Nuxt` : 'Nuxt: The Intuitive Web Framework',
meta: [
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ key: 'theme-color', name: 'theme-color', content: color }
Expand All @@ -39,8 +36,12 @@ useSeoMeta({
twitterSite: 'nuxt_js'
})
// Provide
watch(() => search.value?.commandPaletteRef?.query, debounce((query) => {
if (!query) return
useTrackEvent('Search', { props: { query, results: `${search.value?.commandPaletteRef.results.length}` } })
}, 500))
// Provide
provide('navigation', navigation)
</script>

Expand All @@ -55,7 +56,7 @@ provide('navigation', navigation)
<AppFooter />

<ClientOnly>
<UDocsSearch :files="files" :navigation="navigation[0]?.children" :groups="searchGroups" :links="searchLinks" />
<UDocsSearch ref="search" :files="files" :navigation="navigation[0]?.children" :groups="searchGroups" :links="searchLinks" />
<UNotifications />
</ClientOnly>
Expand Down
1 change: 0 additions & 1 deletion content/2.modules.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
title: Modules
description: Discover our list of modules to supercharge your Nuxt project. Created by the Nuxt team and community.
navigation.icon: i-ph-puzzle-piece-duotone
head.image: '/socials/modules.jpg'
1 change: 0 additions & 1 deletion content/3.showcase.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
title: Showcase
description: Discover our selection of websites built with Nuxt. This collection is powered by VueTelescope.
navigation.icon: i-ph-app-window-duotone
head.image: '/socials/showcase.jpg'
links:
- label: 'Chrome'
size: 'md'
Expand Down
1 change: 0 additions & 1 deletion content/4.enterprise/1.support.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
title: Official Support
navigation.title: Support
description: Through NuxtLabs experts and agency networks, we have a solution for every need.
head.image: '/socials/support.jpg'
navigation.icon: i-ph-lifebuoy-duotone
links:
- to: 'mailto:[email protected]'
Expand Down
1 change: 0 additions & 1 deletion content/4.enterprise/2.agencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ title: Nuxt Agencies
description: Are you looking for a trusted partner with a strong expertise in Nuxt development? Consult our agency partner catalog and find an agency near you with the right set of skills.
head.title: Nuxt Partner Agencies
head.description: Consult our agency partner catalog and find an agency near you with the right set of skills.
head.image: '/socials/agencies.jpg'
navigation.icon: i-ph-handshake-duotone
links:
- label: 'Submit my agency'
Expand Down
1 change: 0 additions & 1 deletion content/4.enterprise/3.sponsors.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
title: Sponsors
description: Nuxt is an open-source framework totally free to use thanks to our generous sponsors. If you use Nuxt in your daily work and feel that it has made your life easier, please consider backing us.
head.description: Nuxt is an open-source framework totally free to use thanks to our generous sponsors.
head.image: '/socials/sponsors.jpg'
navigation.icon: i-ph-hand-heart-duotone
links:
- label: 'Become a sponsor'
Expand Down
2 changes: 0 additions & 2 deletions content/4.enterprise/4.jobs.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
title: Explore Nuxt Jobs
description: Browse available openings for coding with Vue and Nuxt all over the world.
head.title: Jobs
navigation.title: Jobs
navigation.icon: i-ph-briefcase-duotone
head.image: '/socials/jobs.jpg'
links:
- label: 'Post a job'
to: 'https://vuejobs.com/jobs/create'
Expand Down
2 changes: 1 addition & 1 deletion content/4.enterprise/_dir.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
navigation.icon: i-ph-buildings-duotone
head.titleTemplate: '%s - Nuxt Enterprise'
head.titleTemplate: '%s · Nuxt Enterprise'
6 changes: 2 additions & 4 deletions content/5.blog.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
title: Blog
title: The Nuxt Blog
navigation.title: Blog
description: 'Read the latest news about all Nuxt solutions, from framework announcements to integration tutorials.'
navigation.icon: i-ph-newspaper
head.title: The Nuxt Blog
head.description: Read the latest news about the Nuxt framework and its community.
head.image: '/socials/blog.jpg'
1 change: 0 additions & 1 deletion content/design-kit.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: Design Kit
description: Welcome to Nuxt design definition page. Identity was redefined by handpicking conscientiously colors, typography and shapes in order to put forward how performant, useful & easy Nuxt products are.
head.image: '/socials/design-kit.jpg'
navigation.icon: 'i-ph-palette'
links:
- label: 'Download Design Kit'
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@vueuse/core": "^10.5.0",
"@vueuse/nuxt": "^10.5.0",
"nuxt": "^3.7.4",
"perfect-debounce": "^1.0.0",
"scule": "^1.0.0",
"sitemap": "^7.1.1"
},
Expand Down
6 changes: 6 additions & 0 deletions pages/blog/[slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ const { data: surround } = await useAsyncData(`${route.path}-surround`, () => qu
.findSurround(withoutTrailingSlash(route.path))
)
useSeoMeta({
titleTemplate: '%s · Nuxt Blog',
title: article.value.head?.title || article.value.title,
description: article.value.head?.description || article.value.description
})
const socialLinks = computed(() => [{
icon: 'i-simple-icons-linkedin',
to: `https://www.linkedin.com/sharing/share-offsite/?url=https://nuxt.com${article.value._path}`
Expand Down
6 changes: 5 additions & 1 deletion pages/blog/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const { fetchList, articles } = useBlog()
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne())
useContentHead(page)
useSeoMeta({
titleTemplate: '%s',
title: page.value.head?.title || page.value.title,
description: page.value.head?.description || page.value.description
})
await fetchList()
</script>
Expand Down
4 changes: 2 additions & 2 deletions pages/docs/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const titleTemplate = computed(() => {
if (page.value.titleTemplate) return page.value.titleTemplate
const titleTemplate = navKeyFromPath(route.path, 'titleTemplate', navigation.value)
if (titleTemplate) return titleTemplate
return '%s - Nuxt'
return '%s · Nuxt'
})
const communityLinks = computed(() => [{
Expand Down Expand Up @@ -84,7 +84,7 @@ const ecosystemLinks = [{
useSeoMeta({
titleTemplate,
title: page.value.head?.title || page.value.title,
description: page.value.description
description: page.value.head?.description || page.value.description
})
</script>

Expand Down
6 changes: 6 additions & 0 deletions pages/enterprise/agencies/[slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ const links = computed(() => [{
to: agency.value.link,
target: '_blank'
}])
useSeoMeta({
titleTemplate: '%s · Nuxt Agencies',
title: agency.value.head?.title || agency.value.title,
description: agency.value.head?.description || agency.value.description
})
</script>

<template>
Expand Down
6 changes: 5 additions & 1 deletion pages/enterprise/agencies/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const { filteredAgencies, fetchList, services, regions } = useEnterpriseAgencies
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne())
useContentHead(page)
useSeoMeta({
titleTemplate: 'Explore Nuxt Agencies',
title: page.value.head?.title || page.value.title,
description: page.value.head?.description || page.value.description
})
await fetchList()
</script>
Expand Down
6 changes: 5 additions & 1 deletion pages/enterprise/jobs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ const { fetchList, filteredJobs } = useEnterpriseJobs()
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne())
useContentHead(page)
useSeoMeta({
titleTemplate: 'Explore Nuxt Jobs',
title: page.value.head?.title || page.value.title,
description: page.value.head?.description || page.value.description
})
await fetchList()
</script>
Expand Down
6 changes: 5 additions & 1 deletion pages/enterprise/sponsors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ if (!page.value) {
const { data: sponsors } = await useFetch('https://api.nuxt.com/sponsors')
useContentHead(page)
useSeoMeta({
titleTemplate: 'Explore Nuxt Sponsors',
title: page.value.head?.title || page.value.title,
description: page.value.head?.description || page.value.description
})
</script>

<template>
Expand Down
6 changes: 5 additions & 1 deletion pages/enterprise/support.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ if (!page.value) {
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
}
useContentHead(page)
useSeoMeta({
titleTemplate: '%s · Nuxt Enterprise',
title: page.value.head?.title || page.value.title,
description: page.value.head?.description || page.value.description
})
</script>

<template>
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit cf72c56

Please sign in to comment.