Skip to content

fix: navigation dir confs handle missing query params#2772

Merged
farnabaz merged 2 commits intonuxt:mainfrom
hi-zp:fix-dir-conf-for-locale
Sep 12, 2024
Merged

fix: navigation dir confs handle missing query params#2772
farnabaz merged 2 commits intonuxt:mainfrom
hi-zp:fix-dir-conf-for-locale

Conversation

@hi-zp
Copy link
Copy Markdown
Contributor

@hi-zp hi-zp commented Sep 8, 2024

🔗 Linked issue

resolves #2771

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

Comment on lines 35 to 37

const dirConfigs = await serverQueryContent(event)
const dirConfigs = await serverQueryContent(event, query)
.where({ _path: /\/_dir$/i, _partial: true })
.find()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using user's query in configs search might result in loosing some configs. Imagine user filter documents based on their path or title.

What if we use first retrieved content to get the locale and use it in configs query?

const dirConfigs = await serverQueryContent(event, contents.length ? { _locale: contents[0]._length } : {})
    .where({ _path: /\/_dir$/i, _partial: true })
    .find()

Copy link
Copy Markdown
Member

@farnabaz farnabaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@farnabaz farnabaz merged commit f36d854 into nuxt:main Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The configuration in _dir.yml does not take effect when using i18n.

2 participants