Commit 011c3d7a authored by Artemiy's avatar Artemiy
Browse files

display articles with given tag

parent 84ce10cc
......@@ -393,6 +393,20 @@ let given_author ocp_author =
links_to_home_pages pp_blog_posts articles_of_author
, author )
(** [given_tag tag] Displays the list of articles tagged with given [tag] *)
let given_tag tag =
let articles_by_date = List.sort compare_articles articles_data in
let articles_with_tag =
List.filter
(fun article ->
List.exists
(fun tag0 -> String.equal (normalize_url tag0) tag)
article.tags )
articles_by_date
in
Format.asprintf {|<h1 id="page-title">Articles tagged with %s</h1>%s%a@.|} tag
links_to_home_pages pp_blog_posts articles_with_tag
(** [category_home] This is the home page for all available categories on the
Blog, along with number of articles of given category *)
let category_home =
......
......@@ -169,6 +169,12 @@ let () =
Dream.html_escape (String.concat ", " (tags @ Meta.keywords_l))
in
Dream.html (render_unsafe ~title ~content ~authors ~keywords ()) )
; Dream.get "/blog/tag/:tag" (fun request ->
let content=
Blog.given_tag (Dream.param "tag" request)
in
let title = title content in
Dream.html (render_unsafe ~title ~content ()) )
; Dream.get "/blog" (fun _request ->
let content = Blog.home_page in
let title = title content in
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment