smLayouts := []string{"sitemapindex.xml", "_default/sitemapindex.xml", "_internal/_default/sitemapindex.xml"}
- if err := s.renderAndWriteXML("sitemapindex", sitemapDefault.Filename,
- h.toSiteInfos(), s.appendThemeTemplates(smLayouts)...); err != nil {
- return err
- }
-
- return nil
+ return s.renderAndWriteXML("sitemapindex",
+ sitemapDefault.Filename, h.toSiteInfos(), s.appendThemeTemplates(smLayouts)...)
}
func (h *HugoSites) assignMissingTranslations() error {
bc := make([]byte, b.Len(), b.Len())
copy(bc, b.Bytes())
- err := p.saveSource(bc, path, safe)
- if err != nil {
- return err
- }
- return nil
+ return p.saveSource(bc, path, safe)
}
func (p *Page) saveSource(by []byte, inpath string, safe bool) (err error) {
"filename": pageToPermalinkFilename,
}
- attributeRegexp = regexp.MustCompile(":\\w+")
+ attributeRegexp = regexp.MustCompile(`:\w+`)
}
require.Len(t, h.Sites[0].RegularPages, 1)
output := strings.TrimSpace(string(h.Sites[0].RegularPages[0].Content))
- if strings.HasPrefix(output, "<p>") {
- output = output[3:]
- }
- if strings.HasSuffix(output, "</p>") {
- output = output[:len(output)-4]
- }
+ output = strings.TrimPrefix(output, "<p>")
+ output = strings.TrimSuffix(output, "</p>")
expected = strings.TrimSpace(expected)
func (s *Site) renderForLayouts(name string, d interface{}, w io.Writer, layouts ...string) error {
layout, found := s.findFirstLayout(layouts...)
- if found == false {
+ if !found {
jww.WARN.Printf("Unable to locate layout for %s: %s\n", name, layouts)
return nil
}
rssPath := path.Join(rssPage.URLPath.URL, rssURI)
s.setPageURLs(rssPage, rssPath)
- if err := s.renderAndWriteXML(rssPage.Title, rssPage.addLangFilepathPrefix(rssPath), rssPage, s.appendThemeTemplates(layouts)...); err != nil {
- return err
- }
-
- return nil
+ return s.renderAndWriteXML(rssPage.Title,
+ rssPage.addLangFilepathPrefix(rssPath), rssPage, s.appendThemeTemplates(layouts)...)
}
func (s *Site) render404() error {
s.setPageURLs(p, "404.html")
nfLayouts := []string{"404.html"}
- if nfErr := s.renderAndWritePage("404 page", "404.html", p, s.appendThemeTemplates(nfLayouts)...); nfErr != nil {
- return nfErr
- }
- return nil
+ return s.renderAndWritePage("404 page", "404.html", p, s.appendThemeTemplates(nfLayouts)...)
+
}
func (s *Site) renderSitemap() error {
smLayouts := []string{"sitemap.xml", "_default/sitemap.xml", "_internal/_default/sitemap.xml"}
addLanguagePrefix := n.Site.IsMultiLingual()
- if err := s.renderAndWriteXML("sitemap", n.addLangPathPrefixIfFlagSet(page.Sitemap.Filename, addLanguagePrefix), n, s.appendThemeTemplates(smLayouts)...); err != nil {
- return err
- }
- return nil
+ return s.renderAndWriteXML("sitemap",
+ n.addLangPathPrefixIfFlagSet(page.Sitemap.Filename, addLanguagePrefix), n, s.appendThemeTemplates(smLayouts)...)
}
func (s *Site) renderRobotsTXT() error {