1+ import { createMemo } from 'solid-js' ;
12/**
23 * 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
67 */
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 ;
1111
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 \+ / , '' ) ;
1517
16- data = data . replace ( / ^ g i t \+ / , '' ) ;
17- // Double check
18- cornerExternalLinkTarge = cornerExternalLinkTarge || '_blank' ;
18+ return result ;
19+ } ) ;
1920
2021 return (
2122 < a
22- href = { data }
23- target = { cornerExternalLinkTarge }
23+ href = { processedUrl ( ) }
24+ target = { props . cornerExternalLinkTarget || '_blank' }
2425 class = "github-corner"
2526 aria-label = "View source on Github"
2627 >
@@ -45,9 +46,8 @@ export function corner(data, cornerExternalLinkTarge) {
4546/**
4647 * Renders main content
4748 * @param {Object } config Configuration object
48- * @returns {String } HTML of the main content
4949 */
50- export function main ( config ) {
50+ export function Main ( config ) {
5151 const name = config . name ? config . name : '' ;
5252
5353 const aside = (
@@ -90,7 +90,7 @@ export function main(config) {
9090 * Cover Page
9191 * @returns {String } Cover page
9292 */
93- export function cover ( ) {
93+ export function Cover ( ) {
9494 const SL = ', 100%, 85%' ;
9595 const bgc =
9696 'linear-gradient(to left bottom, ' +
@@ -104,9 +104,9 @@ export function cover() {
104104 </ section >
105105 ) ;
106106
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.
110110 // console.log('cover style?', el.style.background);
111111
112112 return el ;
@@ -142,11 +142,12 @@ export function markdownParagraph(className, content) {
142142 return `<p class="${ className } ">${ content . slice ( 5 ) . trim ( ) } </p>` ;
143143}
144144
145- export function theme ( color ) {
145+ /** @param {{color: string} } props */
146+ export function Theme ( props ) {
146147 return (
147148 < style > { /* css */ `
148149 :root {
149- --theme-color: ${ color } ;
150+ --theme-color: ${ props . color } ;
150151 }
151152 ` } </ style >
152153 ) ;
0 commit comments