代码拉取完成,页面将自动刷新
package main
import (
"fmt"
"io/ioutil"
"path/filepath"
"strings"
"github.com/kjk/u"
)
const (
// https://www.netlify.com/docs/headers-and-basic-auth/#custom-headers
netlifyHeaders = `
# long-lived caching
/s/*
Cache-Control: max-age=31536000
/*
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
`
)
func genNetlifyHeaders() {
path := filepath.Join("www", "_headers")
err := ioutil.WriteFile(path, []byte(netlifyHeaders), 0644)
u.Must(err)
}
// TODO: this should be in 404.html for each book
func genNetlifyRedirectsForBook(b *Book) []string {
var res []string
// catch-all redirect for all other missing pages
s := fmt.Sprintf(`/essential/%s/* /essential/%s/404.html 404`, b.Dir, b.Dir)
res = append(res, s)
//res = append(res, "")
return res
}
func genNetlifyRedirects(books []*Book) {
var a []string
for _, b := range books {
ab := genNetlifyRedirectsForBook(b)
a = append(a, ab...)
}
s := strings.Join(a, "\n")
path := filepath.Join("www", "_redirects")
err := ioutil.WriteFile(path, []byte(s), 0644)
u.Must(err)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。