diff options
| author | Shulhan <ms@kilabit.info> | 2021-10-10 21:31:00 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-10-10 21:31:00 +0700 |
| commit | 06d03f6afe37124c486a34c120fcb05a8ae86d5e (patch) | |
| tree | 98be3734ef6613b42878829bda7a19eed2e59576 /filehtml.go | |
| parent | 88504a35592cf0c1a714d0a7454cdf95c7adec8b (diff) | |
| download | ciigo-06d03f6afe37124c486a34c120fcb05a8ae86d5e.tar.xz | |
all: check markup modification time before converting to HTML
Previously, when the Convert, Watch or Serve running it will convert
all markup files into HTML without checking if the adoc has been modified
or newer than HTML file.
This changes check the modification time of markup file first before
converting them, to minimize unnecessary operation.
Diffstat (limited to 'filehtml.go')
| -rw-r--r-- | filehtml.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/filehtml.go b/filehtml.go index 91a2c7d..541db91 100644 --- a/filehtml.go +++ b/filehtml.go @@ -6,6 +6,8 @@ package ciigo import ( "html/template" + "io/fs" + "os" "strings" "git.sr.ht/~shulhan/asciidoctor-go" @@ -22,9 +24,18 @@ type fileHTML struct { Metadata map[string]string path string + finfo fs.FileInfo rawBody strings.Builder } +func newFileHtml(path string) (fhtml *fileHTML) { + fhtml = &fileHTML{ + path: path, + } + fhtml.finfo, _ = os.Stat(path) + return fhtml +} + func (fhtml *fileHTML) unpackAdocMetadata(doc *asciidoctor.Document) { fhtml.Title = doc.Title.String() fhtml.Styles = fhtml.Styles[:0] |
