Render 404 page with templates to reuse the footer
This commit is contained in:
parent
36464854b9
commit
625ea8043e
10
public/404.html
generated
10
public/404.html
generated
@ -1,7 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<meta charset="utf-8">
|
||||
<title>Go by Example: Not Found</title>
|
||||
<link rel=stylesheet href="site.css">
|
||||
</head>
|
||||
@ -9,9 +9,11 @@
|
||||
<div id="intro">
|
||||
<h2><a href="./">Go by Example</a></h2>
|
||||
<p>Sorry, we couldn't find that! Check out the <a href="./">home page</a>?</p>
|
||||
<p class="footer">
|
||||
by <a href="https://twitter.com/mmcgrana">@mmcgrana</a> | <a href="mailto:mmcgrana@gmail.com">feedback</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a>
|
||||
</p>
|
||||
|
||||
<p class="footer">
|
||||
by <a href="https://markmcgranaghan.com">Mark McGranaghan</a> and <a href="https://eli.thegreenplace.net">Eli Bendersky</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,17 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
||||
<title>Go by Example: Not Found</title>
|
||||
<link rel=stylesheet href="site.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="intro">
|
||||
<h2><a href="./">Go by Example</a></h2>
|
||||
<p>Sorry, we couldn't find that! Check out the <a href="./">home page</a>?</p>
|
||||
<p class="footer">
|
||||
by <a href="https://twitter.com/mmcgrana">@mmcgrana</a> | <a href="mailto:mmcgrana@gmail.com">feedback</a> | <a href="https://github.com/mmcgrana/gobyexample">source</a> | <a href="https://github.com/mmcgrana/gobyexample#license">license</a>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
15
templates/404.tmpl
Normal file
15
templates/404.tmpl
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Go by Example: Not Found</title>
|
||||
<link rel=stylesheet href="site.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="intro">
|
||||
<h2><a href="./">Go by Example</a></h2>
|
||||
<p>Sorry, we couldn't find that! Check out the <a href="./">home page</a>?</p>
|
||||
{{ template "footer" }}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -210,7 +210,6 @@ func parseSegs(sourcePath string) ([]*Seg, string) {
|
||||
}
|
||||
|
||||
func chromaFormat(code, filePath string) string {
|
||||
|
||||
lexer := lexers.Get(filePath)
|
||||
if lexer == nil {
|
||||
lexer = lexers.Fallback
|
||||
@ -340,6 +339,21 @@ func renderExamples(examples []*Example) {
|
||||
}
|
||||
}
|
||||
|
||||
func render404() {
|
||||
if verbose() {
|
||||
fmt.Println("Rendering 404")
|
||||
}
|
||||
tmpl := template.New("404")
|
||||
_, err := tmpl.Parse(mustReadFile("templates/footer.tmpl"))
|
||||
check(err)
|
||||
_, err = tmpl.Parse(mustReadFile("templates/404.tmpl"))
|
||||
check(err)
|
||||
file, err := os.Create(siteDir + "/404.html")
|
||||
check(err)
|
||||
err = tmpl.Execute(file, "")
|
||||
check(err)
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) > 1 {
|
||||
siteDir = os.Args[1]
|
||||
@ -349,12 +363,12 @@ func main() {
|
||||
copyFile("templates/site.css", siteDir+"/site.css")
|
||||
copyFile("templates/site.js", siteDir+"/site.js")
|
||||
copyFile("templates/favicon.ico", siteDir+"/favicon.ico")
|
||||
copyFile("templates/404.html", siteDir+"/404.html")
|
||||
copyFile("templates/play.png", siteDir+"/play.png")
|
||||
copyFile("templates/clipboard.png", siteDir+"/clipboard.png")
|
||||
examples := parseExamples()
|
||||
renderIndex(examples)
|
||||
renderExamples(examples)
|
||||
render404()
|
||||
}
|
||||
|
||||
var SimpleShellOutputLexer = chroma.MustNewLexer(
|
||||
|
Loading…
x
Reference in New Issue
Block a user