init commit
This commit is contained in:
10
lib/layouts/post_layout.ex
Normal file
10
lib/layouts/post_layout.ex
Normal file
@@ -0,0 +1,10 @@
|
||||
defmodule Llmex.PostLayout do
|
||||
use Tableau.Layout, layout: Llmex.RootLayout
|
||||
use Phoenix.Component
|
||||
|
||||
def template(assigns) do
|
||||
~H"""
|
||||
<%= {:safe, render(@inner_content)} %>
|
||||
"""
|
||||
end
|
||||
end
|
38
lib/layouts/root_layout.ex
Normal file
38
lib/layouts/root_layout.ex
Normal file
@@ -0,0 +1,38 @@
|
||||
defmodule Llmex.RootLayout do
|
||||
use Tableau.Layout
|
||||
use Phoenix.Component
|
||||
|
||||
def template(assigns) do
|
||||
~H"""
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http_equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<title>
|
||||
<%= [@page[:title], Llmex]
|
||||
|> Enum.filter(& &1)
|
||||
|> Enum.intersperse("|")
|
||||
|> Enum.join(" ") %>
|
||||
</title>
|
||||
|
||||
<link rel="stylesheet" href="/css/simple.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main>
|
||||
<%= render @inner_content %>
|
||||
</main>
|
||||
</body>
|
||||
|
||||
<%= if Mix.env() == :dev do %>
|
||||
<%= Phoenix.HTML.raw(Tableau.live_reload(assigns)) %>
|
||||
<% end %>
|
||||
</html>
|
||||
"""
|
||||
|> Phoenix.HTML.Safe.to_iodata()
|
||||
end
|
||||
end
|
45
lib/mix/tasks/post.ex
Normal file
45
lib/mix/tasks/post.ex
Normal file
@@ -0,0 +1,45 @@
|
||||
defmodule Mix.Tasks.Llmex.Gen.Post do
|
||||
use Mix.Task
|
||||
|
||||
@shortdoc "Generate a new post"
|
||||
@moduledoc @shortdoc
|
||||
|
||||
@doc false
|
||||
def run(argv) do
|
||||
if argv == [] do
|
||||
raise "Missing argument: Filename"
|
||||
end
|
||||
|
||||
post_title = Enum.join(argv, " ")
|
||||
post_date = Date.utc_today()
|
||||
post_time = "01:00:00 -04:00"
|
||||
|
||||
file_name =
|
||||
post_title
|
||||
|> String.replace(" ", "-")
|
||||
|> String.replace("_", "-")
|
||||
|> String.replace(~r/[^[:alnum:]\/\-.]/, "")
|
||||
|> String.downcase()
|
||||
|
||||
file_path =
|
||||
"./_posts/#{post_date}-#{file_name}.md"
|
||||
|
||||
if File.exists?(file_path) do
|
||||
raise "File already exists"
|
||||
end
|
||||
|
||||
front_matter = """
|
||||
---
|
||||
layout: Llmex.PostLayout
|
||||
title: \"#{post_title}\"
|
||||
date: #{post_date} #{post_time}
|
||||
permalink: /:title/
|
||||
---
|
||||
"""
|
||||
|
||||
File.write!(file_path, front_matter)
|
||||
|
||||
Mix.shell().info("Succesfully created #{file_path}!")
|
||||
end
|
||||
end
|
||||
|
15
lib/pages/home_page.ex
Normal file
15
lib/pages/home_page.ex
Normal file
@@ -0,0 +1,15 @@
|
||||
defmodule Llmex.HomePage do
|
||||
use Tableau.Page,
|
||||
layout: Llmex.RootLayout,
|
||||
permalink: "/"
|
||||
|
||||
use Phoenix.Component
|
||||
|
||||
def template(assigns) do
|
||||
~H"""
|
||||
<p>
|
||||
hello, world!
|
||||
</p>
|
||||
"""
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user