Skip to content

feat(navigation): allow passing QueryBuilder or QueryBuilderParams in fetchNavigation or <ContentNavigation> - #1206

Merged
Tahul merged 7 commits into
nuxt:mainfrom
harlan-zw:feat/content-nav-query
Jun 3, 2022
Merged

feat(navigation): allow passing QueryBuilder or QueryBuilderParams in fetchNavigation or <ContentNavigation>#1206
Tahul merged 7 commits into
nuxt:mainfrom
harlan-zw:feat/content-nav-query

Conversation

@harlan-zw

@harlan-zwharlan-zw commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

🔗 Linked issue

❓ 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

The ContentNavigation component is typed to only allow you to provide the query as QueryBuilderParams. The DX of this isn't great as everywhere else in the doc a QueryBuilder is used with queryContent.

This is especially annoying when you want to show the ContentNavigation with a simple path prefix, as the user has to then figure out regex.

The fetchContentNavigation already supports a QueryBuilder, so it's seems like this was the initial expectation of this prop anyway.

I've added an example to highlight the use case

📝 Checklist

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

@netlify

netlifyBot commented Jun 3, 2022

Copy link
Copy Markdown

Deploy Preview for nuxt-content ready!

NameLink
🔨 Latest commit267e4b7
🔍 Latest deploy loghttps://app.netlify.com/sites/nuxt-content/deploys/629a234ccdc87100098d6de6
😎 Deploy Previewhttps://deploy-preview-1206--nuxt-content.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@atinuxatinux left a comment

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.

Beautiful ❤️

Comment threaddocs/content/4.api/1.components/3.content-navigation.md Outdated
Comment threaddocs/content/4.api/1.components/3.content-navigation.md Outdated
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
@Tahul

Tahul commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

I love it as well! :)

Thanks a lot @harlan-zw 😄

@Tahul

Tahul commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

Hey @harlan-zw :)

After a brief discussion with @farnabaz ; I remembered we had plans on supporting the same type of query format as <ContentQuery /> has.

I will still merge this PR after applying some changes as we want to support both:

<script setup>constqueryBuilder=queryContent().where({ ... })</script>
<template>
<ContentNavigation :query="queryBuilder" />
<!-- OR (upcoming) -->
<ContentNavigation :where="{ ... }" />
</template>

@Tahul

Tahul commented Jun 3, 2022

Copy link
Copy Markdown
Contributor

Just added a test to cover your changes @harlan-zw, thank you again for this!

@TahulTahul changed the title feat(ContentNavigation): allow query prop to be QueryBuilder instancefeat(navigation): allow passing QueryBuilder or QueryBuilderParams in fetchNavigation or <ContentNavigation>Jun 3, 2022
@Tahul
Tahul merged commit afb791b into nuxt:mainJun 3, 2022
@harlan-zw

Copy link
Copy Markdown
ContributorAuthor

Hey @harlan-zw :)

After a brief discussion with @farnabaz ; I remembered we had plans on supporting the same type of query format as <ContentQuery /> has.

I will still merge this PR after applying some changes as we want to support both:

<script setup>
const queryBuilder = queryContent().where({ ... })
</script>
<template>
<ContentNavigation :query="queryBuilder" />
<!-- OR (upcoming) -->
<ContentNavigation :where="{ ... }" />
</template>

This would definitely be the ideal case, having all components with the same prop API for querying would be a great DX improvement.

@farnabazfarnabaz mentioned this pull request Aug 12, 2022
farnabaz pushed a commit that referenced this pull request Sep 7, 2022
… `fetchNavigation` or `<ContentNavigation>` (#1206)
Co-authored-by: Sébastien Chopin <seb@nuxtjs.com>
Co-authored-by: Yaël Guilloux <yael.guilloux@gmail.com>
Sign up for freeto 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.

3 participants

@harlan-zw@Tahul@atinux