-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: added earmark * feat: added redirect if post not exist * feat: added noticia style * sanitize input html dessa forma n é possível fazer ataques de XSS ou injetar código HTML/JS malicioso --------- Co-authored-by: zoeyrinha <[email protected]>
- Loading branch information
Showing
5 changed files
with
119 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
defmodule PescarteWeb.Blog.PostLive.Show do | ||
use PescarteWeb, :live_view | ||
|
||
alias Pescarte.Blog.Post | ||
alias PescarteWeb.Markdown | ||
|
||
@impl true | ||
def mount(%{"id" => id}, _session, socket) do | ||
case Post.get_post(id) do | ||
{:ok, post} -> {:ok, assign(socket, post: post)} | ||
_ -> {:ok, push_navigate(socket, to: "/noticias")} | ||
end | ||
end | ||
|
||
@impl true | ||
def render(assigns) do | ||
~H""" | ||
<div class="noticia"> | ||
<h1 class="text-4xl leading-10 font-bold text-blue-100"><%= @post.titulo %></h1> | ||
<div class="noticia-descricao"><%= raw(Markdown.to_html(@post.conteudo)) %></div> | ||
<DesignSystem.link href="/noticias" class="text-sm font-semibold"> | ||
<.button style="primary"> | ||
<Lucideicons.arrow_left class="text-white-100" /> Voltar para Notícias | ||
</.button> | ||
</DesignSystem.link> | ||
</div> | ||
<PescarteWeb.DesignSystem.GetInTouch.render /> | ||
""" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
defmodule PescarteWeb.Markdown do | ||
@moduledoc """ | ||
Módulo responsável por converter markdown para HTML. | ||
""" | ||
|
||
alias Earmark | ||
|
||
def to_html(markdown) do | ||
Earmark.as_html!(markdown, escape: true) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters