Skip to content

Commit

Permalink
Merge pull request #747 from dpc-sdp/feature/search-fixes
Browse files Browse the repository at this point in the history
[R20-1337][R20-1339] Scope site search to site and content types
  • Loading branch information
jeffdowdle authored Aug 7, 2023
2 parents 9eaaa95 + a5098ff commit 47d3a08
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/nuxt-ripple/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ declare module '@nuxt/schema' {
rtl?: boolean
}
search?: {
contentTypes: string[]
filterFunctions?: Record<
string,
(filterConfig: any, values: string[]) => void
Expand Down
14 changes: 14 additions & 0 deletions packages/ripple-tide-search/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default defineAppConfig({
ripple: {
search: {
contentTypes: [
'landing_page',
'event',
'grant',
'news',
'publication',
'publication_page'
]
}
}
})
14 changes: 3 additions & 11 deletions packages/ripple-tide-search/components/TideSearchPage.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed, ref } from 'vue'

Check warning on line 2 in packages/ripple-tide-search/components/TideSearchPage.vue

View workflow job for this annotation

GitHub Actions / Test

'computed' is defined but never used. Allowed unused vars must match /props/u

Check warning on line 2 in packages/ripple-tide-search/components/TideSearchPage.vue

View workflow job for this annotation

GitHub Actions / Test

'computed' is defined but never used. Allowed unused vars must match /props/u
import { useRuntimeConfig, useFetch, useRoute } from '#imports'
import { useRuntimeConfig, useTideSite, useRoute } from '#imports'

Check warning on line 3 in packages/ripple-tide-search/components/TideSearchPage.vue

View workflow job for this annotation

GitHub Actions / Test

'useRoute' is defined but never used. Allowed unused vars must match /props/u

Check warning on line 3 in packages/ripple-tide-search/components/TideSearchPage.vue

View workflow job for this annotation

GitHub Actions / Test

'useRoute' is defined but never used. Allowed unused vars must match /props/u
import useSearchUI from './../composables/useSearchUI'
import {
AppSearchFilterConfigItem,
Expand Down Expand Up @@ -53,16 +53,8 @@ const props = withDefaults(defineProps<Props>(), {
}
})
const route = useRoute()
const { public: config } = useRuntimeConfig()
const siteId = config.tide?.site
const { data: site } = useFetch('/api/tide/site', {
baseURL: config.apiUrl || '',
params: {
id: siteId
}
})
const site = await useTideSite()
const apiConnectorOptions = {
...config.tide?.appSearch,
Expand Down Expand Up @@ -115,7 +107,7 @@ const getFilterOptions = (field) => {
</script>

<template>
<TideBaseLayout :site="site">
<TideBaseLayout>
<template #aboveBody>
<RplHeroHeader
:title="pageTitle"
Expand Down
15 changes: 14 additions & 1 deletion packages/ripple-tide-search/pages/search.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<script setup lang="ts">
import { AppSearchFilterConfigItem, MappedSearchResult } from '../types'
import { formatDate } from '#imports'
import { formatDate, useRuntimeConfig, useAppConfig } from '#imports'
const appConfig = useAppConfig()
const runtimeConfig = useRuntimeConfig()
const filtersConfig: AppSearchFilterConfigItem[] = [
{
Expand All @@ -15,6 +18,16 @@ const searchDriverOptions = {
initialState: { resultsPerPage: 10 },
alwaysSearchOnInitialLoad: true,
searchQuery: {
filters: [
{
field: 'field_node_site',
values: [runtimeConfig.public.tide?.site]
},
{
field: 'type',
values: appConfig.ripple?.search?.contentTypes
}
],
search_fields: {
title: {
weight: 10
Expand Down

0 comments on commit 47d3a08

Please sign in to comment.