♻️ Refactor projects section to use data file
This commit is contained in:
parent
9e96d2a6ed
commit
6c56f6dc5f
4 changed files with 70 additions and 81 deletions
|
|
@ -57,6 +57,14 @@
|
|||
{{ range .Resources.Match "sections/*.md" }}
|
||||
<aside id="{{ .Params.id }}" class="{{ .Params.class }}">
|
||||
{{ .Content }}
|
||||
{{- if eq .Params.id "projects" }}
|
||||
{{ $dataPath := "data/projects.yaml" }}
|
||||
{{ with $.Resources.Get $dataPath }}
|
||||
{{ partial "projects.html" . }}
|
||||
{{ else }}
|
||||
{{ errorf "Unable to get %s" $dataPath }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</aside>
|
||||
{{ end }}
|
||||
|
||||
|
|
|
|||
18
layouts/_partials/projects.html
Normal file
18
layouts/_partials/projects.html
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
<section class="projects">
|
||||
|
||||
{{ with . | transform.Unmarshal -}}
|
||||
{{- range $project := . -}}
|
||||
{{- range $slug, $proj := $project -}}
|
||||
<section class="project {{ $slug }}">
|
||||
|
||||
<h3>{{ $proj.name }}</h3>
|
||||
|
||||
<p><a href="{{ $proj.url }}" class="noprint">🔗</a>
|
||||
{{ $proj.desc }}</p>
|
||||
|
||||
</section><!-- /.project.{{ $slug }} -->
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end }}
|
||||
|
||||
</section>
|
||||
Loading…
Add table
Add a link
Reference in a new issue