File tree Expand file tree Collapse file tree 1 file changed +27
-2
lines changed
Expand file tree Collapse file tree 1 file changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,18 @@ export const italic: Callback<any> = () => {
2525 return { open, close }
2626}
2727
28+ export const link : Callback < any > = ( ) => {
29+ const open = ( tag : string ) => {
30+ return `<a href="${ tag } " target="_blank" class="underline text-xs">`
31+ }
32+
33+ const close = ( ) => {
34+ return ' </a>'
35+ }
36+
37+ return { open, close }
38+ }
39+
2840export const useRaw : Callback < any > = ( ) => {
2941 const convert = ( page : ContextStatePageContent ) => {
3042 let final = ''
@@ -35,8 +47,21 @@ export const useRaw: Callback<any> = () => {
3547
3648 if ( page . type !== 'paragraph' ) return page . raw
3749
38- for ( let i = 0 ; i < page . raw . length ; i ++ ) {
39- const letter = page . raw . charAt ( i )
50+ const over : Array < string > = [ ]
51+
52+ let _raw = page . raw
53+
54+ page . raw . split ( / [ , ] + / ) . forEach ( ( word : string ) => {
55+ console . log ( word )
56+ if ( word . includes ( 'http' ) ) over . push ( word )
57+ } )
58+
59+ over . forEach ( ( word : string ) => {
60+ _raw = _raw . replace ( word , `${ link ( ) . open ( word ) } ${ word } ${ link ( ) . close ( ) } ` )
61+ } )
62+
63+ for ( let i = 0 ; i < _raw . length ; i ++ ) {
64+ const letter = _raw . charAt ( i )
4065
4166 if ( letter === '*' && ! _italic ) {
4267 _italic = true
You can’t perform that action at this time.
0 commit comments