Skip to content

Commit

Permalink
fix: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Apr 25, 2024
1 parent ce1457e commit 159fe0d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 45 deletions.
19 changes: 9 additions & 10 deletions docs/hooks/00-copy-readme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ local json = require("json")
ForFile = "00-readme.md"

function Writer(filedata)
local sourcedata = json.decode(filedata)
if sourcedata.name == "00-readme.html"
then
local f = assert(io.open(wdir.."/../readme.md", "rb"))
local content = f:read("*all")
f:close()
sourcedata.content = content
end
return json.encode(sourcedata)
end
local sourcedata = json.decode(filedata)
if sourcedata.name == "00-readme.html" then
local f = assert(io.open(wdir .. "/../readme.md", "rb"))
local content = f:read("*all")
f:close()
sourcedata.content = content
end
return json.encode(sourcedata)
end
67 changes: 34 additions & 33 deletions docs/hooks/01-add-navigation.lua
Original file line number Diff line number Diff line change
@@ -1,39 +1,41 @@
---@diagnostic disable-next-line: undefined-global
local wdir = workingdir

package.path = package.path .. ";" .. wdir .. "/lib/?.lua"

local json = require("json")
local alvu = require("alvu")
local utils = require(wdir .. ".lib.utils")

function Writer(filedata)
local pagesPath = wdir .. "/pages"
local index = {}
local files = alvu.files(pagesPath)

for fileIndex = 1, #files do
local file_name = files[fileIndex]
if not (file_name == "_layout.html" or file_name == "index.md" or utils.starts_with(file_name,"concepts/"))
then
local name = string.gsub(file_name, ".md", "")
name = string.gsub(name, ".html", "")
local title, _ = utils.normalize(name):lower()

table.insert(index, {
name = title,
slug = name
})
end
end

table.insert(index, 1, {
name = "..",
slug = "index"
})

local source_data = json.decode(filedata)

local template = [[
local pagesPath = wdir .. "/pages"
local index = {}
local files = alvu.files(pagesPath)

for fileIndex = 1, #files do
local file_name = files[fileIndex]
if
not (file_name == "_layout.html" or file_name == "index.md" or utils.starts_with(file_name, "concepts/"))
then
local name = string.gsub(file_name, ".md", "")
name = string.gsub(name, ".html", "")
local title, _ = utils.normalize(name):lower()

table.insert(index, {
name = title,
slug = name,
})
end
end

table.insert(index, 1, {
name = "..",
slug = "index",
})

local source_data = json.decode(filedata)

local template = [[
<header class="container">
<nav>
{{$baseurl:=.Meta.BaseURL}}
Expand All @@ -42,13 +44,12 @@ function Writer(filedata)
{{end}}
</nav>
</header>
<main class="container">
]]

source_data.content = template .. "\n" .. source_data.content .. "</main>"
source_data.data = {
index = index
}
source_data.content = template .. "\n" .. source_data.content
source_data.data = {
index = index,
}

return json.encode(source_data)
return json.encode(source_data)
end
2 changes: 1 addition & 1 deletion docs/pages/01-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ can be defined as shown below
<html lang="en">
<head></head>
<body>
{ { .Content } }
<slot></slot>
</body>
</html>
```
Expand Down
4 changes: 3 additions & 1 deletion docs/pages/_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
</head>

<body>
{{.Content}}
<main class="container">
<slot></slot>
</main>
<footer class="container">
Built with <a href="http://github.com/barelyhuman/alvu">alvu</a>
</footer>
Expand Down

0 comments on commit 159fe0d

Please sign in to comment.