mirror of
https://github.com/rwinkhart/glamour-temp-MUTN.git
synced 2026-09-06 08:57:14 -04:00
Embed styles in gold library
This commit is contained in:
@@ -2,8 +2,14 @@ package gold
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/lucasb-eyer/go-colorful"
|
||||
"github.com/rakyll/statik/fs"
|
||||
|
||||
_ "github.com/charmbracelet/gold/statik"
|
||||
)
|
||||
|
||||
type StyleType int
|
||||
@@ -63,6 +69,27 @@ type ElementStyle struct {
|
||||
Suffix string `json:"suffix"`
|
||||
}
|
||||
|
||||
func loadStyle(f string) ([]byte, error) {
|
||||
var r io.ReadCloser
|
||||
var err error
|
||||
|
||||
r, err = os.Open(f)
|
||||
if err != nil {
|
||||
statikFS, err := fs.New()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r, err = statikFS.Open("/" + f + ".json")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
defer r.Close()
|
||||
return ioutil.ReadAll(r)
|
||||
}
|
||||
|
||||
func cascadeStyles(onlyColors bool, s ...ElementStyle) ElementStyle {
|
||||
var r ElementStyle
|
||||
|
||||
|
||||
Reference in New Issue
Block a user