Merge pull request #54543 from SayakMukhopadhyay/rework-docs-layout

feat: align docs layout to Docsy
pull/54747/head
Kubernetes Prow Robot 2026-03-02 11:22:12 +05:30 committed by GitHub
commit eec66ff8d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 128 additions and 140 deletions

View File

@ -1,7 +1,4 @@
{{/*
Copied from Docsy with the addition of the search-input and the customSearch block.
Revisit this if / when either of https://github.com/google/docsy/issues/2194 and https://github.com/google/docsy/pull/1512 are closed
*/}}
{{/* Copied from Docsy with the addition of the search-input and the customSearch block. */}}
{{ define "main" }}
<div id="search-results-search" class="col-sm-6 col-md-6 col-lg-6 mx-auto py-3">

View File

@ -1,5 +1,5 @@
<!doctype html>
<html lang="{{ .Site.Language.Lang }}" class="no-js" dir="{{ or .Site.Language.LanguageDirection `ltr` }}">
<html itemscope itemtype="http://schema.org/WebPage" lang="{{ .Site.Language.Lang }}" class="no-js" dir="{{ or .Site.Language.LanguageDirection `ltr` }}">
<head>
{{ partial "head.html" . }}
</head>
@ -8,51 +8,44 @@
{{ partial "navbar.html" . }}
{{ partial "announcement.html" . }}
{{ block "hero" . }}
<section class="header-hero filler">
</section>
{{ end }}
</header>
<div class="container-fluid td-outer">
<div class="td-main">
<div class="row flex-column flex-md-row">
<div id="sidebarnav" class="split td-sidebar d-print-none">
<div class="row flex-xl-nowrap">
{{/*
Not using any of the bootstrap flex grid classes as they mess up the split bar.
Instead, check the `sidebar-tree.js` for how the widths are handled.
*/}}
<aside id="sidebarnav" class="td-sidebar d-print-none">
{{ partial "sidebar.html" . }}
</div>
<div id="maindoc" class="split pl-md-5 row">
<!--main class="col-12 col-md-9 col-xl-8 pl-md-5" role="main"-->
<main role="main" class="col-xl-8" {{ if ne .Params.cid "docsHome" }}data-pagefind-body{{ end }}{{ if (and .IsPage .Params.description ) }} data-pagefind-meta="description:{{ .Params.description }}"{{ end }}>
{{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
{{ block "deprecation_warning" . }}
{{ partial "version-banner.html" . }}
{{ end }}
{{ block "outdated_content" . }}
{{ partial "docs/outdated_content.html" . }}
{{ end }}
{{ block "main" . }}{{ end }}
{{- if .HasShortcode "thirdparty-content" -}}
{{ block "thirdparty-disclaimer" . }}
{{ partial "docs/thirdparty-disclaimer.html" . }}
{{- end -}}
{{- end -}}
{{- if (.Param "auto_generated") -}}
{{ block "auto-generated-pageinfo" . }}
{{ partial "docs/auto-generated-pageinfo.html" . }}
{{- end -}}
{{- end -}}
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable) (.Site.Config.Services.GoogleAnalytics.ID)) }}
{{ partial "feedback.html" .Site.Params.ui.feedback }}
{{ end }}
{{ partial "page-meta-lastmod.html" . }}
{{ if (.Site.Config.Services.Disqus.Shortname) }}
<br />
{{ partial "disqus-comment.html" . }}
{{ end }}
</main>
<div class="d-none d-xl-block td-toc d-print-none col-xl-4">
{{ partial "toc.html" . }}
</div>
</div> <!--end of main-content-->
</aside>
<aside class="d-none d-xl-block td-sidebar-toc d-print-none">
{{ partial "page-meta-links.html" . }}
{{ partial "toc.html" . }}
</aside>
<main id="maindoc" class="pl-md-5" role="main" {{ if ne .Params.cid "docsHome" }}data-pagefind-body{{ end }}{{ if (and .IsPage .Params.description ) }} data-pagefind-meta="description:{{ .Params.description }}"{{ end }}>
{{ if not .Site.Params.ui.breadcrumb_disable }}{{ partial "breadcrumb.html" . }}{{ end }}
{{ block "deprecation_warning" . }}
{{ partial "version-banner.html" . }}
{{ end }}
{{ block "outdated_content" . }}
{{ partial "docs/outdated_content.html" . }}
{{ end }}
{{ block "main" . }}{{ end }}
{{/* Partial "docs/api-reference-links" determines API reference links for 'partial/page-meta-links.html' */}}
{{ partial "docs/api-reference-links" . }}
{{- if .HasShortcode "thirdparty-content" -}}
{{ block "thirdparty-disclaimer" . }}
{{ partial "docs/thirdparty-disclaimer.html" . }}
{{- end -}}
{{- end -}}
{{- if (.Param "auto_generated") -}}
{{ block "auto-generated-pageinfo" . }}
{{ partial "docs/auto-generated-pageinfo.html" . }}
{{- end -}}
{{- end -}}
</main>
</div>
</div>
</div>

25
layouts/docs/content.html Normal file
View File

@ -0,0 +1,25 @@
<div class="td-content">
{{- if .HasShortcode "kat-button" -}}
<div class="pageinfo pageinfo-secondary">
{{ T "katacoda_message" | safeHTML }}
</div>
{{- end -}}
<h1 data-pagefind-weight="10">{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
<header class="article-meta">
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
</header>
{{ .Content }}
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable) (.Site.Config.Services.GoogleAnalytics.ID)) }}
{{ partial "feedback.html" .Site.Params.ui.feedback }}
<br />
{{ end }}
{{ if (.Site.Config.Services.Disqus.Shortname) }}
<br />
{{ partial "disqus-comment.html" . }}
{{ end }}
{{ partial "page-meta-lastmod.html" . }}
</div>

View File

@ -1,45 +1,27 @@
{{/*
Copied from Docsy with the modification of .Site.Config.Services.GoogleAnalytics and .Site.Config.Services.Disqus as
the existing .Site.GoogleAnalytics and .Site.DisqusShortname are no longer supported.
*/}}
{{ define "main" }}
{{- $child_of_first_section := false -}}
{{- with .Parent -}}
{{- if eq .CurrentSection .FirstSection -}}
{{- $child_of_first_section = true -}}
{{- end -}}
{{- end -}}
<div class="td-content">
{{ $hasContent := false }}
{{ with .File }}
{{ if ne .Filename "" }}
{{ $hasContent = (ge (len $.RawContent) 100) }}
{{ end }}
{{ end }}
{{ if $hasContent }}
{{- if $child_of_first_section -}}
{{ partial "docs/top-section-page" (dict "ctx" $ "page" $ ) }}
{{- else -}}
{{ partial "docs/content-page" (dict "ctx" $ "page" $ ) }}
<!-- Partial "docs/api-reference-links" determines API reference links for 'partial/page-meta-links.html' -->
{{ partial "docs/api-reference-links" $ }}
{{- end -}}
{{ else }}
<h1>{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
{{ end }}
<div class="td-content">
<h1>{{ .Title }}</h1>
{{ with .Params.description }}<div class="lead">{{ . | markdownify }}</div>{{ end }}
<header class="article-meta">
{{ partial "taxonomy_terms_article_wrapper.html" . }}
{{ if (and (not .Params.hide_readingtime) (.Site.Params.ui.readingtime.enable)) }}
{{ partial "reading-time.html" . }}
{{ end }}
</header>
{{ .Content }}
{{ partial "section-index.html" . }}
</div>
{{ end }}
{{ define "hero" }}
{{- $child_of_first_section := false -}}
{{- with .Parent -}}
{{- if eq .CurrentSection .FirstSection -}}
{{- $child_of_first_section = true -}}
{{- end -}}
{{- end -}}
{{- if $child_of_first_section -}}
<section class="header-hero text-white pb-4 light-text ">
<h1>{{ .Title }}</h1>
</section>
{{- else -}}
<section class="header-hero filler">
</section>
{{- end -}}
{{ if (and (not .Params.hide_feedback) (.Site.Params.ui.feedback.enable) (.Site.Config.Services.GoogleAnalytics.ID)) }}
{{ partial "feedback.html" .Site.Params.ui.feedback }}
<br />
{{ end }}
{{ if (.Site.Config.Services.Disqus.Shortname) }}
<br />
{{ partial "disqus-comment.html" . }}
{{ end }}
{{ partial "page-meta-lastmod.html" . }}
</div>
{{ end }}

View File

@ -1,12 +0,0 @@
{{ define "main" }}
<div class="td-content">
{{- if .HasShortcode "kat-button" -}}
<div class="pageinfo pageinfo-secondary">
{{ T "katacoda_message" | safeHTML }}
</div>
{{- end -}}
{{ partial "docs/content-page" (dict "ctx" . "page" .) }}
<!-- Partial "docs/api-reference-links" determines API reference links for 'partial/page-meta-links.html' -->
{{ partial "docs/api-reference-links" . }}
</div>
{{ end }}

View File

@ -1,27 +1,43 @@
{{/* template adapted from Docsy theme */}}
{{ if .File.Path }}
{{ $pathFormatted := replace .File.Path "\\" "/" }}
{{ $gh_repo := ($.Param "github_repo") }}
{{ $gh_subdir := ($.Param "github_subdir") }}
{{ $gh_project_repo := ($.Param "github_project_repo") }}
{{ $gh_branch := (default "main" ($.Param "github_branch")) }}
<div class="td-page-meta ml-2 pb-1 pt-2 mb-0">
{{ if $gh_repo }}
{{ $gh_repo_path := printf "%s/content/%s" $gh_branch $pathFormatted }}
{{ if and ($gh_subdir) (.Site.Language.Lang) }}
{{ $gh_repo_path = printf "%s/%s/content/%s/%s" $gh_branch $gh_subdir ($.Site.Language.Lang) $pathFormatted }}
{{ else if .Site.Language.Lang }}
{{ $gh_repo_path = printf "%s/content/%s/%s" $gh_branch ($.Site.Language.Lang) $pathFormatted }}
{{ else if $gh_subdir }}
{{ $gh_repo_path = printf "%s/%s/content/%s" $gh_branch $gh_subdir $pathFormatted }}
{{ end }}
{{ $editURL := printf "%s/edit/%s" $gh_repo $gh_repo_path }}
{{ $createURL := printf "%s/edit/%s" $gh_repo $gh_repo_path }}
{{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (htmlEscape $.Title )}}
{{ $newPageStub := resources.Get "stubs/new-page-template.md" }}
{{ $newPageQS := querify "value" $newPageStub.Content "filename" "change-me.md" | safeURL }}
{{ $newPageURL := printf "%s/new/%s?%s" $gh_repo $gh_repo_path $newPageQS }}
{{ if .File }}
{{ $pathFormatted := replace .File.Path "\\" "/" -}}
{{ $gh_repo := ($.Param "github_repo") -}}
{{ $gh_url := ($.Param "github_url") -}}
{{ $gh_subdir := ($.Param "github_subdir") -}}
{{ $gh_project_repo := ($.Param "github_project_repo") -}}
{{ $gh_branch := (default "main" ($.Param "github_branch")) -}}
<div class="td-page-meta ml-2 pb-1 pt-2 mb-0">
{{ if $gh_url -}}
{{ warnf "Warning: use of `github_url` is deprecated. For details see https://www.docsy.dev/docs/adding-content/repository-links/#github_url-optional" -}}
<a href="{{ $gh_url }}" target="_blank"><i class="fa-solid fa-pen-to-square fa-fw"></i> {{ T "post_edit_this" }}</a>
{{ else if $gh_repo -}}
{{ $gh_repo_path := printf "%s/content/%s" $gh_branch $pathFormatted -}}
{{ if and ($gh_subdir) (.Site.Language.Lang) -}}
{{ $gh_repo_path = printf "%s/%s/content/%s/%s" $gh_branch $gh_subdir ($.Site.Language.Lang) $pathFormatted -}}
{{ else if .Site.Language.Lang -}}
{{ $gh_repo_path = printf "%s/content/%s/%s" $gh_branch ($.Site.Language.Lang) $pathFormatted -}}
{{ else if $gh_subdir -}}
{{ $gh_repo_path = printf "%s/%s/content/%s" $gh_branch $gh_subdir $pathFormatted -}}
{{ end -}}
{{/* Adjust $gh_repo_path based on path_base_for_github_subdir */ -}}
{{ $ghs_base := $.Param "path_base_for_github_subdir" -}}
{{ $ghs_rename := "" -}}
{{ if reflect.IsMap $ghs_base -}}
{{ $ghs_rename = $ghs_base.to -}}
{{ $ghs_base = $ghs_base.from -}}
{{ end -}}
{{ with $ghs_base -}}
{{ $gh_repo_path = replaceRE . $ghs_rename $gh_repo_path -}}
{{ end -}}
{{ $viewURL := printf "%s/tree/%s" $gh_repo $gh_repo_path -}}
{{ $editURL := printf "%s/edit/%s" $gh_repo $gh_repo_path -}}
{{ $issuesURL := printf "%s/issues/new?title=%s" $gh_repo (safeURL $.Title ) -}}
{{ $newPageStub := resources.Get "stubs/new-page-template.md" -}}
{{ $newPageQS := querify "value" $newPageStub.Content "filename" "change-me.md" | safeURL -}}
{{ $newPageURL := printf "%s/new/%s?%s" $gh_repo $gh_repo_path $newPageQS -}}
<!-- Accessing API Reference links from "layouts/api-reference-links.html" -->
{{- $apiReferenceMetaLinks := $.Store.Get "apiReferenceMetaLinks" -}}
@ -51,9 +67,9 @@
<a href="#auto-generated-edit-notice" class="auto-generated-notice-link"><i class="d-inline-block fa-fw"></i> {{ T "auto_generated_edit_notice" | safeHTML }}</a>
{{- end -}}
{{ end }}
{{ with .CurrentSection.AlternativeOutputFormats.Get "print" }}
<a id="print" href="{{ .Permalink | safeURL }}"><i class="fa-solid fa-print fa-fw"></i> {{ T "print_entire_section" }}</a>
{{ end }}
</div>
{{ end -}}
{{ with .CurrentSection.AlternativeOutputFormats.Get "print" -}}
<a id="print" href="{{ .Permalink | safeURL }}"><i class="fa-solid fa-print fa-fw"></i> {{ T "print_entire_section" }}</a>
{{ end }}
</div>
{{ end -}}

View File

@ -32,7 +32,6 @@
{{ $jsSearch := resources.Get "js/search.js" | resources.ExecuteAsTemplate "js/search.js" .Site.Home }}
{{ if .Site.Params.offlineSearch }}
{{ $jsSearch = resources.Get "js/offline-search.js" }}
{{/* Revisit this if / when either of https://github.com/google/docsy/issues/2194 and https://github.com/google/docsy/pull/1512 are closed */}}
{{ else if .Site.Params.customSearch }}
{{ $jsSearch = resources.Get "js/custom-search.js" }}
{{ end }}

View File

@ -1,8 +1,4 @@
{{/*
Copied from Docsy with the addition of the customSearch block.
This can be deleted once https://github.com/google/docsy/issues/2194 and https://github.com/google/docsy/pull/1512 are closed
and the site has been updated to incorporate the upstream change.
*/}}
{{/* Copied from Docsy with the addition of the customSearch block. */}}
{{ if .Site.Params.gcs_engine_id -}}
<div class="td-search">
<div class="td-search__icon"></div>

View File

@ -1,8 +0,0 @@
{{ partial "page-meta-links.html" . }}
{{ if not .Params.notoc }}
{{ with .TableOfContents }}
{{ if ge (len .) 100 }}
{{ . }}
{{ end }}
{{ end }}
{{ end }}