Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to search description #132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ under the `config_images` folder.
search_title: "My application"

# Define the description to render opposite the logo and title.
# Note that this description is rendered as markdown, to enable for example link to a website
search_description: "Data that speaks for itself"

# Define the placeholder text inside the search box.
Expand Down Expand Up @@ -304,6 +305,8 @@ By default, Vectara Answer runs locally on your machine using `npm run start`. T

Please see these detailed [instructions](DOCKER.md) for more details on using Docker.

Note: the latest release of Vectara Answer is hosted on [docker-hub](https://hub.docker.com/repository/docker/vectara/vectara-answer/general), so if you want to pull it locally (instead of building) you can always use that image.

## Author

👤 **Vectara**
Expand Down
12 changes: 8 additions & 4 deletions src/views/search/controls/SearchControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { useSearchContext } from "../../../contexts/SearchContext";
import "./searchControls.scss";
import { HistoryDrawer } from "./HistoryDrawer";
import { OptionsDrawer } from "./OptionsDrawer";
import Markdown from "markdown-to-jsx";

type Props = {
hasQuery: boolean;
Expand Down Expand Up @@ -102,11 +103,14 @@ export const SearchControls = ({ hasQuery }: Props) => {
<VuiFlexContainer alignItems="center" spacing="m">
{searchHeader.description && (
<VuiFlexItem grow={false}>
<VuiTitle size="xxs" align="right">
<VuiTitle size="xs" align="right">
<VuiTextColor color="subdued">
<h2 style={{ whiteSpace: "pre-line" }}>
{searchHeader.description.replaceAll("\\n", "\n")}
</h2>
<Markdown
Copy link
Collaborator

@cjcenizal cjcenizal Jan 10, 2024

Choose a reason for hiding this comment

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

Markdown will enable elements here that don't belong, such as lists, tables, and multiple paragraphs. This seems like overkill for the stated problem.

I think a more targeted solution would be to add a searchHeader.descriptionUrl option. Then this code would conditionally render a link if that option is defined. What do you think of this approach?

const searchHeaderDescription = searchHeader.description.replaceAll("\\n", "\n");

const searchHeaderContent = searchHeader.descriptionUrl ? (
  <a href={searchHeader.descriptionUrl}>{searchHeaderDescription}</a>
) : searchHeaderDescription;

return (
  <VuiTextColor color="subdued">
    <h2 style={{ whiteSpace: "pre-line" }}>
      {searchHeaderContent}
    </h2>
  </VuiTextColor>
);

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So in this way the whole description is a single URL right?
In this case, the idea was to have something like "Created by Bob Gourley (OODA)" where only OODA is a URL linking to Bob's website. Any good way to do that?
I think Markdown can also be useful to do multi-line descriptions that we want to control the line breaks e.g. with

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I'd probably make the whole thing a link or I'd add a location in the UI for rendering some kind of authorship link. I'll approve this PR to unblock you though.

children={searchHeader.description}
options={{
forceBlock: true,
}}
/>
</VuiTextColor>
</VuiTitle>
</VuiFlexItem>
Expand Down