Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improved isHomePage using currentPage #229

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composables/use-home-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { joinURL } from 'ufo'

export async function useHomePage() {
const { homeItem } = await useCommonContent()
const route = useRoute()

const isHomePage = computed(() => {
const url = homeItem.value?.url
const currentPageUrl = useCurrentPage().value.webResponse?.item?.url

if (url) return route.path === url
if (url) return currentPageUrl === url

// If there is an error then maybe the API could not be reached.
// Therefore, the common content will be empty.
Expand All @@ -16,7 +16,7 @@ export async function useHomePage() {
const locales: string[] = $i18n?.localeCodes?.value || []

// test `/` or `/{locale}` depending on the current locale and the i18n route strategy from Nuxt i18n or Roadiz
return route.path === '/' || locales.map(locale => joinURL('/', locale)).includes(joinURL('/', route.path))
return currentPageUrl === '/' || (currentPageUrl && locales.map(locale => joinURL('/', locale)).includes(joinURL('/', currentPageUrl)))
})

const homePagePath = computed(() => {
Expand Down
Loading