Skip to content

Commit

Permalink
[docs] Add 404.html page (#11428)
Browse files Browse the repository at this point in the history
Co-authored-by: Matías García Isaía <mgarcia@manas.tech>
  • Loading branch information
straight-shoota and matiasgarciaisaia committed Nov 30, 2021
1 parent 92516d6 commit baf5c3b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/compiler/crystal/tools/doc/generator.cr
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class Crystal::Doc::Generator
main_index = Main.new(raw_body, Type.new(self, @program), project_info)
File.write File.join(@output_dir, "index.json"), main_index
File.write File.join(@output_dir, "search-index.js"), main_index.to_jsonp

File.write File.join(@output_dir, "404.html"), MainTemplate.new(Error404Template.new.to_s, types, project_info)
end

def generate_sitemap(types)
Expand Down
12 changes: 12 additions & 0 deletions src/compiler/crystal/tools/doc/html/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h1 class="type-name">
404 Not Found
</h1>

<p>
This page is unavailable in this version of the API docs.
</p>

<p>
You can use the sidebar to search for your page, or try a different
Crystal version.
</p>
4 changes: 4 additions & 0 deletions src/compiler/crystal/tools/doc/templates.cr
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ module Crystal::Doc
ECR.def_to_s "#{__DIR__}/html/_sidebar.html"
end

record Error404Template do
ECR.def_to_s "#{__DIR__}/html/404.html"
end

struct JsTypeTemplate
ECR.def_to_s "#{__DIR__}/html/js/doc.js"
end
Expand Down

0 comments on commit baf5c3b

Please sign in to comment.