@@ -3,6 +3,8 @@ import { glossary } from "../lib/glossary";
3import { withRouter } from "next/router";
3import { withRouter } from "next/router";
4import debounce from "lodash.debounce";
4import debounce from "lodash.debounce";
5import Downshift from "downshift";
5import Downshift from "downshift";
6+import ob from "urbit-ob";
7+import Sigil from "../components/Sigil";
7class Search extends Component {
9class Search extends Component {
8 constructor(props) {
10 constructor(props) {
@@ -14,6 +16,7 @@ class Search extends Component {
14 this.onInputValueChange = this.onInputValueChange.bind(this);
16 this.onInputValueChange = this.onInputValueChange.bind(this);
15 this.onSelect = this.onSelect.bind(this);
17 this.onSelect = this.onSelect.bind(this);
16 this.glossarySearch = this.glossarySearch.bind(this);
18 this.glossarySearch = this.glossarySearch.bind(this);
19+ this.patpSearch = this.patpSearch.bind(this);
19 searchEndpoint(query) {
22 searchEndpoint(query) {
@@ -26,6 +29,10 @@ class Search extends Component {
33+ return ob.isValidPatp(`~${deSig(query.toLowerCase())}`) || !isNaN(query);
29 onSelect(item) {
36 onSelect(item) {
30 if (item.slug) {
37 if (item.slug) {
31 this.props.router.push(item.slug);
38 this.props.router.push(item.slug);
@@ -50,12 +57,30 @@ class Search extends Component {
50 content: item,
57 content: item,
60+ const patp = this.patpSearch(query)
63+ : ob.patp(ob.patp2dec(`~${deSig(query)}`))
66+ const patpResult = this.patpSearch(query)
53 const glossaryResults = this.glossarySearch(query).map((item) => ({
78 const glossaryResults = this.glossarySearch(query).map((item) => ({
54 type: "GLOSSARY_RESULT",
79 type: "GLOSSARY_RESULT",
55 content: item,
80 content: item,
58− const list = [...glossaryResults, ...results];
83+ const list = [...patpResult, ...glossaryResults, ...results];
60 this.setState({ results: list });
85 this.setState({ results: list });
@@ -117,6 +142,30 @@ class Search extends Component {
118 ? state.results.map((item, index) => {
143 ? state.results.map((item, index) => {
119 const selected = highlightedIndex === index;
144 const selected = highlightedIndex === index;
145+ if (item.type === "PATP") {
148+ className={`cursor-pointer p-2 flex space-x-2 items-center text-left w-full ${
149+ selected ? "bg-green-400" : ""
152+ key: item.content.slug + "-" + index,
155+ selected: highlightedIndex === index,
158+ <div className="rounded-md overflow-hidden">
160+ patp={item.content.patp}
165+ <p className="font-mono">{item.content.patp}</p>
120 if (item.type === "GLOSSARY_RESULT") {
169 if (item.type === "GLOSSARY_RESULT") {
@@ -210,4 +259,8 @@ class Search extends Component {
262+function deSig(string) {
263+ return string.startsWith("~") ? string.substring(1) : string;
213export default withRouter(Search);
266export default withRouter(Search);