Skip to content

Commit

Permalink
Merge pull request #14 from edrlab/layout
Browse files Browse the repository at this point in the history
Layout
  • Loading branch information
gautierchomel authored Jul 8, 2024
2 parents 372ef04 + 351496d commit 8ef7ffa
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ target = '$1'

############################# Outputs ############################
[outputs]
home = ["HTML", "RSS", "WebAppManifest", "SearchIndex"]
home = ["HTML", "RSS", "WebAppManifest", "SearchIndex", "json"]
section = ["HTML", "json", "csv"]

############################# Imaging ############################
[imaging]
Expand Down
1 change: 1 addition & 0 deletions layouts/rules/list.csv.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rubrique;title;detail;abstract;categories;agrege;opquast;indiceebook;description;before;weight;after;actif;layout;date;tags;objectif;Meo;Controle;Source;Referentiel;Steps;
74 changes: 74 additions & 0 deletions layouts/rules/list.json.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }}
{{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }}
{{- else }}
{{- $pages = $pctx.Pages }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{ $length := (len $pages) -}}
{
"version": "https://jsonfeed.org/version/1.1",
"title": "{{ if eq .Title site.Title }}{{ site.Title }}{{ else }}{{ with .Title }}{{ . }} {{ i18n "string_on" }} {{ end }}{{ site.Title }}{{ end }}",
"description": "{{ i18n "string_recent_content" }} {{ if ne .Title site.Title }}{{ with .Title }}{{ i18n "string_in" }} {{ . }} {{ end }}{{ end }}{{ i18n "string_on" }} {{ site.Title }}",
"home_page_url": "{{ site.BaseURL }}",
{{ with .OutputFormats.Get "JSON" -}}
"feed_url": "{{ .Permalink }}",
{{ end -}}
{{ with site.LanguageCode -}}
"language": "{{ . }}",
{{ end -}}
{{ with $.Param "icon" -}}
"icon": "{{ . | absURL }}",
{{ end -}}
{{ with $.Param "favicon" -}}
"favicon": "{{ . | absURL }}",
{{ end -}}
{{ with site.Params.author.name -}}
"authors": [
{
"name": "{{ . }}"{{ with site.Params.author.url }},
"url": "{{ . }}"{{ end }}{{ with site.Params.author.avatar }},
"avatar": "{{ . | absURL }}"{{ end }}
}
],
{{ end -}}
"items": [
{{ range $index, $element := $pages -}}
{
"title": {{ .Title | jsonify }},
"date_published": "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}",
"date_modified": "{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}",
"id": "{{ .Permalink }}",
"url": "{{ .Permalink }}",
"Rubrique": {{ .Params.Rubrique | jsonify }},
"detail": {{ .Params.detail | jsonify }},
"abstract": {{ .Params.abstract | jsonify }},
"categories": {{ .Params.categories | jsonify }},
"agrege": {{ .Params.agrege | jsonify }},
"opquast": {{ .Params.opquast | jsonify }},
"indiceebook": {{ .Params.indiceebook | jsonify }},
"description": {{ .Params.description | jsonify }},
"before": {{ .Params.before | jsonify }},
"weight": {{ .Params.weight | jsonify }},
"after": {{ .Params.after | jsonify }},
"actif": {{ .Params.actif | jsonify }},
"layout": {{ .Params.layout | jsonify }},
"date": {{ .Params.date | jsonify }},
"tags": {{ .Params.tags | jsonify }},
"objectif": {{ .Params.objectif | jsonify }},
"Meo": {{ .Params.Meo | jsonify }},
"Controle": {{ .Params.Controle | jsonify }},
"Source": {{ .Params.Source | jsonify }},
"Referentiel": {{ .Params.Referentiel | jsonify }},
"Steps": {{ .Params.Steps | jsonify }},

"content_html": {{ .Content | jsonify }}
}{{ if ne (add $index 1) $length }},{{ end }}
{{ end -}}
]
}

0 comments on commit 8ef7ffa

Please sign in to comment.