@@ -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 ( / < p r e > [ \r \n ] * ( [ ^ ] + ?) [ \r \n ] * < \/ p r e > / 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
177201interface IDescription {
0 commit comments