Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Docsy 0.6.0 via NPM module (1.31 backport) #49473

Merged
merged 11 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ nohup.out
.hugo_build.lock

# Netlify Functions build output
package-lock.json
/functions/
/node_modules/

Expand Down
4 changes: 0 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
[submodule "themes/docsy"]
path = themes/docsy
url = https://github.com/google/docsy.git
branch = v0.3.0
[submodule "api-ref-generator"]
path = api-ref-generator
url = https://github.com/kubernetes-sigs/reference-docs
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ FROM docker.io/library/golang:1.23.0-alpine3.20
RUN apk add --no-cache \
runuser \
git \
gcompat \
openssh-client \
rsync \
npm
Expand Down
25 changes: 18 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@ NETLIFY_FUNC = $(NODE_BIN)/netlify-lambda
# CONTAINER_ENGINE=podman make container-image
CONTAINER_ENGINE ?= docker
IMAGE_REGISTRY ?= gcr.io/k8s-staging-sig-docs
IMAGE_VERSION=$(shell scripts/hash-files.sh Dockerfile Makefile | cut -c 1-12)
IMAGE_VERSION=$(shell scripts/hash-files.sh Dockerfile Makefile package.json package-lock.json | cut -c 1-12)
CONTAINER_IMAGE = $(IMAGE_REGISTRY)/k8s-website-hugo:v$(HUGO_VERSION)-$(IMAGE_VERSION)
# Mount read-only to allow use with tools like Podman in SELinux mode
# Container targets don't need to write into /src
CONTAINER_RUN = "$(CONTAINER_ENGINE)" run --rm --interactive --tty --volume "$(CURDIR):/src:ro,Z"
CONTAINER_RUN_TTY = "$(CONTAINER_ENGINE)" run --rm --interactive --tty
CONTAINER_HUGO_MOUNTS = \
--read-only \
--mount type=bind,source=$(CURDIR)/.git,target=/src/.git,readonly \
--mount type=bind,source=$(CURDIR)/archetypes,target=/src/archetypes,readonly \
--mount type=bind,source=$(CURDIR)/assets,target=/src/assets,readonly \
--mount type=bind,source=$(CURDIR)/content,target=/src/content,readonly \
--mount type=bind,source=$(CURDIR)/data,target=/src/data,readonly \
--mount type=bind,source=$(CURDIR)/i18n,target=/src/i18n,readonly \
--mount type=bind,source=$(CURDIR)/layouts,target=/src/layouts,readonly \
--mount type=bind,source=$(CURDIR)/static,target=/src/static,readonly \
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
--mount type=bind,source=$(CURDIR)/hugo.toml,target=/src/hugo.toml,readonly

CCRED=\033[0;31m
CCEND=\033[0m
Expand Down Expand Up @@ -98,15 +111,13 @@ docker-push: ## Build a multi-architecture image and push that into the registry

container-build: module-check
mkdir -p public
$(CONTAINER_RUN) --read-only \
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 \
--mount type=bind,source=$(CURDIR)/public,target=/src/public $(CONTAINER_IMAGE) \
hugo --cleanDestinationDir --buildDrafts --buildFuture --environment preview --noBuildLock
$(CONTAINER_RUN_TTY) $(CONTAINER_HUGO_MOUNTS) $(CONTAINER_IMAGE) \
hugo --destination /tmp/public --cleanDestinationDir --buildDrafts --buildFuture --environment preview --noBuildLock

# no build lock to allow for read-only mounts
container-serve: module-check ## Boot the development server using container.
$(CONTAINER_RUN) --cap-drop=ALL --cap-add=AUDIT_WRITE --read-only \
--mount type=tmpfs,destination=/tmp,tmpfs-mode=01777 -p 1313:1313 $(CONTAINER_IMAGE) \
$(CONTAINER_RUN_TTY) --cap-drop=ALL --cap-add=AUDIT_WRITE $(CONTAINER_HUGO_MOUNTS) \
-p 1313:1313 $(CONTAINER_IMAGE) \
hugo server --buildDrafts --buildFuture --environment development --bind 0.0.0.0 --destination /tmp/public --cleanDestinationDir --noBuildLock

test-examples:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ git clone https://github.com/kubernetes/website.git
cd website
```

The Kubernetes website uses the [Docsy Hugo theme](https://github.com/google/docsy#readme). Even if you plan to run the website in a container, we strongly recommend pulling in the submodule and other development dependencies by running the following:
The Kubernetes website uses git submodules. Even if you plan to run the website in a container, we strongly recommend pulling in the submodule and other development dependencies by running the following:

### Windows

Expand Down
33 changes: 15 additions & 18 deletions assets/scss/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ body.td-home main[role="main"] > section:first-of-type .content p:first-child {

body.td-404 main .error-details {
max-width: 1100px;
margin-left: auto;
margin-right: auto;
margin-top: 4em;
margin-bottom: 0;
margin: 0 auto;
}

/* Global - Mermaid.js diagrams */
Expand Down Expand Up @@ -417,8 +414,6 @@ footer {
}


/* COMMUNITY */

body.cid-community {
main > * h1 {
visibility: hidden;
Expand Down Expand Up @@ -1123,13 +1118,6 @@ body.cid-community #cncf-code-of-conduct h2:after {
}
}

@media only screen and (max-width: 767px) {
body.cid-community .community-section h2:before,
body.cid-community .community-section h2:after {
display: none;
}
}

#caseStudies body > #deprecation-warning, body.cid-casestudies > #deprecation-warning, body.cid-community > #deprecation-warning {
display: inline-block;
vertical-align: top;
Expand Down Expand Up @@ -1591,7 +1579,7 @@ html.no-js body div#announcement {
// default background is blue; overrides are possible
color: #fff;
display: none; // When javascript is available, Let javascript handle the state of the announcement

.announcement-main {
margin-left: auto;
margin-right: auto;
Expand Down Expand Up @@ -1828,7 +1816,7 @@ div.alert > em.javascript-required {
align-items: center;
background-color: #fff;
border: 1px solid #4c4c4c;
border-radius: 20px;
border-radius: 20px;
vertical-align: middle;
flex-grow: 1;
overflow-x: hidden;
Expand Down Expand Up @@ -1857,7 +1845,7 @@ div.alert > em.javascript-required {
#search .pagefind-ui form input {
background-color: #fff;
border: 1px solid #4c4c4c;
border-radius: 20px;
border-radius: 20px;
overflow-x: hidden;
width: auto;
padding: 6px 10px !important;
Expand Down Expand Up @@ -1912,7 +1900,7 @@ body.td-search #search {
}

/* CSS for 'figure' full-screen display */

/* Define styles for full-screen overlay */
.figure-fullscreen-overlay {
position: fixed;
Expand Down Expand Up @@ -1941,7 +1929,7 @@ body.td-search #search {
/* Define styles for close button */
.figure-close-button {
position: absolute;
top: 1%;
top: 1%;
right: 2%;
cursor: pointer;
font-size: calc(5vw + 10px);
Expand All @@ -1954,6 +1942,10 @@ body.td-search #search {
padding: 0.2rem;
}

.includecode .highlight {
margin-top: 0;
margin-bottom: 0;
}

// handle main page features on narrow viewports
@media screen and (max-width: 768px) {
Expand Down Expand Up @@ -1985,4 +1977,9 @@ section.k8s-birthday-override:has(div.k8s-birthday-override.revert-to-previous i
@extend .table;
}
}
}

// Work around issue surfaced in k/website PR #49031
body.cid-partners .td-outer, body.cid-community .td-outer {
height: initial;
}
8 changes: 4 additions & 4 deletions content/en/docs/contribute/style/diagram-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ Figure 6. Pod Topology Spread Constraints.

Code block:

```
```text
graph TB
subgraph "zoneB"
n3(Node3)
Expand Down Expand Up @@ -528,7 +528,7 @@ Figure 7. Ingress

Code block:

```mermaid
```text
graph LR;
client([client])-. Ingress-managed <br> load balancer .->ingress[Ingress];
ingress-->|routing rule|service[Service];
Expand Down Expand Up @@ -556,7 +556,7 @@ K8s components to start a container.

Code block:

```
```text
%%{init:{"theme":"neutral"}}%%
sequenceDiagram
actor me
Expand Down Expand Up @@ -592,7 +592,7 @@ In the code for
[figure 7](https://mermaid-js.github.io/mermaid-live-editor/edit/#eyJjb2RlIjoiZ3JhcGggIExSXG4gIGNsaWVudChbY2xpZW50XSktLiBJbmdyZXNzLW1hbmFnZWQgPGJyPiBsb2FkIGJhbGFuY2VyIC4tPmluZ3Jlc3NbSW5ncmVzc107XG4gIGluZ3Jlc3MtLT58cm91dGluZyBydWxlfHNlcnZpY2VbU2VydmljZV07XG4gIHN1YmdyYXBoIGNsdXN0ZXJcbiAgaW5ncmVzcztcbiAgc2VydmljZS0tPnBvZDFbUG9kXTtcbiAgc2VydmljZS0tPnBvZDJbUG9kXTtcbiAgZW5kXG4gIGNsYXNzRGVmIHBsYWluIGZpbGw6I2RkZCxzdHJva2U6I2ZmZixzdHJva2Utd2lkdGg6NHB4LGNvbG9yOiMwMDA7XG4gIGNsYXNzRGVmIGs4cyBmaWxsOiMzMjZjZTUsc3Ryb2tlOiNmZmYsc3Ryb2tlLXdpZHRoOjRweCxjb2xvcjojZmZmO1xuICBjbGFzc0RlZiBjbHVzdGVyIGZpbGw6I2ZmZixzdHJva2U6I2JiYixzdHJva2Utd2lkdGg6MnB4LGNvbG9yOiMzMjZjZTU7XG4gIGNsYXNzIGluZ3Jlc3Msc2VydmljZSxwb2QxLHBvZDIgazhzO1xuICBjbGFzcyBjbGllbnQgcGxhaW47XG4gIGNsYXNzIGNsdXN0ZXIgY2x1c3RlcjtcbiIsIm1lcm1haWQiOiJ7XG4gIFwidGhlbWVcIjogXCJkZWZhdWx0XCJcbn0iLCJ1cGRhdGVFZGl0b3IiOmZhbHNlLCJhdXRvU3luYyI6dHJ1ZSwidXBkYXRlRGlhZ3JhbSI6dHJ1ZX0),
you can see examples of both.

```
```text
classDef k8s fill:#326ce5,stroke:#fff,stroke-width:4px,color:#fff; // defines style for the k8s class
class ingress,service,pod1,pod2 k8s; // k8s class is applied to elements ingress, service, pod1 and pod2.
```
Expand Down
19 changes: 10 additions & 9 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ title = "Kubernetes"

# Hugo allows theme composition (and inheritance). The precedence is from left to right.
theme = ["docsy"]
themesDir = "node_modules"

# Language settings
contentDir = "content/en"
Expand Down Expand Up @@ -248,44 +249,44 @@ no = 'Sorry to hear that. Please <a href="https://github.com/USERNAME/REPOSITORY
[[params.links.user]]
name_key = "community_youtube_name"
url = "https://youtube.com/kubernetescommunity"
icon = "fab fa-youtube"
icon = "fa-brands fa-youtube"

[[params.links.user]]
name_key = "community_forum_name"
url = "https://discuss.kubernetes.io"
icon = "fa fa-envelope"
icon = "fa-solid fa-envelope"

[[params.links.user]]
name_key = "community_server_fault_name"
url = "https://serverfault.com/questions/tagged/kubernetes"
icon = "fab fa-stack-overflow"
icon = "fa-brands fa-stack-overflow"

[[params.links.user]]
name_key = "community_x_name"
url = "https://twitter.com/kubernetesio"
icon = "fab fa-twitter"
icon = "fa-brands fa-twitter"
# Replace with fa-x-twitter once available

# Developer relevant links. These will show up on right side of footer and in the community page if you have one.
[[params.links.developer]]
name_key = "community_contributor_site_name"
url = "https://k8s.dev/"
icon = "fas fa-laptop-code"
icon = "fa-solid fa-laptop-code"

[[params.links.developer]]
name_key = "community_github_name"
url = "https://github.com/kubernetes/kubernetes"
icon = "fab fa-github"
icon = "fa-brands fa-github"

[[params.links.developer]]
name_key = "community_slack_name"
url = "https://slack.k8s.io"
icon = "fab fa-slack"
icon = "fa-brands fa-slack"

[[params.links.developer]]
name_key = "community_calendar_name"
url = "https://calendar.google.com/calendar/embed?src=calendar%40kubernetes.io"
icon = "fas fa-calendar-alt"
icon = "fa-solid fa-calendar-days"

# Language definitions.

Expand Down Expand Up @@ -357,7 +358,7 @@ languageNameLatinScript = "Deutsch"

[languages.hi]
title = "Kubernetes"
languageName = "हिन्दी (Hindi)"
languageName = "हिन्दी (Hindi)"
weight = 6
contentDir = "content/hi"
languagedirection = "ltr"
Expand Down
2 changes: 2 additions & 0 deletions layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{ define "main" }}
{{ partial "handle-version-switch-404.html" . }}
<div class="td-content">
<section id="error-404" class="error-details">
<p>
{{ T "error_404_were_you_looking_for" }}
Expand All @@ -11,4 +12,5 @@
{{ end }}
</ul>
</section>
</div>
{{ end }}
2 changes: 1 addition & 1 deletion layouts/blog/baseof.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
><!-- inside main element -->
{{ with .CurrentSection.OutputFormats.Get "rss" -}}
<a class="btn btn-lg -bg-orange td-rss-button d-none d-lg-block" href="{{ .Permalink | safeURL }}" target="_blank">
RSS <i class="fa fa-rss ml-2 "></i>
RSS <i class="fa-solid fa-rss ml-2 "></i>
</a>
{{ end -}}
{{ block "main" . }}{{ end }}
Expand Down
16 changes: 8 additions & 8 deletions layouts/partials/blog-meta-links.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<div class="td-page-blog-meta ml-2 pb-1 pt-2 mb-4">
{{ with site.Home.OutputFormats.Get "rss" -}}
<link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink | safeURL }}" title="{{ site.Title }}">
<a class="widget-link" href="{{ .Permalink | safeURL }}" target="_blank"><div> <i class="fas fa-rss fab-icon"> </i> <span class="widget-link-text">RSS Feed</span></div> </a>
<a class="widget-link" href="{{ .Permalink | safeURL }}" target="_blank"><div> <i class="fa-solid fa-rss"> </i> <span class="widget-link-text">RSS Feed</span></div> </a>
{{ end -}}
<a class="widget-link" href="https://kubernetes.io/docs/contribute/new-content/blogs-case-studies/" target="_blank"><div> <i class="fa fa-edit fab-icon"></i> <span class="widget-link-text">Submit a Post</span></div></a>
<a class="widget-link" href="https://twitter.com/kubernetesio" target="_blank"><div> <i class="fab fa-twitter-square fab-icon"> </i> <span class="widget-link-text"> @Kubernetesio</span></div></a>
<a class="widget-link" href="https://github.com/kubernetes/kubernetes" target="_blank"><div> <i class="fab fa-github-square fab-icon"></i> <span class="widget-link-text"> on GitHub </span></div></a>
<a class="widget-link" href="http://slack.k8s.io" target="_blank"><div><i class="fab fa-slack fab-icon"> </i> <span class="widget-link-text">#kubernetes-users </span></div></a>
<a class="widget-link" href="https://stackoverflow.com/questions/tagged/kubernetes" target="_blank"><div><i class="fab fa-stack-overflow fab-icon"></i> <span class="widget-link-text"> Stack Overflow</span></div></a>
<a class="widget-link" href="https://discuss.kubernetes.io" target="_blank"><div> <i class="fab fa-discourse fab-icon"></i><span class="widget-link-text"> Forum </span></div></a>
<a class="widget-link" href="https://kubernetes.io/docs/setup"><div><i class="fa fa-download fab-icon"></i> <span class="widget-link-text"> Kubernetes</span></div></a>
<a class="widget-link" href="https://kubernetes.io/docs/contribute/new-content/blogs-case-studies/" target="_blank"><div> <i class="fa-solid fa-pen-to-square"></i> <span class="widget-link-text">Submit a Post</span></div></a>
<a class="widget-link" href="https://twitter.com/kubernetesio" target="_blank"><div> <i class="fa-brands fa-twitter-square"> </i> <span class="widget-link-text"> @Kubernetesio</span></div></a>
<a class="widget-link" href="https://github.com/kubernetes/kubernetes" target="_blank"><div> <i class="fa-brands fa-square-github"></i> <span class="widget-link-text"> on GitHub </span></div></a>
<a class="widget-link" href="http://slack.k8s.io" target="_blank"><div><i class="fa-brands fa-slack"> </i> <span class="widget-link-text">#kubernetes-users </span></div></a>
<a class="widget-link" href="https://stackoverflow.com/questions/tagged/kubernetes" target="_blank"><div><i class="fa-brands fa-stack-overflow"></i> <span class="widget-link-text"> Stack Overflow</span></div></a>
<a class="widget-link" href="https://discuss.kubernetes.io" target="_blank"><div> <i class="fa-brands fa-discourse"></i><span class="widget-link-text"> Forum </span></div></a>
<a class="widget-link" href="https://kubernetes.io/docs/setup"><div><i class="fa-solid fa-download"></i> <span class="widget-link-text"> Kubernetes</span></div></a>
</div>
6 changes: 3 additions & 3 deletions layouts/partials/blog-sidebar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{/* The blog nav organizes posts grouped by year, which represents a customized version of the
{{/* The blog nav organizes posts grouped by year, which represents a customized version of the
sidebar-tree in use elsewhere on the site. */}}

{{/* We cache this partial for bigger sites and set the active class client side. */}}
Expand All @@ -8,10 +8,10 @@

<form class="td-sidebar__search d-flex align-items-center">
{{ partial "search-input.html" . }}
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fas fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
<button class="btn btn-link td-sidebar__toggle d-md-none p-0 ml-3 fa-solid fa-bars" type="button" data-toggle="collapse" data-target="#td-section-nav" aria-controls="td-docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
</button>
</form>

<nav class="collapse td-sidebar-nav pt-2 pl-4" id="td-section-nav">
<!-- {{ if (gt (len .Site.Home.Translations) 0) }}
<div class="nav-item dropdown d-block d-lg-none">
Expand Down
6 changes: 3 additions & 3 deletions layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@
{{ partial "css.html" . }}
<!-- Content for social media sharing previews -->
<!-- Facebook uses the og: stuff, while Twitter and others use twitter: -->
<meta name="description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Summary }}{{ end }}">
<meta property="og:description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Summary }}{{ end }}">
<meta name="twitter:description" content="{{ if .Params.description }}{{ .Params.description }}{{ else }}{{ .Summary }}{{ end }}">
<meta name="description" content="{{ template "partials/page-description.html" . }}">
<meta property="og:description" content="{{ template "partials/page-description.html" . }}">
<meta name="twitter:description" content="{{ template "partials/page-description.html" . }}">
<meta property="og:url" content="{{ .Permalink }}">
<meta property="og:title" content="{{ if .Params.title }}{{ .Title }}{{ else }}{{ .Summary | truncate 10 }}{{ end }}">
<meta name="twitter:title" content="{{ if .Params.title }}{{ .Title }}{{ else }}{{ .Summary | truncate 10 }}{{ end }}">
Expand Down
10 changes: 0 additions & 10 deletions layouts/partials/hooks/head-end.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@
{{- end -}}
{{- end -}}

{{ if .HasShortcode "mermaid" }}
<!-- Copied from https://unpkg.com/[email protected]/dist/mermaid.min.js -->
{{- with resources.Get "js/mermaid-10.6.1.min.js" -}}
<script src="{{ .RelPermalink }}" integrity="sha384-+NGfjU8KzpDLXRHduEqW+ZiJr2rIg+cidUVk7B51R5xK7cHwMKQfrdFwGdrq1Bcz"></script>
{{- else -}}
<!-- without Mermaid, the site won't appear right -->
{{- errorf "No Mermaid helper script found" -}}
{{- end -}}
{{- end -}}

{{- if eq .Layout "glossary" -}}
{{- with resources.Get "js/glossary.js" -}}
<script defer src="{{ .RelPermalink }}"></script>
Expand Down
Loading