Skip to content

Commit e75643a

Browse files
committed
all: more unification of star formatting
1 parent a436733 commit e75643a

2 files changed

Lines changed: 21 additions & 25 deletions

File tree

‎src/components/findNotebooks.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function NotebookPeek({ notebook, src }: { notebook: SearchNotebook; src: Source
136136
} catch (e) {
137137
console.warn(`notebook ${notebook.id}: invalid date: ${e}`);
138138
}
139-
const preview = `**${notebook.title}** ${notebook.stars?.totalCount ? `| ${notebook.stars.totalCount} stars` : ""}
139+
const preview = `**${notebook.title}** ${notebook.stars?.totalCount ? `- ${notebook.stars.totalCount} ★` : ""}
140140
141141
> ${blurb}
142142

‎src/components/search.tsx‎

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,10 @@ function SearchResultItem({
218218
);
219219
}
220220

221-
function getPeekFields(match: SearchMatch) {
222-
const navigationTitle = `Peek ${match.type} result`;
223-
const matchTitle = `${match.repository} ${match.repoStars ? `(${match.repoStars} ★)` : ""}`;
224-
return { navigationTitle, matchTitle };
225-
}
226-
227221
function MultiResultPeek({ searchResult }: { searchResult: { url: string; match: ContentMatch | SymbolMatch } }) {
228222
const { match } = searchResult;
229-
const { navigationTitle, matchTitle } = getPeekFields(match);
223+
const navigationTitle = `Peek ${match.type} results`;
224+
const matchTitle = `${match.repository} ${match.repoStars ? `(${match.repoStars} ★)` : ""}`;
230225

231226
// Match types with expanded peek support
232227
switch (match.type) {
@@ -267,7 +262,8 @@ function MultiResultPeek({ searchResult }: { searchResult: { url: string; match:
267262

268263
function PeekSearchResult({ searchResult }: { searchResult: SearchResult }) {
269264
const { match } = searchResult;
270-
const { navigationTitle, matchTitle } = getPeekFields(match);
265+
const navigationTitle = `Peek ${match.type} result`;
266+
const matchTitle = `**${match.repository}** ${match.repoStars ? `- ${match.repoStars} ★` : ""}`;
271267

272268
// Match types that use markdown view support
273269
let markdownContent = "";
@@ -279,29 +275,29 @@ function PeekSearchResult({ searchResult }: { searchResult: SearchResult }) {
279275
case "repo":
280276
markdownContent = `> ${match.private ? "Private" : "Public"} ${match.type} match
281277
282-
---
283-
284-
${match.description || ""}`;
278+
---
279+
280+
${match.description || ""}`;
285281
break;
286282

287283
case "path":
288284
markdownContent = `> ${match.type} match
289-
290-
---
291-
292-
\`${match.path}\`
293-
`;
285+
286+
---
287+
288+
\`${match.path}\`
289+
`;
294290
break;
295291

296292
case "commit":
297293
markdownContent = `> ${match.type} match in ${match.detail}
298294
299-
---
300-
301-
${match.label}
302-
303-
${match.content}
304-
`;
295+
---
296+
297+
${match.label}
298+
299+
${match.content}
300+
`;
305301
break;
306302

307303
default:
@@ -310,13 +306,13 @@ function PeekSearchResult({ searchResult }: { searchResult: SearchResult }) {
310306
\`\`\`
311307
${JSON.stringify(match, null, " ")}
312308
\`\`\`
313-
`;
309+
`;
314310
}
315311

316312
return (
317313
<Detail
318314
navigationTitle={navigationTitle}
319-
markdown={`## ${matchTitle}\n\n${markdownContent}`}
315+
markdown={`${matchTitle}\n\n${markdownContent}`}
320316
actions={<ActionPanel>{resultActions(searchResult.url)}</ActionPanel>}
321317
></Detail>
322318
);

0 commit comments

Comments
 (0)