diff options
author | Indrajith K L | 2024-06-21 00:43:41 +0530 |
---|---|---|
committer | Indrajith K L | 2024-06-21 02:38:36 +0530 |
commit | f7275309ad3ec062ebed915a097766daf126813b (patch) | |
tree | 12fa7deedd4e6332b28e2c0b7dc1b8b17fc1cde4 /src/indrajith-dev-crystal.cr | |
parent | 11c92db4208efb6381a2fd65bcc4de427d1f21f6 (diff) | |
download | indrajith-dev-crystal-f7275309ad3ec062ebed915a097766daf126813b.tar.gz indrajith-dev-crystal-f7275309ad3ec062ebed915a097766daf126813b.tar.bz2 indrajith-dev-crystal-f7275309ad3ec062ebed915a097766daf126813b.zip |
Basic Home Page Implementation
* Moves assets from old website
* Basic layout based on old website
* Move home page from old website
Diffstat (limited to 'src/indrajith-dev-crystal.cr')
-rw-r--r-- | src/indrajith-dev-crystal.cr | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/indrajith-dev-crystal.cr b/src/indrajith-dev-crystal.cr index a7a08b6..28948cf 100644 --- a/src/indrajith-dev-crystal.cr +++ b/src/indrajith-dev-crystal.cr @@ -3,8 +3,25 @@ require "kemal" module Indrajith::Dev::Crystal VERSION = "0.1.0" - get "/" do - "Hello World!" + macro page_renderer(filename) + render "src/views/#{{{filename}}}.ecr", "src/views/layout.ecr" + end + + def self.htmx_request?(context) + context.request.headers.has_key?("HX-Request") || + context.request.headers.has_key?("Hx-Request") || + context.request.headers.has_key?("hx-request") + end + + get "/" do |context| + if htmx_request?(context) + partial_content = render("src/views/home.ecr") + context.response.content_type = "text/html" + context.response.print partial_content + else + context.response.content_type = "text/html" + page_renderer "home" + end end Kemal.run |