-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from nickarellano/main
Dark Mode support example
- Loading branch information
Showing
1 changed file
with
8 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,19 @@ | ||
package payloads | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/davecgh/go-spew/spew" | ||
"github.com/gomarkdown/markdown" | ||
) | ||
|
||
// NewDumpPayload creates a new Dump Payload | ||
func NewDumpPayload(value interface{}) Payload { | ||
style := ` | ||
<style> | ||
.go-dump pre { | ||
position:relative; | ||
overflow-x: auto; | ||
width: 100%; | ||
padding: 10px 10px; | ||
height: auto; | ||
background-color: #f3f3f3; | ||
} | ||
</style>` | ||
md := []byte("``` \n"+spew.Sdump(value)+"\n```") | ||
md := []byte("``` \n" + spew.Sdump(value) + "\n```") | ||
output := markdown.ToHTML(md, nil, nil) | ||
return NewCustomPayload(style+`<div class="go-dump">`+string(output) + "</div>", "") | ||
styledOutput := strings.Replace(string(output), "<pre><code>", strings.Join([]string{ | ||
`<pre class="relative overflow-x-auto w-full p-5 h-auto bg-gray-100 dark:bg-gray-800">`, | ||
`<code class="h-auto">`, | ||
}, ""), 1) | ||
return NewCustomPayload(styledOutput, "") | ||
} |