Browse Source

Fix styles

master
Jan-Lukas Else 3 weeks ago
parent
commit
aabdde7d39
  1. 4
      go.mod
  2. 8
      go.sum
  3. 37
      highlighting.go
  4. 2
      markdown.go
  5. 21
      original-assets/styles/styles.scss
  6. 8
      templateAssets.go
  7. 13
      templates/assets/css/styles.css

4
go.mod

@ -18,7 +18,7 @@ require (
github.com/elnormous/contenttype v1.0.0
github.com/emersion/go-sasl v0.0.0-20211008083017-0b9dcfb154ac
github.com/emersion/go-smtp v0.15.0
github.com/go-chi/chi/v5 v5.0.5
github.com/go-chi/chi/v5 v5.0.6
github.com/go-fed/httpsig v1.1.0
github.com/gorilla/handlers v1.5.1
github.com/gorilla/securecookie v1.1.1
@ -50,7 +50,7 @@ require (
// master
github.com/yuin/goldmark-emoji v1.0.2-0.20210607094911-0487583eca38
github.com/yuin/goldmark-highlighting v0.0.0-20210516132338-9216f9c5aa01
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa
golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/text v0.3.7

8
go.sum

@ -148,8 +148,8 @@ github.com/fsnotify/fsnotify v1.5.1/go.mod h1:T3375wBYaZdLLcVNkcVbzGHY7f1l/uK5T5
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/github/fakeca v0.1.0 h1:Km/MVOFvclqxPM9dZBC4+QE564nU4gz4iZ0D9pMw28I=
github.com/github/fakeca v0.1.0/go.mod h1:+bormgoGMMuamOscx7N91aOuUST7wdaJ2rNjeohylyo=
github.com/go-chi/chi/v5 v5.0.5 h1:l3RJ8T8TAqLsXFfah+RA6N4pydMbPwSdvNM+AFWvLUM=
github.com/go-chi/chi/v5 v5.0.5/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-chi/chi/v5 v5.0.6 h1:CHIMAkr36TRf/zYvOqNKklMDxEm9HuqdiK+syK+tYtw=
github.com/go-chi/chi/v5 v5.0.6/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/go-fed/httpsig v1.1.0 h1:9M+hb0jkEICD8/cAiNqEB66R87tTINszBRTjwjQzWcI=
github.com/go-fed/httpsig v1.1.0/go.mod h1:RCMrTZvN1bJYtofsG4rd5NaO5obxQ5xBkdiS7xsT7bM=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
@ -512,8 +512,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa h1:idItI2DDfCokpg0N51B2VtiLdJ4vAuXC9fnCb2gACo4=
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8 h1:5QRxNnVsaJP6NAse0UdkRgL3zHMvCRRkrDVLNdNpdy4=
golang.org/x/crypto v0.0.0-20211115234514-b4de73f9ece8/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=

37
highlighting.go

@ -0,0 +1,37 @@
package main
import (
"github.com/alecthomas/chroma"
"github.com/alecthomas/chroma/styles"
)
var chromaGoBlogStyle = styles.Register(chroma.MustNewStyle("goblog", chroma.StyleEntries{
// Monokai
chroma.Text: "#f8f8f2",
chroma.Error: "#960050 bg:#1e0010",
chroma.Comment: "#75715e",
chroma.Keyword: "#66d9ef",
chroma.KeywordNamespace: "#f92672",
chroma.Operator: "#f92672",
chroma.Punctuation: "#f8f8f2",
chroma.Name: "#f8f8f2",
chroma.NameAttribute: "#a6e22e",
chroma.NameClass: "#a6e22e",
chroma.NameConstant: "#66d9ef",
chroma.NameDecorator: "#a6e22e",
chroma.NameException: "#a6e22e",
chroma.NameFunction: "#a6e22e",
chroma.NameOther: "#a6e22e",
chroma.NameTag: "#f92672",
chroma.LiteralNumber: "#ae81ff",
chroma.Literal: "#ae81ff",
chroma.LiteralDate: "#e6db74",
chroma.LiteralString: "#e6db74",
chroma.LiteralStringEscape: "#ae81ff",
chroma.GenericDeleted: "#f92672",
chroma.GenericEmph: "italic",
chroma.GenericInserted: "#a6e22e",
chroma.GenericStrong: "bold",
chroma.GenericSubheading: "#75715e",
chroma.Background: "bg:#272822",
}))

2
markdown.go

@ -38,7 +38,7 @@ func (a *goBlog) initMarkdown() {
marktag.Mark,
emoji.Emoji,
highlighting.NewHighlighting(
highlighting.WithStyle("monokai"),
highlighting.WithCustomStyle(chromaGoBlogStyle),
highlighting.WithFormatOptions(
chromahtml.ClassPrefix("c-"),
chromahtml.WithClasses(true),

21
original-assets/styles/styles.scss

@ -46,25 +46,26 @@ html {
body {
@extend .sans-serif;
@include color(background, background);
@include color(color, primary);
line-height: 1.5;
margin: 0 auto;
max-width: 700px;
padding: 10px;
word-break: break-word;
overflow-wrap: break-word;
* {
@include color(color, primary);
max-width: 100%;
}
[class*='c-'] {
// monokai is dark, so we need to use light color for text
color: #{map-get($colors, primary-dark)};
}
*::selection {
@include color(color, background);
@include color(background, primary);
}
}
a, hr {
@include color(color, primary);
}
*::selection {
@include color(color, background);
@include color(background, primary);
}
header {

8
templateAssets.go

@ -11,7 +11,6 @@ import (
"strings"
chromahtml "github.com/alecthomas/chroma/formatters/html"
"github.com/alecthomas/chroma/styles"
"go.goblog.app/app/pkgs/contenttype"
)
@ -121,7 +120,7 @@ func (a *goBlog) initChromaCSS() error {
return nil
}
// Initialize the style
chromaStyleBuilder := styles.Get("monokai").Builder()
chromaStyleBuilder := chromaGoBlogStyle.Builder()
chromaStyle, err := chromaStyleBuilder.Build()
if err != nil {
return err
@ -135,6 +134,7 @@ func (a *goBlog) initChromaCSS() error {
// Write the CSS to the file
chromahtml.New(
chromahtml.ClassPrefix("c-"),
chromahtml.WithAllClasses(true),
).WriteCSS(chromaTempFile, chromaStyle)
// Close the file
_ = chromaTempFile.Close()
@ -144,8 +144,6 @@ func (a *goBlog) initChromaCSS() error {
if err != nil {
return err
}
if compiled != "" {
a.assetFileNames["css/chroma.css"] = compiled
}
a.assetFileNames["css/chroma.css"] = compiled
return nil
}

13
templates/assets/css/styles.css

@ -23,6 +23,8 @@ html {
body {
background: #fff;
background: var(--background, #fff);
color: #000;
color: var(--primary, #000);
line-height: 1.5;
margin: 0 auto;
max-width: 700px;
@ -31,14 +33,15 @@ body {
overflow-wrap: break-word;
}
body * {
color: #000;
color: var(--primary, #000);
max-width: 100%;
}
body [class*=c-] {
color: #fff;
a, hr {
color: #000;
color: var(--primary, #000);
}
body *::selection {
*::selection {
color: #fff;
color: var(--background, #fff);
background: #000;

Loading…
Cancel
Save