src/components/Blog.js) and individual article pages routed via src/components/ViewBlog.js.
Routing
| Route | Component | Description |
|---|---|---|
/blog | Blog | Listing page (currently empty) |
/blog/:id | ViewBlog | Individual article view, looks up content by id |
Article data structure
Articles are defined insrc/constants/articles.js. Each article is a separate file inside src/constants/articles/ that exports an object with three fields:
src/constants/articles.js:
Current articles
| ID | Title | Notes |
|---|---|---|
netflix | (title defined in netflix.js) | The only article currently registered |
How ViewBlog uses getArticle
When a visitor navigates to /blog/:id, the ViewBlog component calls getArticle(id) to retrieve the article content and renders it. If the id is not found in idsAndArticles, getArticle returns undefined.
Adding a new article
Create a new article file
Create a new file in
src/constants/articles/. Name it after the article’s ID slug.src/constants/articles/my-new-article.js
Register the article in both exports
Add an entry to the
articles metadata array and the idsAndArticles map.Until the
Blog listing component is implemented, articles are only accessible by direct URL (/blog/:id). There is no navigable index page linking to them.Future work
TheBlog component (src/components/Blog.js) imports the articles array and Patrick’s face photo, suggesting a listing UI was planned. Implementing it would involve mapping over articles and rendering each entry as a link to /blog/:id: