MaNDoS

Markdown Node Display Server

Quick Start

1. Create a HTML Template

Create a folder named mandos in your Markdown folder.**

cd /path/to/markdown/folder && mkdir mandos

Create a file named main.html within. This will be the default template used to serve the markdown files.

Example main.html:

<!DOCTYPE html>
<html>
<head><title>{{.Title}}</title></head>
<body>{{ToHtml .Content}}</body>
</html>

Go to the ## Template Functions And Variables section if you want to know more about what functions and variables you can use in a template file.

You can create as many templates as you want within this folder. To use them, add a template field to the metadata part of your markdown note and set the value as the name of the template.

Here is an example template metadata field with the value of foo.html:

---
template: foo.html
---

# My Markdown Note
This node will be served in the foo.html template.

The metadata part must be at the top of the markdown file, and must be formatted as YAML.

2. Create static Folder

You need to create a folder named static at the root of your Markdown folder.

cd /path/to/markdown/folder && mkdir static

3 Run The Server

MD_FOLDER=/path/to/markdown/folder INDEX=index.md ONLY_PUBLIC=no MD_TEMPLATES=/path/to/templates/folder SOLO_TEMPLATES=rss.xml,node-list.json go -C /path/to/mandos run .

If you want to run the server with TLS encryption, you can use the CERT and KEY environment variables and pass the respective file paths to them.

Template Functions And Variables

There are some variables and functions you can use inside a template. If it's a Markdown template, there are 9 basic variables you can use:

The functions below can be used in both markdown templates and solo templates.

Solo Templates

A solo template is a non-markdown file that can execute the template functions inside, when you navigate to its endpoint. These files can be used to, for example, create an RSS feed.

Here is an example node-list.json file to create a node list in json format. It allows you to create cool graphs like the ones in Obsidian.

{{- $listLen := len ListNodes -}}
[{{- range $i, $v := ListNodes -}}

{{- $olLen := len $v.OutLinks -}}
{{- $ilLen := len $v.InLinks -}}

{"file":"{{$v.File -}}",
"title":"{{ReplaceStr $v.Title `"` `\"` }}",
"tags":[
	{{- range $tagi,$tag := $v.Tags -}} "{{$tag}}"
		{{- if ne (Add $tagi 1) (len $v.Tags)}},{{end -}}
	{{- end -}}
],
"outlinks":[
	{{- range $oli, $olv := $v.OutLinks -}} "{{$olv}}"
		{{- if ne (Add $oli 1) $olLen }},{{end -}}
	{{- end -}}
],
"inlinks":[
	{{- range $ili, $ilv := $v.InLinks -}} "{{$ilv}}"
		{{- if ne (Add $ili 1) $ilLen }},{{end -}}
	{{- end -}}
]}{{if ne (Add $i 1) $listLen}},{{end -}}

{{- end -}}]

And here is an example rss.xml file to create an RSS feed.

<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel>
<title>Zenarvus</title>
<link>https://zenarvus.com/rss.xml</link>
<description>My second brain on the web.</description>
{{- range (SortNodesByDate ListNodes) -}}

{{- if not .Date.IsZero -}}
<item>
<title>{{.Title}}</title>
<link>https://zenarvus.com{{.File}}</link>
<pubDate>{{.Date.Format "Mon, 02 Jan 2006 15:04:05 GMT"}}</pubDate>
</item>
{{end}}

{{- end -}}
</channel></rss>

Additional Tips