@bep added a todo
shortcode on the hugo doc site and added the list of pages with this shortcode, which is very useful for not forgetting the todos
I stole that for my hugo documentation site & extended it because I found very useful to have a visual reminder on the rendered page and not only on the code.
So while browsing the site i can see:
- what remains to do
- where in the page this todo located
Just call {{< todo >}} whatever I want to be done {{< /todo >}}
I also added a parameter on the front matter in case you donât need it rendered (my use case is public documentation vs. internal documentation).
So you get the information rendered only on one of those case:
- Your front matter parameter is
listTodo = true
- Your are in server mode whatever is your parameter value
I donât know if this could be usefull for hugo documentation or someone else, but just in case âŠ
shortcode : todo.html
{{ if (or .Site.IsServer .Site.Params.listTodo) }}
{{ if .Inner }}<div id="draft-warning">-#- TODO : {{ .Inner }} -#-</div>{{ end }}
{{ end }}
front matter parameter
[params]
listTodo = true # affiche la liste des TODO avec les derniers changements
css for showing the todo content inside the rendered page
#draft-warning {
position: relative;
top: 50%;
-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-o-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
z-index: 1;
float: right;
display: block;
margin: 0px 0px;
padding: 1rem;
background-color: red;
border: 0.1rem solid black;
color: yellow;
font-size: 80%;
}
Get the list of todo pages with the content text todo
<!-- Affiche les TODO si besoin -->
{{ if (or .Site.IsServer .Site.Params.listTodo) }}
{{ .Scratch.Set "todos" slice }}
{{ range .Site.RegularPages }}
{{ if .HasShortcode "todo" }}
{{ $.Scratch.Add "todos" . }}
{{ end }}
{{ end }}
<h2 id="todos">Pages marquées avec des TODO</h2>
<table>
<thead>
<tr>
<th>DerniĂšre modification</th>
<th>Lien</th>
<th>Contenu du TODO</th>
</tr>
</thead>
<tbody>
{{ range (.Scratch.Get "todos") }}
<tr>
<td>{{ .Lastmod.Format "02 Jan 2006" }}</td>
<td>
<a href="{{ .Permalink }}">{{ .Title }}</a>
</td>
<td>
{{ $_x := (findRE "-#-(.|\n)*?-#-" .Content) }}
{{ range $_x }}
<li>{{ . }}
{{ end }}
</td>
</tr>
{{ end }}
</tbody>
</table>
{{ end }}