Changing the article page
Let’s make a small change to the Journal. We’ll add “Summary” under the title of each article. Open an article from the feed and keep it open so you can check your edit. The files we’ll use are in examples/canonical.
Finding the route
First look at the address in your browser. The part after /article/ identifies the post. Open openapi.yaml and find /article/{slug}. Its GET operation is called article.
Now open RouteBindings.bend and look for the matching case:
case Api.OnArticle{}: ArticleShow.actionThe import for ArticleShow at the top of this file takes us to the controller.
Opening the article view
In Controller/Articles/Show.bend, find present. By the time we reach it, load_article has fetched the article with its author. Look at what’s still missing for our HTML page. The controller reads the comments here and gives them, together with the article, to Article.content.
If you’re wondering why comments are missing when you request JSON, look at the next case in the same function. The JSON response only includes the article.
Adding the label
Follow Article.content into View/Article.bsx. Inside def content, find the H1. The very next paragraph contains {description}. Keep the headline as it is and add the label to the paragraph as shown below.
<h1>{title}</h1>
<p>Summary: {description}</p>Save the file with bwf dev running. When the server is listening again, reload the article. You should see the label under the headline. If the page looks the same, check that you edited the paragraph. The meta tag a few lines above it also uses description.
Back on the feed
Go back to the feed and find the card for the same article. Its description still appears without the label. The card has its own paragraph in View/Feed.bsx. The navigation above both pages comes from View/Layout.bsx.
You can follow another page through the Journal in the same way. Start with its address in openapi.yaml, then follow the operation into the controller. The routing chapter shows how Bwf derives the Bend name for each operation.