Replace slug by id
This commit is contained in:
@@ -534,7 +534,7 @@ We update the "blog" Mustache templates.
|
|||||||
{{#articles}}
|
{{#articles}}
|
||||||
<section>
|
<section>
|
||||||
<header class="article-header">
|
<header class="article-header">
|
||||||
<h2 class="article-title"><a href="/article/{{slug}}">{{title}}</a></h2>
|
<h2 class="article-title"><a href="/article/{{id}}">{{title}}</a></h2>
|
||||||
<div class="article-meta">By <strong>{{author.firstname}}</strong>, on <strong>{{addedAt}}</strong></div>
|
<div class="article-meta">By <strong>{{author.firstname}}</strong>, on <strong>{{addedAt}}</strong></div>
|
||||||
</header>
|
</header>
|
||||||
<div class="article-description">
|
<div class="article-description">
|
||||||
@@ -591,7 +591,7 @@ class HtmlController(private val repository: ArticleRepository,
|
|||||||
fun article(@PathVariable id: Long, model: Model): String {
|
fun article(@PathVariable id: Long, model: Model): String {
|
||||||
val article = repository
|
val article = repository
|
||||||
.findById(id)
|
.findById(id)
|
||||||
.orElseThrow { IllegalArgumentException("Wrong article slug provided") }
|
.orElseThrow { IllegalArgumentException("Wrong article id provided") }
|
||||||
.render()
|
.render()
|
||||||
model["title"] = article.title
|
model["title"] = article.title
|
||||||
model["article"] = article
|
model["article"] = article
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class HtmlController(private val repository: ArticleRepository,
|
|||||||
fun article(@PathVariable id: Long, model: Model): String {
|
fun article(@PathVariable id: Long, model: Model): String {
|
||||||
val article = repository
|
val article = repository
|
||||||
.findById(id)
|
.findById(id)
|
||||||
.orElseThrow { IllegalArgumentException("Wrong article slug provided") }
|
.orElseThrow { IllegalArgumentException("Wrong article id provided") }
|
||||||
.render()
|
.render()
|
||||||
model["title"] = article.title
|
model["title"] = article.title
|
||||||
model["article"] = article
|
model["article"] = article
|
||||||
|
|||||||
Reference in New Issue
Block a user