Skip to content

Commit b97f230

Browse files
Elle Meredithelle
authored andcommitted
Define index action for homepage
- To remove the confusion of where the home page is defined, making it easier to understand what is happening - Also removing one branch in the layout conditional
1 parent 4c68430 commit b97f230

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

app/controllers/pages_controller.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ class PagesController < ApplicationController
22
append_view_path "pages"
33
layout :layout_by_path
44

5+
def index
6+
render :index, layout: "homepage"
7+
end
8+
59
def show
610
@page = Page.new(view_context, params[:path])
711

812
# If the page doesn't exist, throw a 404
913
raise ActionController::RoutingError.new("The documentation page `#{@page.basename}` does not exist") unless @page.exists?
1014

11-
# For the homepage, render with a custom layout that doesn't include the sidebar etc
12-
1315
# If there's another more correct version of the URL (for example, we changed `_`
1416
# to `-`), then redirect them to where they should be.
1517
unless @page.is_canonical?
@@ -32,9 +34,7 @@ def is_landing_page?
3234
helper_method :is_landing_page?
3335

3436
def layout_by_path
35-
if request.path == "/docs"
36-
"homepage"
37-
elsif request.path.starts_with? "/docs/apis/graphql"
37+
if request.path.starts_with? "/docs/apis/graphql"
3838
"graphql"
3939
else
4040
"application"

0 commit comments

Comments
 (0)