Skip to content

Commit 8302ccf

Browse files
committed
Add page title to React Typescript articles
1 parent c2f66d2 commit 8302ccf

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/components_guide_web/controllers/react_typescript_controller.ex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,19 @@ defmodule ComponentsGuideWeb.ReactTypescriptController do
77
|> render("index.html", article: "tips")
88
end
99

10-
@articles ["testing", "forms", "reducer-patterns", "hooks-concurrent-world", "event-handlers", "logical-clocks", "editor", "editor-prolog"]
10+
@articles %{
11+
"testing" => %{title: "Testing React"},
12+
"forms" => %{title: "Creating Forms in React"},
13+
"reducer-patterns" => %{title: "React Reducer Patterns"},
14+
"hooks-concurrent-world" => %{title: "React Hooks in a Concurrent World"},
15+
"logical-clocks" => %{title: "Logical Clocks in React"},
16+
"editor" => %{title: "React Online Editor"},
17+
"editor-prolog" => %{title: "Prolog Online Editor"}
18+
}
1119

12-
def show(conn, %{"article" => article}) when article in @articles do
13-
render(conn, "index.html", article: article)
20+
def show(conn, %{"article" => article}) when is_map_key(@articles, article) do
21+
conn
22+
|> assign(:page_title, @articles[article].title)
23+
|> render("index.html", article: article)
1424
end
1525
end

0 commit comments

Comments
 (0)