Skip to content

Commit 0e4ded8

Browse files
committed
chore(*): move link to headline
1 parent 79e7f9f commit 0e4ded8

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

src/functions/algoliaResponse.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ export async function algoliaResponse(
4545
: null;
4646

4747
const contentParts = [
48-
`<:${emojiName}:${emojiId}> ${bold(resolveHitToNamestring(hit))}${headlineSuffix ? ` ${headlineSuffix}` : ''}`,
48+
`<:${emojiName}:${emojiId}> ${hyperlink(
49+
bold(resolveHitToNamestring(hit)),
50+
hit.url,
51+
)}${headlineSuffix ? ` ${headlineSuffix}` : ''}`,
4952
];
5053

5154
if (hit.content?.length) {
@@ -67,8 +70,6 @@ export async function algoliaResponse(
6770
}
6871
}
6972

70-
contentParts.push(`${hyperlink('read more', hideLinkEmbed(hit.url))}`);
71-
7273
prepareResponse(res, contentParts.join('\n'), {
7374
ephemeral,
7475
suggestion: user ? { userId: user, kind: type } : undefined,

src/functions/oramaResponse.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ export async function oramaResponse(res: Response, resultUrl: string, user?: str
5656

5757
const section = findRelevantDocsSection(`#${parsed.anchor ?? parsed.endpoint}`, docsContents, !parsed.anchor);
5858

59-
if (section) {
60-
const title = section.headline ?? parsed.endpoint ?? 'No Title';
61-
contentParts.push(`<:guide:${EMOJI_ID_GUIDE}> ${bold(title)}`);
62-
}
59+
const title = section?.headline ?? parsed.endpoint ?? 'discord.js guide';
60+
contentParts.push(`<:guide:${EMOJI_ID_GUIDE}> ${hyperlink(bold(title), parsed.guideUrl)}`);
6361

6462
const relevantLines = noCodeLines(section?.lines ?? []);
6563
if (relevantLines.length) {
@@ -82,8 +80,6 @@ export async function oramaResponse(res: Response, resultUrl: string, user?: str
8280
}
8381
}
8482

85-
contentParts.push(hyperlink('read more', parsed.guideUrl));
86-
8783
prepareResponse(res, contentParts.join('\n'), {
8884
ephemeral,
8985
suggestion: user ? { userId: user, kind: 'guide' } : undefined,

src/util/discordDocs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function parseSections(content: string): ParsedSection[] {
128128
}
129129

130130
function formatAnchor(text: string) {
131-
return `#${text.toLowerCase().replaceAll(' ', '-').replaceAll(/[:'.]/gi, '')}`;
131+
return `#${text.toLowerCase().replaceAll(' ', '-').replaceAll(/['.:]/gi, '')}`;
132132
}
133133

134134
export function findRelevantDocsSection(query: string, docsMd: string, defaultFirst = false) {

0 commit comments

Comments
 (0)