Skip to content

Commit

Permalink
feat(fetchcontentnavigation): apply changes from #1205
Browse files Browse the repository at this point in the history
  • Loading branch information
Tahul committed Jun 3, 2022
1 parent a9ea149 commit 267e4b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/runtime/components/ContentNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PropType, toRefs, defineComponent, h, useSlots, computed } from 'vue'
import { hash } from 'ohash'
import type { NavItem, QueryBuilderParams } from '../types'
import { QueryBuilder } from '../types'
import { useAsyncData, queryContent, fetchContentNavigation } from '#imports'
import { useAsyncData, fetchContentNavigation } from '#imports'

export default defineComponent({
props: {
Expand Down
10 changes: 7 additions & 3 deletions src/runtime/composables/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { hash } from 'ohash'
import { useHead, useCookie } from '#app'
import type { NavItem, QueryBuilder } from '../types'
import type { NavItem, QueryBuilder, QueryBuilderParams } from '../types'
import { jsonStringify } from '../utils/json'
import { withContentBase } from './utils'

export const fetchContentNavigation = (queryBuilder?: QueryBuilder) => {
const params = queryBuilder?.params()
export const fetchContentNavigation = (queryBuilder?: QueryBuilder | QueryBuilderParams) => {
let params = queryBuilder

// When params is an instance of QueryBuilder then we need to pick the params explicitly
if (typeof params?.params === 'function') { params = params.params() }

const apiPath = withContentBase(params ? `/navigation/${hash(params)}` : '/navigation')

if (!process.dev && process.server) {
Expand Down

0 comments on commit 267e4b7

Please sign in to comment.