@@ -6,7 +6,7 @@ import * as MarkdownIt from "markdown-it";
6
6
import * as path from "path" ;
7
7
import * as vscode from "vscode" ;
8
8
import { Disposable , ExtensionContext , ViewColumn , WebviewPanel , window } from "vscode" ;
9
- import { Solution } from "./shared" ;
9
+ import { IProblem , Solution } from "./shared" ;
10
10
11
11
class LeetCodeSolutionProvider implements Disposable {
12
12
@@ -37,7 +37,7 @@ class LeetCodeSolutionProvider implements Disposable {
37
37
} ;
38
38
}
39
39
40
- public async show ( solutionString : string ) : Promise < void > {
40
+ public async show ( solutionString : string , problem : IProblem ) : Promise < void > {
41
41
if ( ! this . panel ) {
42
42
this . panel = window . createWebviewPanel ( "leetCode" , "Top voted solution" , ViewColumn . Active , {
43
43
retainContextWhenHidden : true ,
@@ -51,7 +51,7 @@ class LeetCodeSolutionProvider implements Disposable {
51
51
}
52
52
53
53
this . solution = this . parseSolution ( solutionString ) ;
54
- this . panel . title = this . solution . title ;
54
+ this . panel . title = problem . name ;
55
55
this . panel . webview . html = this . getWebViewContent ( this . solution ) ;
56
56
this . panel . reveal ( ViewColumn . Active ) ;
57
57
}
@@ -96,6 +96,14 @@ class LeetCodeSolutionProvider implements Disposable {
96
96
const styles : string = this . getMarkdownStyles ( )
97
97
. map ( ( style : vscode . Uri ) => `<link rel="stylesheet" type="text/css" href="${ style . toString ( ) } ">` )
98
98
. join ( "\n" ) ;
99
+ const { title, url, lang, author, votes } = solution ;
100
+ const head : string = this . markdown . render ( `# [${ title } ](${ url } )` ) ;
101
+ const auth : string = `[${ author } ](https://leetcode.com/${ author } /)` ;
102
+ const info : string = this . markdown . render ( [
103
+ `| Language | Author | Votes |` ,
104
+ `| :------: | :------: | :------: |` ,
105
+ `| ${ lang } | ${ auth } | ${ votes } |` ,
106
+ ] . join ( "\n" ) ) ;
99
107
const body : string = this . markdown . render ( solution . body ) ;
100
108
return `
101
109
<!DOCTYPE html>
@@ -104,6 +112,8 @@ class LeetCodeSolutionProvider implements Disposable {
104
112
${ styles }
105
113
</head>
106
114
<body class="vscode-body 'scrollBeyondLastLine' 'wordWrap' 'showEditorSelection'" style="tab-size:4">
115
+ ${ head }
116
+ ${ info }
107
117
${ body }
108
118
</body>
109
119
</html>
0 commit comments