diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-09-11 22:02:29 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-09-11 22:02:29 +0200 |
| commit | e55841149d9259f26f4d117daba34b5666a52097 (patch) | |
| tree | 841e8c85615ae3563b6d8a4ea575eb275e0feacd /src/themes/serene/templates/_components/seo.html | |
| parent | treefmt.nix: Update to newest nixpkgs changes (diff) | |
| download | b-peetz.de-e55841149d9259f26f4d117daba34b5666a52097.zip | |
src/themes/serene: Update to newest version
Diffstat (limited to 'src/themes/serene/templates/_components/seo.html')
| -rw-r--r-- | src/themes/serene/templates/_components/seo.html | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/themes/serene/templates/_components/seo.html b/src/themes/serene/templates/_components/seo.html new file mode 100644 index 0000000..361d7d2 --- /dev/null +++ b/src/themes/serene/templates/_components/seo.html @@ -0,0 +1,39 @@ +{% component seo(title, desc, config, url = "", page_type = "website", image = "", colocated_path = "", published = "", updated = "", tags = [], lang = "") %} +{%- set og_image = "" -%} +{%- if image -%} + {%- if image is starting_with(pat="http://") or image is starting_with(pat="https://") or image is starting_with(pat="//") -%} + {%- set og_image = image -%} + {%- elif image is starting_with(pat="/") -%} + {%- set og_image = get_url(path=image) -%} + {%- elif colocated_path -%} + {%- set og_image = get_url(path=colocated_path ~ image) -%} + {%- else -%} + {%- set og_image = get_url(path=image) -%} + {%- endif -%} +{%- elif config.extra.og_image -%} + {%- if config.extra.og_image is starting_with(pat="http://") or config.extra.og_image is starting_with(pat="https://") or config.extra.og_image is starting_with(pat="//") -%} + {%- set og_image = config.extra.og_image -%} + {%- else -%} + {%- set og_image = get_url(path=config.extra.og_image) -%} + {%- endif -%} +{%- endif -%} +<meta name="description" content="{{ desc | striptags | trim }}"> +{% if url %}<link rel="canonical" href="{{ url | safe }}">{% endif %} +<meta property="og:site_name" content="{{ config.title }}"> +<meta property="og:type" content="{{ page_type }}"> +<meta property="og:title" content="{{ title }}"> +<meta property="og:description" content="{{ desc | striptags | trim }}"> +{% if url %}<meta property="og:url" content="{{ url | safe }}">{% endif %} +{% if lang %}<meta property="og:locale" content="{{ lang | replace(from="-", to="_") }}">{% endif %} +{% if og_image %}<meta property="og:image" content="{{ og_image | safe }}">{% endif %} +{% if page_type == "article" %} +{% if published %}<meta property="article:published_time" content="{{ published }}">{% endif %} +{% if updated %}<meta property="article:modified_time" content="{{ updated }}">{% endif %} +{% if tags %}{% for tag in tags %}<meta property="article:tag" content="{{ tag }}"> +{% endfor %}{% endif %} +{% endif %} +<meta name="twitter:card" content="{% if og_image %}summary_large_image{% else %}summary{% endif %}"> +<meta name="twitter:title" content="{{ title }}"> +<meta name="twitter:description" content="{{ desc | striptags | trim }}"> +{% if og_image %}<meta name="twitter:image" content="{{ og_image | safe }}">{% endif %} +{% endcomponent seo %} |
