add at least one child in the toc

This commit is contained in:
Celogeek 2023-04-22 10:26:11 +02:00
parent bc19e5e4ce
commit 4a43760535
Signed by: celogeek
SSH Key Fingerprint: SHA256:njNJLzoLQdbV9PC6ehcruRb0QnEgxABoCYZ+0+aUIYc
2 changed files with 9 additions and 4 deletions

@ -20,8 +20,8 @@ func NewGift(options *ImageOptions) *gift.GIFT {
}
g.Add(
filters.Resize(options.ViewWidth, options.ViewHeight, gift.LanczosResampling),
filters.Pixel(),
filters.Position(options.ViewWidth, options.ViewHeight, filters.PositionCenter),
filters.Pixel(),
)
return g
}

@ -44,9 +44,14 @@ func (e *ePub) getToc(title string, images []*Image) string {
if len(ol.ChildElements()) == 1 && e.StripFirstDirectoryFromToc {
ol = ol.ChildElements()[0]
}
if len(ol.ChildElements()) > 0 {
nav.AddChild(ol)
}
beginning := etree.NewElement("li")
beginningLink := beginning.CreateElement("a")
beginningLink.CreateAttr("href", images[0].TextPath())
beginningLink.CreateText("Start of the book")
ol.InsertChildAt(0, beginning)
nav.AddChild(ol)
doc.Indent(2)
r, _ := doc.WriteToString()