{{- $wcPage := .wcPage -}} {{- $wcBlock := .wcBlock -}} {{- $wcIdentifier := .wcIdentifier -}} {{- $st := $wcBlock.design.spacing | default dict -}} {{- $pad := $st.padding | default (slice "4rem" "0" "4rem" "0") -}}
{{ with $wcBlock.content.title }}

{{ . | markdownify }}

{{ end }} {{ with $wcBlock.content.subtitle }}

{{ . | markdownify }}

{{ end }}
{{ with $wcBlock.content.view_all }} {{ end }}
{{/* Get trending questions dynamically or from static config */}} {{ $questions := slice }} {{/* Method 1: Dynamic - Pull from pages with trending: true */}} {{ $count := $wcBlock.content.count | default 4 }} {{ $trending_pages := where site.RegularPages "Params.trending" true }} {{ $trending_pages = $trending_pages.ByParam "trending_weight" | default ($trending_pages.ByDate.Reverse) }} {{ $trending_pages = first $count $trending_pages }} {{ if $trending_pages }} {{ range $trending_pages }} {{ $question_item := dict }} {{ $question_item = merge $question_item (dict "question" (.Params.question | default .Title)) }} {{ $question_item = merge $question_item (dict "link" .RelPermalink) }} {{ $question_item = merge $question_item (dict "answer_preview" (.Params.answer_preview | default .Params.answer | default .Summary | plainify | truncate 150)) }} {{/* Optional metadata */}} {{ with .Params.author }} {{ $question_item = merge $question_item (dict "author" .) }} {{ end }} {{ with .Params.views }} {{ $question_item = merge $question_item (dict "views" .) }} {{ end }} {{ with .Params.upvote_count }} {{ $question_item = merge $question_item (dict "upvotes" .) }} {{ end }} {{ with .Params.badge }} {{ $question_item = merge $question_item (dict "badge" .) }} {{ else }} {{/* Default badges based on metadata */}} {{ if gt (.Params.upvote_count | default 0) 50 }} {{ $question_item = merge $question_item (dict "badge" (dict "text" "🔥 Popular" "color" "bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-200")) }} {{ else if .Params.featured }} {{ $question_item = merge $question_item (dict "badge" (dict "text" "⭐ Featured" "color" "bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-200")) }} {{ else if (time .Date).After (now.AddDate 0 0 -7) }} {{ $question_item = merge $question_item (dict "badge" (dict "text" "✨ New" "color" "bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-200")) }} {{ else }} {{ $question_item = merge $question_item (dict "badge" (dict "text" "🔥 Trending" "color" "bg-amber-100 text-amber-800 dark:bg-amber-900/30 dark:text-amber-200")) }} {{ end }} {{ end }} {{ $questions = $questions | append $question_item }} {{ end }} {{ end }} {{/* Method 2: Static fallback - Use config if no trending pages found */}} {{ if not $questions }} {{ $questions = $wcBlock.content.questions }} {{ end }} {{/* Questions list or carousel */}}
{{ range $index, $question := $questions }}
{{/* Badge */}} {{ with .badge }}
{{ .text }}
{{ end }} {{/* Question */}}

{{ .question }}

{{/* Answer preview */}} {{ with .answer_preview }}

{{ . }}

{{ end }} {{/* Meta info */}}
{{ with .author }} {{ . }} {{ end }} {{ with .views }} {{ . }} {{ end }} {{ with .upvotes }} {{ . }} helpful {{ end }}
Read →
{{ end }}
{{/* Mobile view all link */}} {{ with $wcBlock.content.view_all }} {{ end }}