mirror of
https://github.com/tiennm99/iammiti99.git
synced 2026-10-15 04:18:41 +00:00
feat(theme): share button + QR + vCard + manifest + WebSite schema
Adds share button, QR code block, and Schema.org WebSite markup for enhanced link sharing. Introduces vCard contact export and PWA manifest generation for mobile compatibility. Expands profile distribution and integration capabilities.
This commit is contained in:
1 parent
4d9107cbf7
commit
cde369188e
5 files changed
+101
No files matched your search
@@ -0,0 +1,31 @@
|
||||
{{- $name := site.Params.name | default site.Title -}}
|
||||
{{- $shortName := site.Params.shortName | default (substr $name 0 12) -}}
|
||||
{{- $themeColor := site.Params.themeColor | default "#8b3a2b" -}}
|
||||
{{- $bgColor := site.Params.themeBackground | default "#f4efe6" -}}
|
||||
{{- /* start_url and scope use relURL so subpath deployments (e.g. GitHub Pages
|
||||
project sites at /repo/) install correctly. */ -}}
|
||||
{{- $root := "/" | relURL -}}
|
||||
{{- $hasIcons := or site.Params.appleTouchIcon site.Params.faviconSvg -}}
|
||||
{
|
||||
"name": "{{ $name }}",
|
||||
"short_name": "{{ $shortName }}",
|
||||
"start_url": "{{ $root }}",
|
||||
"scope": "{{ $root }}",
|
||||
"display": "minimal-ui",
|
||||
"background_color": "{{ $bgColor }}",
|
||||
"theme_color": "{{ $themeColor }}"
|
||||
{{- if $hasIcons -}}
|
||||
,
|
||||
"icons": [
|
||||
{{- $first := true -}}
|
||||
{{- with site.Params.appleTouchIcon -}}
|
||||
{{- if $first }}{{ $first = false }}{{ else }},{{ end }}
|
||||
{ "src": "{{ . | relURL }}", "sizes": "180x180", "type": "image/png" }
|
||||
{{- end -}}
|
||||
{{- with site.Params.faviconSvg -}}
|
||||
{{- if $first }}{{ $first = false }}{{ else }},{{ end }}
|
||||
{ "src": "{{ . | relURL }}", "sizes": "any", "type": "image/svg+xml" }
|
||||
{{- end -}}
|
||||
]
|
||||
{{- end }}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{{- $name := site.Params.name | default site.Title -}}
|
||||
{{- /* Flatten links + sections for URL lines. */ -}}
|
||||
{{- $allLinks := slice -}}
|
||||
{{- if site.Params.sections -}}
|
||||
{{- range site.Params.sections -}}{{- range .links -}}{{- $allLinks = $allLinks | append . -}}{{- end -}}{{- end -}}
|
||||
{{- else -}}{{- $allLinks = site.Params.links -}}{{- end -}}
|
||||
BEGIN:VCARD
|
||||
VERSION:3.0
|
||||
FN:{{ $name }}
|
||||
{{ with site.Params.jobTitle }}TITLE:{{ . }}
|
||||
{{ end -}}
|
||||
{{ with site.Params.email }}EMAIL:{{ . }}
|
||||
{{ end -}}
|
||||
{{ with site.Params.location }}ADR:;;{{ . }};;;;
|
||||
{{ end -}}
|
||||
URL:{{ site.BaseURL }}
|
||||
{{ range $allLinks -}}
|
||||
{{- if and .url (not (or (strings.HasPrefix .url "mailto:") (strings.HasPrefix .url "tel:"))) -}}
|
||||
URL;TYPE={{ .title | upper }}:{{ .url }}
|
||||
{{ end -}}
|
||||
{{- end -}}
|
||||
END:VCARD
|
||||
@@ -0,0 +1,15 @@
|
||||
{{- /* Render a QR code of the current page Permalink inside a collapsible <details>.
|
||||
Gated by site.Params.qr = true. Uses Hugo's built-in images.QR (≥ 0.140).
|
||||
The PNG is generated at build time and cached under resources/_gen/. */ -}}
|
||||
{{- if site.Params.qr -}}
|
||||
{{- $url := .Permalink -}}
|
||||
{{- $qr := images.QR $url (dict "level" "medium" "scale" 4) -}}
|
||||
{{- $showLabel := i18n "show_qr" | default "Show QR code" -}}
|
||||
{{- $alt := i18n "qr_alt" | default "QR code linking to this page" -}}
|
||||
<details class="bio__qr">
|
||||
<summary>{{ $showLabel }}</summary>
|
||||
<img class="bio__qr-img" src="{{ $qr.RelPermalink }}"
|
||||
width="{{ $qr.Width }}" height="{{ $qr.Height }}"
|
||||
alt="{{ $alt }}" loading="lazy" decoding="async" />
|
||||
</details>
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,14 @@
|
||||
{{- /* Optional WebSite JSON-LD for rich-snippet eligibility.
|
||||
Off by default — opt in via params.schemaWebSite = true. */ -}}
|
||||
{{- if site.Params.schemaWebSite -}}
|
||||
{{- $name := site.Params.name | default site.Title -}}
|
||||
{{- $payload := dict
|
||||
"@context" "https://schema.org"
|
||||
"@type" "WebSite"
|
||||
"name" $name
|
||||
"url" site.BaseURL
|
||||
"inLanguage" (site.Language.LanguageCode | default site.LanguageCode | default "en")
|
||||
-}}
|
||||
{{- with site.Params.bio -}}{{- $payload = merge $payload (dict "description" .) -}}{{- end -}}
|
||||
<script type="application/ld+json">{{ $payload | jsonify | safeJS }}</script>
|
||||
{{- end -}}
|
||||
@@ -0,0 +1,19 @@
|
||||
{{- /* Render a share button. Uses navigator.share (Web Share API) when available;
|
||||
falls back to clipboard.writeText with a small toast.
|
||||
Loaded only when site.Params.share = true (gated by caller). */ -}}
|
||||
{{- $name := site.Params.name | default site.Title -}}
|
||||
{{- $shareLabel := i18n "share_label" | default "Share this page" -}}
|
||||
{{- $copied := i18n "share_copied" | default "Link copied" -}}
|
||||
{{- $failed := i18n "share_failed" | default "Could not share" -}}
|
||||
<button type="button"
|
||||
class="bio__share"
|
||||
data-bonsai-share
|
||||
data-share-url="{{ .Permalink }}"
|
||||
data-share-title="{{ $name }}"
|
||||
data-toast-copied="{{ $copied }}"
|
||||
data-toast-failed="{{ $failed }}"
|
||||
aria-label="{{ $shareLabel }}">
|
||||
<span class="bio__share-icon" aria-hidden="true">{{ partial "icon.html" "share" }}</span>
|
||||
<span class="bio__share-label">{{ $shareLabel }}</span>
|
||||
</button>
|
||||
<output class="bio__share-toast" role="status" aria-live="polite" hidden></output>
|
||||
Reference in new issue
Block a user