


{{/* Get profile data */}}
{{ $displayName := "" }}
{{ $name := "" }}
{{ $picture := "" }}
{{ $about := "" }}

{{ range hugo.Data.profile }}
    {{ range . }}
        {{ range .tags }}
            {{ if eq (index . 0) "display_name" }}
                {{ $displayName = index . 1 }}
            {{ else if eq (index . 0) "name" }}
                {{ $name = index . 1 }}
            {{ else if eq (index . 0) "picture" }}
                {{ $picture = index . 1 }}
            {{ else if eq (index . 0) "about" }}
                {{ $about = index . 1 }}
            {{ end }}
        {{ end }}
    {{ end }}
{{ end }}

{{/* Fallback if display_name is empty */}}
{{ if not $displayName }}
    {{ $displayName = $name }}
{{ end }}

{{/* If still empty, use site title */}}
{{ if not $displayName }}
    {{ $displayName = .Site.Title }}
{{ end }}

{{/* Clean about text - remove markdown and HTML */}}
{{ $cleanAbout := $about | plainify | htmlUnescape }}
{{ $cleanAbout = trim $cleanAbout " \n\r\t" }}

{{/* Truncate to 160 chars for SEO */}}
{{ $truncatedAbout := $cleanAbout }}
{{ if gt (len $truncatedAbout) 160 }}
    {{ $truncatedAbout = substr $truncatedAbout 0 160 | printf "%s…" }}
{{ end }}

{{/* Hugo escaping functions */}}
{{ $escapedTitle := $displayName | safeHTMLAttr }}
{{ $escapedDescription := $truncatedAbout | safeHTMLAttr }}
{{ $escapedPicture := $picture | safeURL }}
{{ $escapedSiteTitle := .Site.Title | safeHTMLAttr }}

{{/* Build time in ISO 8601 format */}}
{{ $buildTime := now.Format "2006-01-02T15:04:05-07:00" }}
{{ $buildTimeRFC3339 := now.Format "2006-01-02T15:04:05Z07:00" }}

{{/* Hugo version */}}
{{ $hugoVersion := hugo.Version }}

{{/* Base URL */}}
{{ $baseURL := .Site.BaseURL | safeURL }}
{{ $permalink := .Permalink | safeURL }}

<!-- Primary Meta Tags -->
<title>{{ $escapedTitle }}{{ if ne $escapedTitle $escapedSiteTitle }} | {{ $escapedSiteTitle }}{{ end }}</title>
<meta name="title" content="{{ $escapedTitle }}" />
<meta name="description" content="{{ $escapedDescription }}" />
<meta name="author" content="{{ $escapedTitle }}" />
<meta name="generator" content="Hugo {{ $hugoVersion }}" />

<!-- Modified Date -->
<meta name="dc.date.modified" scheme="ISO8601" content="{{ $buildTime }}" />
<meta name="dcterms.modified" content="{{ $buildTime }}" />

<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:url" content="{{ $permalink }}" />
<meta property="og:title" content="{{ $escapedTitle }}" />
<meta property="og:description" content="{{ $escapedDescription }}" />
{{ if $picture }}
<meta property="og:image" content="{{ $escapedPicture }}" />
{{ end }}
<meta property="og:site_name" content="{{ $escapedTitle }}" />
<meta property="article:published_time" content="{{ $buildTimeRFC3339 }}" />
<meta property="article:modified_time" content="{{ $buildTimeRFC3339 }}" />

<!-- Twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:url" content="{{ $permalink }}" />
<meta name="twitter:title" content="{{ $escapedTitle }}" />
<meta name="twitter:description" content="{{ $escapedDescription }}" />
<link rel="alternate" hreflang="x-default" href="https://setto.basspistol.com" />
{{ if $picture }}
<meta name="twitter:image" content="{{ $escapedPicture }}" />
<meta name="twitter:image:alt" content="{{ $escapedTitle }}" />
{{ end }}

<!-- Additional SEO -->
<link rel="canonical" href="{{ $permalink }}" />
<meta name="robots" content="index, follow" />
<meta name="language" content="English" />
<meta name="revisit-after" content="7 days" />

<!-- Theme Color for mobile browsers -->
<meta name="theme-color" content="#ffd700" />
<meta name="msapplication-TileColor" content="#ffd700" />

<!-- Favicon fallback -->
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ctext y='.9em' font-size='90'%3E⚡%3C/text%3E%3C/svg%3E" />

<!-- JSON-LD Structured Data -->
<script type="application/ld+json">
{{- $personSchema := dict
    "@context" "https://schema.org"
    "@type" "Person"
    "name" ($displayName | safeHTML)
    "description" ($cleanAbout | safeHTML)
    "url" $baseURL
-}}
{{- if $picture -}}
    {{- $personSchema = merge $personSchema (dict "image" ($picture | safeHTML)) -}}
{{- end -}}
{{- $personSchema | jsonify (dict "indent" "  ") | safeJS -}}
</script>

<script type="application/ld+json">
{{- $websiteSchema := dict
    "@context" "https://schema.org"
    "@type" "WebSite"
    "name" ($displayName | safeHTML)
    "description" ($cleanAbout | safeHTML)
    "url" $baseURL
    "dateModified" $buildTimeRFC3339
-}}
{{- $websiteSchema | jsonify (dict "indent" "  ") | safeJS -}}
</script>

<script type="application/ld+json">
{{- $breadcrumbSchema := dict
    "@context" "https://schema.org"
    "@type" "BreadcrumbList"
    "itemListElement" (slice (dict
        "@type" "ListItem"
        "position" 1
        "name" "Home"
        "item" $baseURL
    ))
-}}
{{- $breadcrumbSchema | jsonify (dict "indent" "  ") | safeJS -}}
</script>
