Skip to content

Commit bc372f6

Browse files
DOC-5503 allow custom name and link for first tab
1 parent 52063a7 commit bc372f6

File tree

3 files changed

+44
-20
lines changed

3 files changed

+44
-20
lines changed

layouts/partials/tabbed-clients-example.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
{{ $redisCommands := .Scratch.Get "redisCommands" }}
55
{{ $redisCommandsLineLimit := (or (.Scratch.Get "maxLines") 100) }}
66
{{ $cliTabName := (or (.Scratch.Get "cli_tab_name") ">_ Redis CLI") }}
7+
{{ $cliFooterLinkText := .Scratch.Get "cli_footer_link_text" }}
8+
{{ $cliFooterLinkUrl := .Scratch.Get "cli_footer_link_url" }}
79

810
{{ if not (isset $.Site.Data.examples $id) }}
911
{{ warnf "[tabbed-clients-example] Example not found %q for %q" $id $.Page }}
@@ -13,7 +15,7 @@
1315
{{/* Render redis-cli example from inner content if any */}}
1416
{{ if (ne (trim $redisCommands "\n") "") }}
1517
{{ $redisCliContent := highlight (trim $redisCommands "\n") "plaintext" (printf "linenos=false,hl_lines=1-%d" $redisCommandsLineLimit ) }}
16-
{{ $tabs = $tabs | append (dict "title" "redis-cli" "displayName" $cliTabName "content" $redisCliContent "limit" $redisCommandsLineLimit) }}
18+
{{ $tabs = $tabs | append (dict "title" "redis-cli" "displayName" $cliTabName "content" $redisCliContent "limit" $redisCommandsLineLimit "customFooterLinkText" $cliFooterLinkText "customFooterLinkUrl" $cliFooterLinkUrl) }}
1719
{{ end }}
1820

1921
{{ $clientExamples := index $.Site.Data.examples $id }}
@@ -41,5 +43,5 @@
4143
{{ end }}
4244
{{ end }}
4345

44-
{{ $params := dict "id" (printf "%s-step%s" $id $step) "tabs" $tabs "showFooter" (eq $lang "") }}
46+
{{ $params := dict "id" (printf "%s-step%s" $id $step) "tabs" $tabs "showFooter" true }}
4547
{{ partial "tabs/wrapper.html" $params }}

layouts/partials/tabs/wrapper.html

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,44 @@
5454
<div class="cli-footer flex items-center justify-between rounded-b-md bg-slate-900 mt-0 px-4 pt-0 mb-0 transition-opacity ease-in-out duration-300 opacity-0 invisible
5555
group-hover:opacity-100 group-hover:visible">
5656
{{ if eq (index $tab "title") "redis-cli" }}
57-
<div class="flex-1 text-xs text-white overflow-ellipsis">{{ $footerText }}</div>
58-
<div class="text-right">
59-
<a href="{{ $btnRIUrl }}" tabindex="1" class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs
60-
hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none
61-
focus:ring-2 focus:white focus:border-slate-500" title="{{$btnRIText}}">
62-
<svg class="w-4 h-4 mr-1" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
63-
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"/>
64-
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"/>
65-
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"/>
66-
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"/>
67-
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"/>
68-
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"/>
69-
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"/>
70-
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"/>
71-
</svg>
72-
<span>{{$btnRIText}}</span>
73-
</a>
74-
</div>
57+
{{ $displayName := index $tab "displayName" }}
58+
{{ $hasCustomTabName := and $displayName (ne $displayName $cliName) }}
59+
{{ $customLinkText := index $tab "customFooterLinkText" }}
60+
{{ $customLinkUrl := index $tab "customFooterLinkUrl" }}
61+
62+
{{ if and $customLinkText $customLinkUrl }}
63+
<div class="text-left">
64+
<a href="{{ $customLinkUrl }}" tabindex="1" class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs
65+
hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none
66+
focus:ring-2 focus:white focus:border-slate-500" title="{{ $customLinkText }}">
67+
<span>{{ $customLinkText }}</span>
68+
</a>
69+
</div>
70+
<div class="flex-1"></div>
71+
{{ else }}
72+
{{ if $hasCustomTabName }}
73+
<div class="flex-1"></div>
74+
{{ else }}
75+
<div class="flex-1 text-xs text-white overflow-ellipsis">{{ $footerText }}</div>
76+
{{ end }}
77+
<div class="text-right">
78+
<a href="{{ $btnRIUrl }}" tabindex="1" class="rounded rounded-mx px-2 py-1 flex items-center text-white text-xs
79+
hover:text-white hover:bg-slate-600 hover:border-transparent focus:outline-none
80+
focus:ring-2 focus:white focus:border-slate-500" title="{{$btnRIText}}">
81+
<svg class="w-4 h-4 mr-1" width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
82+
<path d="M2.26236 5.66895L1.21732 6.07172L7.00018 8.65693V7.79842L2.26236 5.66895Z" fill="#fca5a5"/>
83+
<path d="M2.26236 8.02271L1.21732 8.42548L7.00018 11.0119V10.1516L2.26236 8.02271Z" fill="#fca5a5"/>
84+
<path d="M1.21732 3.7175L7.00018 6.30392V2.87805L8.66273 2.13423L7.00018 1.49512L1.21732 3.7175Z" fill="#fca5a5"/>
85+
<path d="M7.00018 2.8781V6.30366L1.21732 3.71724V5.20004L7.00018 7.79705V8.65526L1.21732 6.07217V7.55496L7.00018 10.1553V11.0135L1.21732 8.42376V9.90656H1.18878L7.00018 12.5051L8.66273 11.7613V2.13428L7.00018 2.8781Z" fill="#f87171"/>
86+
<path d="M9.07336 11.5777L10.7359 10.8338V4.01538L9.07336 4.7592V11.5777Z" fill="#f87171"/>
87+
<path d="M9.07336 4.75867L10.7359 4.01485L9.07336 3.37573V4.75867Z" fill="#fca5a5"/>
88+
<path d="M11.1481 10.6497L12.8112 9.90591V5.896L11.1487 6.63982L11.1481 10.6497Z" fill="#f87171"/>
89+
<path d="M11.1481 6.63954L12.8112 5.89572L11.1481 5.25781V6.63954Z" fill="#fca5a5"/>
90+
</svg>
91+
<span>{{$btnRIText}}</span>
92+
</a>
93+
</div>
94+
{{ end }}
7595
{{ else }}
7696
<!--<a href='/docs/latest/develop/clients/{{ index $tab "quickstartSlug" }}/' tabindex="1" class="rounded rounded-mx px-3 py-1 text-white text-xs-->
7797
<a href='{{ absURL (print "develop/clients/" (index $tab "quickstartSlug")) }}/' tabindex="1" class="rounded rounded-mx px-3 py-1 text-white text-xs

layouts/shortcodes/clients-example.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@
33
{{ .Scratch.Set "lang" (.Get 2) }}
44
{{ .Scratch.Set "maxLines" (.Get 3) }}
55
{{ .Scratch.Set "cli_tab_name" (.Get 4) }}
6+
{{ .Scratch.Set "cli_footer_link_text" (.Get 5) }}
7+
{{ .Scratch.Set "cli_footer_link_url" (.Get 6) }}
68
{{ .Scratch.Set "redisCommands" .Inner }}
79
{{ partial "tabbed-clients-example.html" . }}

0 commit comments

Comments
 (0)