Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Mohamed Hernouf
www
Commits
011c3d7a
Commit
011c3d7a
authored
Nov 04, 2021
by
Artemiy
Browse files
display articles with given tag
parent
84ce10cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
src/blog.ml
src/blog.ml
+14
-0
src/server.ml
src/server.ml
+6
-0
No files found.
src/blog.ml
View file @
011c3d7a
...
@@ -393,6 +393,20 @@ let given_author ocp_author =
...
@@ -393,6 +393,20 @@ let given_author ocp_author =
links_to_home_pages
pp_blog_posts
articles_of_author
links_to_home_pages
pp_blog_posts
articles_of_author
,
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
(** [category_home] This is the home page for all available categories on the
Blog, along with number of articles of given category *)
Blog, along with number of articles of given category *)
let
category_home
=
let
category_home
=
...
...
src/server.ml
View file @
011c3d7a
...
@@ -169,6 +169,12 @@ let () =
...
@@ -169,6 +169,12 @@ let () =
Dream
.
html_escape
(
String
.
concat
", "
(
tags
@
Meta
.
keywords_l
))
Dream
.
html_escape
(
String
.
concat
", "
(
tags
@
Meta
.
keywords_l
))
in
in
Dream
.
html
(
render_unsafe
~
title
~
content
~
authors
~
keywords
()
)
)
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
->
;
Dream
.
get
"/blog"
(
fun
_request
->
let
content
=
Blog
.
home_page
in
let
content
=
Blog
.
home_page
in
let
title
=
title
content
in
let
title
=
title
content
in
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment