Add Go module hosting
This commit is contained in:
parent
7c4208375a
commit
b42d31fa4c
3 changed files with 36 additions and 1 deletions
8
build.rb
8
build.rb
|
@ -10,6 +10,10 @@ require_relative "pages/blog"
|
||||||
require_relative "pages/about"
|
require_relative "pages/about"
|
||||||
require_relative "pages/post"
|
require_relative "pages/post"
|
||||||
|
|
||||||
|
def go_modules = {
|
||||||
|
"farthergate.com/stack" => "https://git.farthergate.com/aleks/stack"
|
||||||
|
}
|
||||||
|
|
||||||
Phlexite::Site.new { |s|
|
Phlexite::Site.new { |s|
|
||||||
s.build_dir = 'public'
|
s.build_dir = 'public'
|
||||||
|
|
||||||
|
@ -24,4 +28,8 @@ Phlexite::Site.new { |s|
|
||||||
posts.each do |post|
|
posts.each do |post|
|
||||||
s.page "p/#{post[:slug]}/index.html", Pages::Post.new(post)
|
s.page "p/#{post[:slug]}/index.html", Pages::Post.new(post)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
go_modules.each do |import, repo|
|
||||||
|
s.page "#{import.delete_prefix('farthergate.com/')}", Pages::GoMod.new(import, repo)
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
22
pages/gomod.rb
Normal file
22
pages/gomod.rb
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
class Pages::GoMod < ::Phlex::HTML
|
||||||
|
def initialize(import, repo)
|
||||||
|
@import = import
|
||||||
|
@repo = repo
|
||||||
|
end
|
||||||
|
def view_template
|
||||||
|
meta = @post[:data].front_matter
|
||||||
|
render ::Pages::Layout.new({title: meta['title']}, meta: {
|
||||||
|
"go-import" => "#{import} git #{repo}"
|
||||||
|
}) {
|
||||||
|
p {
|
||||||
|
h1 { @import }
|
||||||
|
p {
|
||||||
|
plain "This is a generated page to host the Go module located at "
|
||||||
|
a(href: repo) { repo }
|
||||||
|
plain ". You'll probably find more information about it over there."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -19,13 +19,14 @@ module Pages
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def initialize(page)
|
def initialize(page, meta:)
|
||||||
@page = page
|
@page = page
|
||||||
if @page.is_a? Symbol
|
if @page.is_a? Symbol
|
||||||
@page_info = pages[page]
|
@page_info = pages[page]
|
||||||
else
|
else
|
||||||
@page_info = @page
|
@page_info = @page
|
||||||
end
|
end
|
||||||
|
@meta = meta
|
||||||
end
|
end
|
||||||
def view_template
|
def view_template
|
||||||
|
|
||||||
|
@ -38,6 +39,10 @@ module Pages
|
||||||
link(rel: "prefetch", href: "/DM_Mono/DMMono-Regular.ttf")
|
link(rel: "prefetch", href: "/DM_Mono/DMMono-Regular.ttf")
|
||||||
link(rel: "prefetch", href: "/DM_Mono/DMMono-Medium.ttf")
|
link(rel: "prefetch", href: "/DM_Mono/DMMono-Medium.ttf")
|
||||||
link(rel: "stylesheet", href: "/site.css")
|
link(rel: "stylesheet", href: "/site.css")
|
||||||
|
|
||||||
|
@meta.each { |name, content|
|
||||||
|
meta(name: name, content: content)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
body {
|
body {
|
||||||
header {
|
header {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue