mirror of
https://github.com/wassname/stampy-chat.git
synced 2026-09-11 12:50:34 +08:00
rename element to be more accurate
This commit is contained in:
@@ -10,11 +10,12 @@ export type Glossary = Map<string, GlossaryItem>;
|
||||
|
||||
export const GlossaryContext = createContext<{g: Glossary, r: RegExp} | null>(null);
|
||||
|
||||
// A component which wraps a paragraph and injects glossary terms into it as
|
||||
// hoverable pop-up links. The text is immediately rendered normally, but after
|
||||
// the glossary is loaded (which happens once per page, asynchronously), the
|
||||
// glossary terms are replaced with elements.
|
||||
export const GlossaryP: React.FC<{content: string}> = ({content}) => {
|
||||
// A component which wraps arbitrary html in a span, and injects glossary terms
|
||||
// into it as hoverable pop-up links. The text is immediately rendered normally,
|
||||
// but after the glossary is loaded (which happens once per page, asynchronously),
|
||||
// the glossary terms are replaced with elements.
|
||||
|
||||
export const GlossarySpan: React.FC<{content: string}> = ({content}) => {
|
||||
|
||||
const g = useContext(GlossaryContext);
|
||||
|
||||
|
||||
@@ -43,5 +43,3 @@ const tempHackFetch = (_url: string) => {
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import Image from 'next/image';
|
||||
import Header from "../header";
|
||||
import { SearchBox, Followup } from "../searchbox";
|
||||
import logo from "../logo.svg"
|
||||
import { GlossaryP } from "../glossary";
|
||||
import { GlossarySpan } from "../glossary";
|
||||
|
||||
type Citation = {
|
||||
title: string;
|
||||
@@ -203,7 +203,7 @@ const ShowAssistantEntry: React.FC<{entry: AssistantEntry}> = ({entry}) => {
|
||||
response.split("\n").map(paragraph => ( <p> {
|
||||
paragraph.split(in_text_citation_regex).map((text, i) => {
|
||||
if (i % 2 === 0) {
|
||||
return <GlossaryP content={text.trim()} />;
|
||||
return <GlossarySpan content={text.trim()} />;
|
||||
}
|
||||
i = parseInt(text) - 1;
|
||||
if (!citations.has(i)) return `[${text}]`;
|
||||
|
||||
Reference in New Issue
Block a user