Skip to content

Commit

Permalink
do not translate assets files
Browse files Browse the repository at this point in the history
  • Loading branch information
Streamlet committed Nov 10, 2023
1 parent a711b46 commit 91f3dcb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 8 additions & 2 deletions note/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,14 @@ func (n *node) GetContent() ([]byte, error) {
pageData.BasicItem = item
}
if n.subItems == nil {
t := translator.New(n.absolutePath)
content, err := t.Translate()
var content []byte
var err error
if n.isNote {
t := translator.New(n.absolutePath)
content, err = t.Translate()
} else {
content, err = os.ReadFile(n.absolutePath)
}
if err != nil {
if os.IsNotExist(err) {
return n.templateExecutor.Get404(), err
Expand Down
4 changes: 2 additions & 2 deletions note/translator/default.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package translator

import "io/ioutil"
import "os"

type defaultTranslator struct {
path string
Expand All @@ -13,5 +13,5 @@ func newDefaultTranslator(path string) *defaultTranslator {
}

func (t defaultTranslator) Translate() ([]byte, error) {
return ioutil.ReadFile(t.path)
return os.ReadFile(t.path)
}
4 changes: 2 additions & 2 deletions note/translator/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package translator

import (
"bytes"
"io/ioutil"
"os"
)

type textTranslator struct {
Expand All @@ -16,7 +16,7 @@ func newTextTranslator(path string) *textTranslator {
}

func (t textTranslator) Translate() ([]byte, error) {
content, err := ioutil.ReadFile(t.path)
content, err := os.ReadFile(t.path)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 91f3dcb

Please sign in to comment.