{{- /* Tutorial-specific Schema.org markup */ -}}

{{- $title := .Title | default .Site.Title -}}
{{- $description := .Description | default .Summary | default .Site.Params.description | default .Site.Title -}}
{{- $image := .Params.image | default .Site.Params.seo.default_image | default "/assets/images/logo.png" -}}
{{- $image = $image | absURL -}}
{{- $url := .Permalink | default .RelPermalink | absURL -}}
{{- $author := .Params.author | default .Site.Params.author | default .Site.Title -}}
{{- $duration := .Params.duration | default "PT30M" -}}
{{- $difficulty := .Params.level | default "beginner" -}}
{{- $category := .Params.category | default "technology" -}}

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "HowTo",
  "name": "{{ $title }}",
  "description": "{{ $description }}",
  "image": "{{ $image }}",
  "totalTime": "{{ $duration }}",
  "estimatedCost": {
    "@type": "MonetaryAmount",
    "currency": "EUR",
    "value": "0"
  },
  "tool": [
    {
      "@type": "HowToTool",
      "name": "{{ .Params.primary_tool | default "Ordinateur" }}"
    }
    {{- if .Params.tools -}}
    {{- range .Params.tools -}}
    ,{
      "@type": "HowToTool",
      "name": "{{ . }}"
    }
    {{- end -}}
    {{- end -}}
  ],
  "supply": [
    {
      "@type": "HowToSupply",
      "name": "{{ .Params.primary_supply | default "Connexion Internet" }}"
    }
    {{- if .Params.supplies -}}
    {{- range .Params.supplies -}}
    ,{
      "@type": "HowToSupply",
      "name": "{{ . }}"
    }
    {{- end -}}
    {{- end -}}
  ],
  "step": [
    {{- range $index, $step := .Params.steps -}}
    {{- if $index }},{{ end }}
    {
      "@type": "HowToStep",
      "position": {{ add $index 1 }},
      "name": "{{ $step.name }}",
      "text": "{{ $step.description | default $step.text }}",
      "url": "{{ $url }}#step-{{ add $index 1 }}",
      "image": "{{ $image }}"
    }
    {{- end -}}
  ],
  "educationalLevel": "{{ $difficulty }}",
  "teaches": "{{ .Params.skill | default "compétences informatiques" }}",
  "inLanguage": "fr-FR",
  "audience": {
    "@type": "EducationalAudience",
    "educationalRole": "learner"
  },
  "author": {
    "@type": "Person",
    "name": "{{ $author }}",
    "url": "{{ .Site.BaseURL }}"
  },
  "publisher": {
    "@type": "Organization",
    "name": "{{ .Site.Title }}",
    "url": "{{ .Site.BaseURL }}"
  },
  "datePublished": "{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}",
  "dateModified": "{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}"
}
</script>