@@ -73,9 +73,9 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
73
73
const { title, url, category, difficulty, likes, dislikes, body } = this . description ;
74
74
const head : string = markdownEngine . render ( `# [${ title } ](${ url } )` ) ;
75
75
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 } |` ,
79
79
] . join ( "\n" ) ) ;
80
80
const tags : string = [
81
81
`<details>` ,
@@ -97,6 +97,11 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
97
97
) ,
98
98
`</details>` ,
99
99
] . join ( "\n" ) ;
100
+ const links : string = markdownEngine . render ( [
101
+ `---` ,
102
+ `- [Discussion](${ this . getDiscussionLink ( url ) } )` ,
103
+ `- [Solution](${ this . getSolutionLink ( url ) } )` ,
104
+ ] . join ( "\n" ) ) ;
100
105
return `
101
106
<!DOCTYPE html>
102
107
<html>
@@ -114,6 +119,7 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
114
119
${ tags }
115
120
${ companies }
116
121
${ body }
122
+ ${ links }
117
123
${ ! this . sideMode ? button . element : "" }
118
124
<script>
119
125
const vscode = acquireVsCodeApi();
@@ -172,6 +178,24 @@ class LeetCodePreviewProvider extends LeetCodeWebview {
172
178
body : body . join ( "\n" ) . replace ( / < p r e > [ \r \n ] * ( [ ^ ] + ?) [ \r \n ] * < \/ p r e > / g, "<pre><code>$1</code></pre>" ) ,
173
179
} ;
174
180
}
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
+ }
175
199
}
176
200
177
201
interface IDescription {
0 commit comments