Skip to content

Commit

Permalink
fix: drop fallback title support
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Sep 4, 2023
1 parent db52c81 commit 185b8c8
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions module/src/runtime/plugin/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import {
useSiteConfig,
} from '#imports'

function titleCase(s: string) {
return s
.replaceAll('-', ' ')
.replace(/\w\S*/g, w => w.charAt(0).toUpperCase() + w.substr(1).toLowerCase())
}

export default defineNuxtPlugin({
name: 'nuxtseo:defaults',
setup() {
Expand All @@ -31,19 +25,7 @@ export default defineNuxtPlugin({
const resolveUrl = createSitePathResolver({ withBase: true, absolute: true })
const canonicalUrl = computed(() => resolveUrl(route.path || '/').value)

const title = computed(() => {
if (typeof route.meta?.title === 'string')
return route.meta?.title

// if no title has been set then we should use the last segment of the URL path and title case it
const path = route.path || '/'
const lastSegment = path.split('/').pop()
return lastSegment ? titleCase(lastSegment) : null
})

useHead({
// fallback title
title,
link: [{ rel: 'canonical', href: canonicalUrl }],
})

Expand Down

0 comments on commit 185b8c8

Please sign in to comment.