Skip to content

Commit

Permalink
11.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pookmish authored Feb 24, 2024
1 parent f840f73 commit 689866b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 18 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Stanford Profile

11.2.1
-------------------------------------------------------------------------------
- Provide items per page for graphql views
- Expose event image via graphql
- Added external image url for events content from Localist

11.2.1
-------------------------------------------------------------------------------
- Fixed logger syntax during site install.
Expand Down
2 changes: 1 addition & 1 deletion stanford_profile.info.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: 'Stanford Profile'
description: 'Jumpstart Website Profile'
version: 11.2.1
version: 11.2.2
type: profile
project: Stanford
core_version_requirement: ^9 || ^10
Expand Down

Large diffs are not rendered by default.

26 changes: 22 additions & 4 deletions themes/stanford_basic/algolia-search/src/algolia-search.island.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import algoliasearch from 'algoliasearch/lite';
import {createIslandWebComponent} from 'preact-island'
import {Hits, HitsProps, InstantSearch} from 'react-instantsearch';
import {Hits, HitsProps, InstantSearch, useHits} from 'react-instantsearch';
import SearchBox from "./search-box";
import EventHit from "./hits/events";
import NewsHit from "./hits/news";
Expand All @@ -9,8 +9,9 @@ import styled from "styled-components";
import {StanfordHit} from "./hits/hit.types";

const islandName = 'algolia-search'

const appId = window.drupalSettings?.stanfordAlgolia.appId || process.env.ALGOLIA_APP_ID
const key = window.drupalSettings?.stanfordAlgolia.searchKey || process.env.ALGOLIA_SEARCH_KEY
const key = window.drupalSettings?.stanfordAlgolia.searchKey || process.env.ALGOLIA_KEY

const searchClient = algoliasearch(appId, key);

Expand All @@ -32,6 +33,23 @@ const Container = styled.div`
}
`

const CustomHits = (props) => {
const {hits} = useHits(props);
if (hits.length === 0) return (
<p>No results for your search. Please try another search.</p>
)

return (
<ul>
{hits.map(hit =>
<li key={hit.objectID}>
<Hit hit={hit}/>
</li>
)}
</ul>
)
}

const Search = () => {
const currentUrl = new URL(window.location.href);
const initialSearch = currentUrl.searchParams.get('key');
Expand All @@ -46,8 +64,8 @@ const Search = () => {
}}
>
<Container>
<SearchBox/>
<Hits hitComponent={Hit} classNames={{list: "su-list-unstyled"}}/>
<SearchBox/>
<CustomHits/>
</Container>
</InstantSearch>
)
Expand Down
18 changes: 9 additions & 9 deletions themes/stanford_basic/algolia-search/src/hits/default-hit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ const DefaultHit = ({hit}) => {
</a>
</h2>

<p>
{hit.summary &&
{hit.summary &&
<p className="summary">
<Highlight hit={hit} attribute="summary"/>
}
</p>
}

{(!hit.summary && hit.html) &&
<>
...<Snippet hit={hit} attribute="html"/>...
</>
}
</p>
{(!hit.summary && hit.html) &&
<p>
<Snippet hit={hit} attribute="html"/>
</p>
}
</div>

{hit.updated &&
Expand Down

0 comments on commit 689866b

Please sign in to comment.