Add syntax highlighting, support draft posts
This commit is contained in:
parent
94c692a54c
commit
6fffd6e1cc
16 changed files with 64 additions and 97 deletions
2
Gemfile
2
Gemfile
|
@ -4,7 +4,7 @@ source "https://rubygems.org"
|
|||
|
||||
# gem "rails"
|
||||
|
||||
gem "phlex", "~> 1.11"
|
||||
gem "phlex", "~> 2.3"
|
||||
gem "phlexite", "~> 0.1.3"
|
||||
|
||||
gem "front_matter_parser", "~> 1.0"
|
||||
|
|
|
@ -11,7 +11,8 @@ GEM
|
|||
specs:
|
||||
front_matter_parser (1.0.1)
|
||||
markly (0.12.1)
|
||||
phlex (1.11.0)
|
||||
phlex (2.3.1)
|
||||
zeitwerk (~> 2.7)
|
||||
phlexite (0.1.3)
|
||||
tailwindcss-phlexite (0.1.0)
|
||||
tailwindcss-ruby (~> 4.1)
|
||||
|
@ -19,6 +20,7 @@ GEM
|
|||
tailwindcss-ruby (4.1.8-aarch64-linux-gnu)
|
||||
tailwindcss-ruby (4.1.8-arm64-darwin)
|
||||
tailwindcss-ruby (4.1.8-x86_64-linux-gnu)
|
||||
zeitwerk (2.7.3)
|
||||
|
||||
PLATFORMS
|
||||
aarch64-linux
|
||||
|
@ -28,7 +30,7 @@ PLATFORMS
|
|||
|
||||
DEPENDENCIES
|
||||
front_matter_parser (~> 1.0)
|
||||
phlex (~> 1.11)
|
||||
phlex (~> 2.3)
|
||||
phlex-markdown!
|
||||
phlexite (~> 0.1.3)
|
||||
tailwindcss-phlexite (~> 0.1.0)
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,93 +0,0 @@
|
|||
Copyright 2020 The DM Mono Project Authors (https://www.github.com/googlefonts/dm-mono)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://openfontlicense.org
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
3
assets/prism/prism.css
Normal file
3
assets/prism/prism.css
Normal file
|
@ -0,0 +1,3 @@
|
|||
/* PrismJS 1.30.0
|
||||
https://prismjs.com/download#themes=prism-tomorrow&languages=markup+css+clike+javascript+awk+bash+c+cpp+dart+docker+elixir+erlang+fsharp+fortran+glsl+go+go-module+gradle+java+lua+makefile+markdown+ruby+rust+sql+tcl */
|
||||
code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green}
|
29
assets/prism/prism.js
Normal file
29
assets/prism/prism.js
Normal file
File diff suppressed because one or more lines are too long
2
build.rb
2
build.rb
|
@ -4,7 +4,9 @@ require "phlexite"
|
|||
require "tailwindcss/phlexite"
|
||||
require "front_matter_parser"
|
||||
|
||||
require_relative "util/markdown"
|
||||
require_relative "util/post_loader"
|
||||
require_relative "util/heroicons"
|
||||
require_relative "pages/layout"
|
||||
require_relative "pages/home"
|
||||
require_relative "pages/blog"
|
||||
|
|
|
@ -34,6 +34,7 @@ module Pages
|
|||
meta(charset: "utf-8")
|
||||
meta(name: "viewport", content: "width=device-width, initial-scale=1.0")
|
||||
link(rel: "stylesheet", href: "/tailwind.css")
|
||||
link(rel: "stylesheet", href: "/prism/prism.css")
|
||||
|
||||
script(defer: true, 'data-domain' => "farthergate.com", src: "https://plausible.farthergate.com/js/script.js")
|
||||
|
||||
|
@ -65,6 +66,8 @@ module Pages
|
|||
p { "built with phlexite and tailwindcss" }
|
||||
p { "© #{Time.now.year} Aleks Rūtiņš" }
|
||||
}
|
||||
|
||||
script(src: "/prism/prism.js")
|
||||
}
|
||||
}
|
||||
end
|
||||
|
|
|
@ -8,7 +8,14 @@ class Pages::Post < ::Phlex::HTML
|
|||
render ::Pages::Layout.new({title: meta['title']}) {
|
||||
article(class: 'prose prose-lg m-auto') {
|
||||
h1 { meta['title'] }
|
||||
time(datetime: meta['published_on']) { meta['published_on'] }
|
||||
if meta['published_on']
|
||||
time(datetime: meta['published_on']) { meta['published_on'] }
|
||||
else
|
||||
div(class: 'flex flex-row gap-2 -my-5 items-center') {
|
||||
raw safe(::Util::Heroicons.pencil_square('size-4 block'))
|
||||
p { 'Draft' }
|
||||
}
|
||||
end
|
||||
|
||||
hr
|
||||
|
||||
|
|
9
util/heroicons.rb
Normal file
9
util/heroicons.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module Util
|
||||
module Heroicons
|
||||
def self.pencil_square(cls)
|
||||
"<svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" viewBox=\"0 0 24 24\" stroke-width=\"1.5\" stroke=\"currentColor\" class=\"#{cls}\">
|
||||
<path stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10\" />
|
||||
</svg>"
|
||||
end
|
||||
end
|
||||
end
|
5
util/markdown.rb
Normal file
5
util/markdown.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class Phlex::Markdown
|
||||
def view_template
|
||||
template
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue