1
+ import { createMemo } from 'solid-js' ;
1
2
/**
2
3
* Render github corner
3
- * @param {Object } data URL for the View Source on Github link
4
- * @param { String } cornerExternalLinkTarge value of the target attribute of the link
5
- * @return { String } SVG element as string
4
+ * @param {Object } props
5
+ * @param { string } props.githubUrl URL for the View Source on Github link
6
+ * @param { string= } props.cornerExternalLinkTarget value of the target attribute of the link
6
7
*/
7
- export function corner ( data , cornerExternalLinkTarge ) {
8
- if ( ! data ) {
9
- return '' ;
10
- }
8
+ export function GithubCorner ( props ) {
9
+ const processedUrl = createMemo ( ( ) => {
10
+ let result = props . githubUrl ;
11
11
12
- if ( ! / \/ \/ / . test ( data ) ) {
13
- data = 'https://github.com/' + data ;
14
- }
12
+ if ( ! / \/ \/ / . test ( result ) ) {
13
+ result = 'https://github.com/' + result ;
14
+ }
15
+
16
+ result = result . replace ( / ^ g i t \+ / , '' ) ;
15
17
16
- data = data . replace ( / ^ g i t \+ / , '' ) ;
17
- // Double check
18
- cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank' ;
18
+ return result ;
19
+ } ) ;
19
20
20
21
return (
21
22
< a
22
- href = { data }
23
- target = { cornerExternalLinkTarge }
23
+ href = { processedUrl ( ) }
24
+ target = { props . cornerExternalLinkTarget || '_blank' }
24
25
class = "github-corner"
25
26
aria-label = "View source on Github"
26
27
>
@@ -45,9 +46,8 @@ export function corner(data, cornerExternalLinkTarge) {
45
46
/**
46
47
* Renders main content
47
48
* @param {Object } config Configuration object
48
- * @returns {String } HTML of the main content
49
49
*/
50
- export function main ( config ) {
50
+ export function Main ( config ) {
51
51
const name = config . name ? config . name : '' ;
52
52
53
53
const aside = (
@@ -90,7 +90,7 @@ export function main(config) {
90
90
* Cover Page
91
91
* @returns {String } Cover page
92
92
*/
93
- export function cover ( ) {
93
+ export function Cover ( ) {
94
94
const SL = ', 100%, 85%' ;
95
95
const bgc =
96
96
'linear-gradient(to left bottom, ' +
@@ -104,9 +104,9 @@ export function cover() {
104
104
</ section >
105
105
) ;
106
106
107
- // Bug with Jest/jsdom: at this point, the styles exist, Docsify works
108
- // and this log will show the background value. But only during Jest tests, the
109
- // bakground value is empty. This is why the snapshot
107
+ // JEST_JSDOM_BUG: At this point, the styles exist, Docsify works and this log
108
+ // will show the background value. But only during Jest tests, the bakground
109
+ // value is empty.
110
110
// console.log('cover style?', el.style.background);
111
111
112
112
return el ;
@@ -142,11 +142,12 @@ export function markdownParagraph(className, content) {
142
142
return `<p class="${ className } ">${ content . slice ( 5 ) . trim ( ) } </p>` ;
143
143
}
144
144
145
- export function theme ( color ) {
145
+ /** @param {{color: string} } props */
146
+ export function Theme ( props ) {
146
147
return (
147
148
< style > { /* css */ `
148
149
:root {
149
- --theme-color: ${ color } ;
150
+ --theme-color: ${ props . color } ;
150
151
}
151
152
` } </ style >
152
153
) ;
0 commit comments