mirror of
https://github.com/rustdesk/doc.rustdesk.com.git
synced 2026-04-09 09:16:27 +00:00
seo/geo
This commit is contained in:
26
layouts/partials/utils/breadcrumb-schema-object.html
Normal file
26
layouts/partials/utils/breadcrumb-schema-object.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{{- $breadcrumb := false -}}
|
||||
{{- $items := slice -}}
|
||||
{{- if not .Params.disableBreadcrumb -}}
|
||||
{{- range $index, $ancestor := .Ancestors.Reverse -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "ListItem"
|
||||
"position" (add $index 1)
|
||||
"name" $ancestor.Title
|
||||
"item" $ancestor.Permalink
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "ListItem"
|
||||
"position" (add (len $items) 1)
|
||||
"name" .Title
|
||||
"item" .Permalink
|
||||
) -}}
|
||||
{{- if gt (len $items) 1 -}}
|
||||
{{- $breadcrumb = dict
|
||||
"@type" "BreadcrumbList"
|
||||
"@id" (printf "%s#breadcrumb" .Permalink)
|
||||
"itemListElement" $items
|
||||
-}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $breadcrumb -}}
|
||||
5
layouts/partials/utils/clean-structured-label.html
Normal file
5
layouts/partials/utils/clean-structured-label.html
Normal file
@@ -0,0 +1,5 @@
|
||||
{{- $label := . | default "" -}}
|
||||
{{- $label = $label | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- $label = replaceRE `^[0-9]+(?:\s*[.,::、))-]\s*|\s+)` "" $label -}}
|
||||
{{- $label = replaceRE `^[A-Za-z](?:\s*[.)]\s*|\s+)` "" $label -}}
|
||||
{{- return $label -}}
|
||||
32
layouts/partials/utils/faq-schema-items.html
Normal file
32
layouts/partials/utils/faq-schema-items.html
Normal file
@@ -0,0 +1,32 @@
|
||||
{{- $items := slice -}}
|
||||
{{- $raw := .RawContent | default "" -}}
|
||||
{{- if $raw -}}
|
||||
{{- $sections := after 1 (split (printf "\n%s" $raw) "\n## ") -}}
|
||||
{{- range $sections -}}
|
||||
{{- if lt (len $items) 8 -}}
|
||||
{{- $section := printf "## %s" . -}}
|
||||
{{- $lines := split $section "\n" -}}
|
||||
{{- $question := replaceRE `^##\s+` "" (index $lines 0) | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- if and $question (or (hasSuffix $question "?") (hasSuffix $question "?")) -}}
|
||||
{{- $answerRaw := delimit (after 1 $lines) "\n" -}}
|
||||
{{- $answerRaw = replaceRE "(?ms)```.*?```" " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^!\[[^\n]*$` " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^\{\{%[^\n]*$` " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^\{\{<[^\n]*$` " " $answerRaw -}}
|
||||
{{- $answerRaw = replaceRE `(?m)^-{3,}$` " " $answerRaw -}}
|
||||
{{- $answer := $answerRaw | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- if gt (len $answer) 40 -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "Question"
|
||||
"name" $question
|
||||
"acceptedAnswer" (dict
|
||||
"@type" "Answer"
|
||||
"text" (truncate 320 $answer)
|
||||
)
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
46
layouts/partials/utils/howto-schema-items.html
Normal file
46
layouts/partials/utils/howto-schema-items.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{{- $page := . -}}
|
||||
{{- $items := slice -}}
|
||||
{{- $raw := $page.RawContent | default "" -}}
|
||||
{{- if and $raw (not (in $page.RelPermalink "/faq/")) (not (in $page.RelPermalink "/strategy/")) -}}
|
||||
{{- $sections := after 1 (split (printf "\n%s" $raw) "\n## ") -}}
|
||||
{{- range $i, $sectionText := $sections -}}
|
||||
{{- if lt (len $items) 3 -}}
|
||||
{{- $section := printf "## %s" $sectionText -}}
|
||||
{{- $lines := split $section "\n" -}}
|
||||
{{- $name := replaceRE `^##\s+` "" (index $lines 0) | partial "utils/clean-structured-label.html" -}}
|
||||
{{- if and $name (not (or (hasSuffix $name "?") (hasSuffix $name "?") (in $name ","))) -}}
|
||||
{{- $body := delimit (after 1 $lines) "\n" -}}
|
||||
{{- $body = replaceRE "(?ms)```.*?```" " " $body -}}
|
||||
{{- $body = replaceRE `(?m)^!\[[^\n]*$` " " $body -}}
|
||||
{{- $body = replaceRE `(?m)^\{\{%[^\n]*$` " " $body -}}
|
||||
{{- $body = replaceRE `(?m)^\{\{<[^\n]*$` " " $body -}}
|
||||
{{- $stepsRaw := findRE `(?m)^\d+\.\s+.+$` $body -}}
|
||||
{{- if ge (len $stepsRaw) 3 -}}
|
||||
{{- $steps := slice -}}
|
||||
{{- range $stepIndex, $stepRaw := first 8 $stepsRaw -}}
|
||||
{{- $stepText := replaceRE `^\d+\.\s+` "" $stepRaw | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- if gt (len $stepText) 10 -}}
|
||||
{{- $steps = $steps | append (dict
|
||||
"@type" "HowToStep"
|
||||
"position" (add $stepIndex 1)
|
||||
"name" (truncate 120 $stepText)
|
||||
"text" $stepText
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if ge (len $steps) 3 -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "HowTo"
|
||||
"@id" (printf "%s#howto-%d" $page.Permalink (add (len $items) 1))
|
||||
"name" $name
|
||||
"url" $page.Permalink
|
||||
"inLanguage" $page.Site.Language.Lang
|
||||
"step" $steps
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
21
layouts/partials/utils/toc-schema-items.html
Normal file
21
layouts/partials/utils/toc-schema-items.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{{- $page := . -}}
|
||||
{{- $items := slice -}}
|
||||
{{- $raw := $page.RawContent | default "" -}}
|
||||
{{- if and (or $page.IsPage $page.IsSection) $raw -}}
|
||||
{{- $raw = replaceRE "(?ms)```.*?```" "\n" $raw -}}
|
||||
{{- range findRE `(?m)^#{2,3}\s+.+$` $raw -}}
|
||||
{{- if lt (len $items) 12 -}}
|
||||
{{- $rawLine := replaceRE `^#{2,3}\s+` "" . | markdownify | plainify | htmlUnescape | replaceRE "\\s+" " " | chomp -}}
|
||||
{{- $line := partial "utils/clean-structured-label.html" $rawLine -}}
|
||||
{{- if gt (len $line) 2 -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "ListItem"
|
||||
"position" (add (len $items) 1)
|
||||
"name" $line
|
||||
"url" (printf "%s#%s" $page.Permalink ($rawLine | anchorize))
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
46
layouts/partials/utils/video-schema-items.html
Normal file
46
layouts/partials/utils/video-schema-items.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{{- $page := . -}}
|
||||
{{- $items := slice -}}
|
||||
{{- $seenIDs := slice -}}
|
||||
{{- $raw := $page.RawContent | default "" -}}
|
||||
{{- if $raw -}}
|
||||
{{- $raw = replaceRE `\r?\n\]\(` `](` $raw -}}
|
||||
{{- $currentHeading := $page.Title -}}
|
||||
{{- range split $raw "\n" -}}
|
||||
{{- $line := . -}}
|
||||
{{- $headingMatch := findRESubmatch `^#{2,3}\s+(.+)$` $line -}}
|
||||
{{- with $headingMatch -}}
|
||||
{{- $currentHeading = index (index . 0) 1 | partial "utils/clean-structured-label.html" -}}
|
||||
{{- end -}}
|
||||
{{- $matches := findRESubmatch `\[(.*?)\]\((https?://(?:www\.)?(?:youtube\.com/watch\?v=[^)#\s]+|youtu\.be/[^)#\s]+)[^)]*)\)` $line -}}
|
||||
{{- range $matches -}}
|
||||
{{- if lt (len $items) 8 -}}
|
||||
{{- $title := index . 1 | partial "utils/clean-structured-label.html" -}}
|
||||
{{- $url := index . 2 | chomp -}}
|
||||
{{- $videoID := "" -}}
|
||||
{{- if in $url "youtu.be/" -}}
|
||||
{{- $videoID = replaceRE `^.*youtu\.be/([^?&#/]+).*$` `$1` $url -}}
|
||||
{{- else -}}
|
||||
{{- $videoID = replaceRE `^.*[?&]v=([^?&#/]+).*$` `$1` $url -}}
|
||||
{{- end -}}
|
||||
{{- if or (not $title) (eq $title $url) (hasPrefix $title "http://") (hasPrefix $title "https://") -}}
|
||||
{{- $title = $currentHeading | default $page.Title -}}
|
||||
{{- end -}}
|
||||
{{- if and $title $videoID (not (in $seenIDs $videoID)) -}}
|
||||
{{- $seenIDs = $seenIDs | append $videoID -}}
|
||||
{{- $items = $items | append (dict
|
||||
"@type" "VideoObject"
|
||||
"@id" (printf "%s#video-%s" $page.Permalink $videoID)
|
||||
"name" $title
|
||||
"url" $url
|
||||
"embedUrl" (printf "https://www.youtube.com/embed/%s" $videoID)
|
||||
"thumbnailUrl" (printf "https://i.ytimg.com/vi/%s/hqdefault.jpg" $videoID)
|
||||
"inLanguage" $page.Site.Language.Lang
|
||||
"isPartOf" (dict "@id" (printf "%s#webpage" $page.Permalink))
|
||||
"publisher" (dict "@id" "https://rustdesk.com/#organization")
|
||||
) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $items -}}
|
||||
Reference in New Issue
Block a user