Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
barelyhuman committed Jul 18, 2023
1 parent 8fe46b0 commit 1d2c7c1
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 7 deletions.
5 changes: 3 additions & 2 deletions docs/hooks/01-add-navigation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ function Writer(filedata)
local files = alvu.files(pagesPath)

for fileIndex = 1, #files do
if not (files[fileIndex] == "_layout.html" or files[fileIndex] == "index.md")
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(files[fileIndex], ".md", "")
local name = string.gsub(file_name, ".md", "")
name = string.gsub(name, ".html", "")
local title, _ = utils.normalize(name):lower()

Expand Down
5 changes: 5 additions & 0 deletions docs/lib/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,9 @@ function Lib.totitlecase(name)
end)
end

function Lib.starts_with(str,start)
return string.sub(str,1,string.len(start))==start
end


return Lib
2 changes: 1 addition & 1 deletion docs/pages/01-basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ to each file.
Pretty self-explanatory but the `public` folder will copy everything
put into it to the `dist` folder. This can be used for assets, styles, etc.

Let's move forward to [scripting →]({{.Meta.BaseURL}}02-scripting)
Let's move forward to [scripting →]({{.Meta.BaseURL}}concepts/scripting)
7 changes: 7 additions & 0 deletions docs/pages/03-concepts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Concepts

Explanation of primary blocks of functionality when working with
alvu

- [Scripting]({{.Meta.BaseURL}}concepts/scripting)
- [Writers and Hooks]({{.Meta.BaseURL}}concepts/writers)
26 changes: 24 additions & 2 deletions docs/pages/06-recipes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Recipes

[Jump to Templates](#templates)
### TOC

- [Watching for Changes](#watching-for-changes)
- [Importing Other lua files](#importing-other-lua-files)
- [String Interpolation](#string-interpolation)
- [String Functions](#string-functions)
- [Get Files from a Dir](#get-files-from-a-directory)
- [Reading Writing Files](#reading--writing-files)
- [Templates](#templates)

Methods and ways to be able to do basic tasks while working with alvu

Expand All @@ -12,6 +20,8 @@ I use [entr](https://github.com/eradman/entr) as a file notifier which can run a
ls docs/**/* | entr -cr alvu --path='./docs'
```

> **Note**: since v0.2.9, alvu comes with it's own file watcher and live-reload but is limited to the `public` and `pages` directory and it is still recommended to use `entr` if you wish to handle watching custom paths
This will list all files in the `docs` folder (root of an alvu project) and then run the alvu command while specifying the base path to be `./docs`

## Importing other lua files
Expand All @@ -38,7 +48,7 @@ local function interpolate(s, tab)
end

-- usage
interpolate("this is a ${message} string", { message = "interpolated" })
interpolate("this is an ${message} string", { message = "interpolated" })
```

## String Functions
Expand All @@ -59,6 +69,18 @@ You can read more about these from the [gopher-lua-libs](https://github.com/vadv

If working with blogs and nested data you might wanna get files in a directory and you can use the following function

There's 2 methods, you can either use the `alvu` helper library or you can add the `scandir` function shown below to
your `libs` folder if you wish to maintain control over the file reading functionality

- Using `alvu` helpers

```lua
local alvu = require("alvu")
local all_files = alvu.files(path)
```

- Custom function

```lua
function scandir(directory)
local i, t, popen = 0, {}, io.popen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ end
The above only runs for the file `00-readme.md` and is responsible for copying the contents
of the `readme.md` and overwriting the `00-readme.md` file's content with it at **build time**

[More about Writers → ]({{.Meta.BaseURL}}03-writers)
[More about Writers → ]({{.Meta.BaseURL}}concepts/writers)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ sure you order the hooks with file names

## `Writer`

The [Scripting]({{.Meta.BaseURL}}02-scripting) section, covers most of what this writer does but
The [Scripting]({{.Meta.BaseURL}}concepts/scripting) section, covers most of what this writer does but
to reiterate, the `Writer` hooks are called for everyfile in the `pages`
directory and allow you to manipulate the content of the file before it gets
compiled
Expand Down

0 comments on commit 1d2c7c1

Please sign in to comment.