Skip to content

Commit 825ca17

Browse files
committed
Move the link position to the bottom of the page
1 parent f790600 commit 825ca17

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

ACKNOWLEDGEMENTS.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
A big thanks to the following individuals for contributing:
44

5+
- [@JIEJIAN21](https://github.com/JIEJIAN21) - thanks for logo and icon design
56
- [@TsFreddie](https://github.com/TsFreddie)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=TsFreddie)
67
- [@ntt2k](https://github.com/ntt2k)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=ntt2k)
78
- [@purocean](https://github.com/purocean)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=purocean)
@@ -17,4 +18,5 @@ A big thanks to the following individuals for contributing:
1718
- [@houtianze](https://github.com/houtianze)[contributions](https://github.com/jdneo/vscode-leetcode/commits?author=houtianze)
1819
- [@magic-akari](https://github.com/magic-akari) - [contributions](https://github.com/jdneo/vscode-leetcode/commits?author=magic-akari)
1920
- [@SF-Zhou](https://github.com/SF-Zhou) - [contributions](https://github.com/jdneo/vscode-leetcode/commits?author=SF-Zhou)
20-
- [@JIEJIAN21](https://github.com/JIEJIAN21) - thanks for logo and icon design
21+
- [@fuafa](https://github.com/fuafa) - [contributions](https://github.com/jdneo/vscode-leetcode/commits?author=fuafa)
22+
- [@iFun](https://github.com/iFun) - [contributions](https://github.com/jdneo/vscode-leetcode/commits?author=iFun)

src/webview/leetCodePreviewProvider.ts

+27-3
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
7373
const { title, url, category, difficulty, likes, dislikes, body } = this.description;
7474
const head: string = markdownEngine.render(`# [${title}](${url})`);
7575
const info: string = markdownEngine.render([
76-
`| Category | Difficulty | Likes | Dislikes | [Discuss](${url.replace("/description/", "/discuss/?currentPage=1&orderBy=most_votes&query=")}) | [Solution](${url.replace("/description/", "/solution/")}) |`,
77-
`| :------: | :--------: | :---: | :------: | :-----: | :------: |`,
78-
`| ${category} | ${difficulty} | ${likes} | ${dislikes} | -- | -- |`,
76+
`| Category | Difficulty | Likes | Dislikes |`,
77+
`| :------: | :--------: | :---: | :------: |`,
78+
`| ${category} | ${difficulty} | ${likes} | ${dislikes} |`,
7979
].join("\n"));
8080
const tags: string = [
8181
`<details>`,
@@ -97,6 +97,11 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
9797
),
9898
`</details>`,
9999
].join("\n");
100+
const links: string = markdownEngine.render([
101+
`---`,
102+
`- [Discussion](${this.getDiscussionLink(url)})`,
103+
`- [Solution](${this.getSolutionLink(url)})`,
104+
].join("\n"));
100105
return `
101106
<!DOCTYPE html>
102107
<html>
@@ -114,6 +119,7 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
114119
${tags}
115120
${companies}
116121
${body}
122+
${links}
117123
${!this.sideMode ? button.element : ""}
118124
<script>
119125
const vscode = acquireVsCodeApi();
@@ -172,6 +178,24 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
172178
body: body.join("\n").replace(/<pre>[\r\n]*([^]+?)[\r\n]*<\/pre>/g, "<pre><code>$1</code></pre>"),
173179
};
174180
}
181+
182+
private getDiscussionLink(url: string): string {
183+
if (url.includes("leetcode-cn.com")) {
184+
return url.replace("/description/", "/comments/");
185+
} else if (url.includes("leetcode.com")) {
186+
return url.replace("/description/", "/discuss/?currentPage=1&orderBy=most_votes&query=");
187+
}
188+
189+
return "https://leetcode.com";
190+
}
191+
192+
private getSolutionLink(url: string): string {
193+
if (url.includes("leetcode-cn.com") || url.includes("leetcode.com")) {
194+
return url.replace("/description/", "/solution/");
195+
}
196+
197+
return "https://leetcode.com";
198+
}
175199
}
176200

177201
interface IDescription {

0 commit comments

Comments
 (0)