update tabs shortcode
This commit is contained in:
parent
de78f4984c
commit
7a98007a29
|
@ -37,116 +37,151 @@ See [Installing Minikube](/docs/tasks/tools/install-minikube/).
|
||||||
This brief demo guides you on how to start, use, and delete Minikube locally. Follow the steps given below to start and explore Minikube.
|
This brief demo guides you on how to start, use, and delete Minikube locally. Follow the steps given below to start and explore Minikube.
|
||||||
|
|
||||||
1. Start Minikube and create a cluster:
|
1. Start Minikube and create a cluster:
|
||||||
```shell
|
|
||||||
minikube start
|
|
||||||
```
|
|
||||||
The output is similar to this:
|
|
||||||
|
|
||||||
```
|
```shell
|
||||||
Starting local Kubernetes cluster...
|
minikube start
|
||||||
Running pre-create checks...
|
```
|
||||||
Creating machine...
|
|
||||||
Starting local Kubernetes cluster...
|
The output is similar to this:
|
||||||
```
|
|
||||||
For more information on starting your cluster on a specific Kubernetes version, VM, or container runtime, see [Starting a Cluster](#starting-a-cluster).
|
```
|
||||||
|
Starting local Kubernetes cluster...
|
||||||
|
Running pre-create checks...
|
||||||
|
Creating machine...
|
||||||
|
Starting local Kubernetes cluster...
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information on starting your cluster on a specific Kubernetes version, VM, or container runtime, see [Starting a Cluster](#starting-a-cluster).
|
||||||
|
|
||||||
2. Now, you can interact with your cluster using kubectl. For more information, see [Interacting with Your Cluster](#interacting-with-your-cluster).
|
2. Now, you can interact with your cluster using kubectl. For more information, see [Interacting with Your Cluster](#interacting-with-your-cluster).
|
||||||
|
|
||||||
Let’s create a Kubernetes Deployment using an existing image named `echoserver`, which is a simple HTTP server and expose it on port 8080 using `--port`.
|
Let’s create a Kubernetes Deployment using an existing image named `echoserver`, which is a simple HTTP server and expose it on port 8080 using `--port`.
|
||||||
```shell
|
|
||||||
kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10
|
```shell
|
||||||
```
|
kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.10
|
||||||
The output is similar to this:
|
```
|
||||||
```
|
|
||||||
deployment.apps/hello-minikube created
|
The output is similar to this:
|
||||||
```
|
|
||||||
3. To access the `hello-minikube` Deployment, expose it as a Service:
|
```
|
||||||
```shell
|
deployment.apps/hello-minikube created
|
||||||
kubectl expose deployment hello-minikube --type=NodePort --port=8080
|
```
|
||||||
```
|
3. To access the `hello-minikube` Deployment, expose it as a Service:
|
||||||
The option `--type=NodePort` specifies the type of the Service.
|
|
||||||
|
```shell
|
||||||
|
kubectl expose deployment hello-minikube --type=NodePort --port=8080
|
||||||
|
```
|
||||||
|
|
||||||
|
The option `--type=NodePort` specifies the type of the Service.
|
||||||
|
|
||||||
|
The output is similar to this:
|
||||||
|
|
||||||
|
```
|
||||||
|
service/hello-minikube exposed
|
||||||
|
```
|
||||||
|
|
||||||
The output is similar to this:
|
|
||||||
```
|
|
||||||
service/hello-minikube exposed
|
|
||||||
```
|
|
||||||
4. The `hello-minikube` Pod is now launched but you have to wait until the Pod is up before accessing it via the exposed Service.
|
4. The `hello-minikube` Pod is now launched but you have to wait until the Pod is up before accessing it via the exposed Service.
|
||||||
|
|
||||||
Check if the Pod is up and running:
|
Check if the Pod is up and running:
|
||||||
```shell
|
|
||||||
kubectl get pod
|
```shell
|
||||||
```
|
kubectl get pod
|
||||||
If the output shows the `STATUS` as `ContainerCreating`, the Pod is still being created:
|
```
|
||||||
```
|
|
||||||
NAME READY STATUS RESTARTS AGE
|
If the output shows the `STATUS` as `ContainerCreating`, the Pod is still being created:
|
||||||
hello-minikube-3383150820-vctvh 0/1 ContainerCreating 0 3s
|
|
||||||
```
|
```
|
||||||
If the output shows the `STATUS` as `Running`, the Pod is now up and running:
|
NAME READY STATUS RESTARTS AGE
|
||||||
```
|
hello-minikube-3383150820-vctvh 0/1 ContainerCreating 0 3s
|
||||||
NAME READY STATUS RESTARTS AGE
|
```
|
||||||
hello-minikube-3383150820-vctvh 1/1 Running 0 13s
|
|
||||||
```
|
If the output shows the `STATUS` as `Running`, the Pod is now up and running:
|
||||||
|
|
||||||
|
```
|
||||||
|
NAME READY STATUS RESTARTS AGE
|
||||||
|
hello-minikube-3383150820-vctvh 1/1 Running 0 13s
|
||||||
|
```
|
||||||
|
|
||||||
5. Get the URL of the exposed Service to view the Service details:
|
5. Get the URL of the exposed Service to view the Service details:
|
||||||
```shell
|
|
||||||
minikube service hello-minikube --url
|
```shell
|
||||||
```
|
minikube service hello-minikube --url
|
||||||
|
```
|
||||||
|
|
||||||
6. To view the details of your local cluster, copy and paste the URL you got as the output, on your browser.
|
6. To view the details of your local cluster, copy and paste the URL you got as the output, on your browser.
|
||||||
|
|
||||||
The output is similar to this:
|
The output is similar to this:
|
||||||
```
|
|
||||||
Hostname: hello-minikube-7c77b68cff-8wdzq
|
|
||||||
|
|
||||||
Pod Information:
|
```
|
||||||
-no pod information available-
|
Hostname: hello-minikube-7c77b68cff-8wdzq
|
||||||
|
|
||||||
Server values:
|
Pod Information:
|
||||||
server_version=nginx: 1.13.3 - lua: 10008
|
-no pod information available-
|
||||||
|
|
||||||
Request Information:
|
Server values:
|
||||||
client_address=172.17.0.1
|
server_version=nginx: 1.13.3 - lua: 10008
|
||||||
method=GET
|
|
||||||
real path=/
|
|
||||||
query=
|
|
||||||
request_version=1.1
|
|
||||||
request_scheme=http
|
|
||||||
request_uri=http://192.168.99.100:8080/
|
|
||||||
|
|
||||||
Request Headers:
|
Request Information:
|
||||||
|
client_address=172.17.0.1
|
||||||
|
method=GET
|
||||||
|
real path=/
|
||||||
|
query=
|
||||||
|
request_version=1.1
|
||||||
|
request_scheme=http
|
||||||
|
request_uri=http://192.168.99.100:8080/
|
||||||
|
|
||||||
|
Request Headers:
|
||||||
accept=*/*
|
accept=*/*
|
||||||
host=192.168.99.100:30674
|
host=192.168.99.100:30674
|
||||||
user-agent=curl/7.47.0
|
user-agent=curl/7.47.0
|
||||||
|
|
||||||
Request Body:
|
Request Body:
|
||||||
-no body in request-
|
-no body in request-
|
||||||
```
|
```
|
||||||
If you no longer want the Service and cluster to run, you can delete them.
|
|
||||||
|
If you no longer want the Service and cluster to run, you can delete them.
|
||||||
|
|
||||||
7. Delete the `hello-minikube` Service:
|
7. Delete the `hello-minikube` Service:
|
||||||
```shell
|
|
||||||
kubectl delete services hello-minikube
|
```shell
|
||||||
```
|
kubectl delete services hello-minikube
|
||||||
The output is similar to this:
|
```
|
||||||
```
|
|
||||||
service "hello-minikube" deleted
|
The output is similar to this:
|
||||||
```
|
|
||||||
|
```
|
||||||
|
service "hello-minikube" deleted
|
||||||
|
```
|
||||||
|
|
||||||
8. Delete the `hello-minikube` Deployment:
|
8. Delete the `hello-minikube` Deployment:
|
||||||
```shell
|
|
||||||
kubectl delete deployment hello-minikube
|
```shell
|
||||||
```
|
kubectl delete deployment hello-minikube
|
||||||
The output is similar to this:
|
```
|
||||||
```
|
|
||||||
deployment.extensions "hello-minikube" deleted
|
The output is similar to this:
|
||||||
```
|
|
||||||
|
```
|
||||||
|
deployment.extensions "hello-minikube" deleted
|
||||||
|
```
|
||||||
|
|
||||||
9. Stop the local Minikube cluster:
|
9. Stop the local Minikube cluster:
|
||||||
```shell
|
|
||||||
minikube stop
|
```shell
|
||||||
```
|
minikube stop
|
||||||
The output is similar to this:
|
```
|
||||||
```
|
|
||||||
Stopping "minikube"...
|
The output is similar to this:
|
||||||
"minikube" stopped.
|
|
||||||
```
|
```
|
||||||
For more information, see [Stopping a Cluster](#stopping-a-cluster).
|
Stopping "minikube"...
|
||||||
|
"minikube" stopped.
|
||||||
|
```
|
||||||
|
|
||||||
|
For more information, see [Stopping a Cluster](#stopping-a-cluster).
|
||||||
|
|
||||||
10. Delete the local Minikube cluster:
|
10. Delete the local Minikube cluster:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
minikube delete
|
minikube delete
|
||||||
```
|
```
|
||||||
|
@ -193,8 +228,8 @@ For example the command would be.
|
||||||
minikube start --driver=<driver_name>
|
minikube start --driver=<driver_name>
|
||||||
```
|
```
|
||||||
Minikube supports the following drivers:
|
Minikube supports the following drivers:
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
See [DRIVERS](https://minikube.sigs.k8s.io/docs/reference/drivers/) for details on supported drivers and how to install
|
See [DRIVERS](https://minikube.sigs.k8s.io/docs/reference/drivers/) for details on supported drivers and how to install
|
||||||
plugins.
|
plugins.
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/
|
||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y kubectl
|
sudo apt-get install -y kubectl
|
||||||
{{< /tab >}}
|
{{< /tab >}}
|
||||||
|
|
||||||
{{< tab name="CentOS, RHEL or Fedora" codelang="bash" >}}cat <<EOF > /etc/yum.repos.d/kubernetes.repo
|
{{< tab name="CentOS, RHEL or Fedora" codelang="bash" >}}cat <<EOF > /etc/yum.repos.d/kubernetes.repo
|
||||||
[kubernetes]
|
[kubernetes]
|
||||||
name=Kubernetes
|
name=Kubernetes
|
||||||
|
@ -89,17 +90,23 @@ snap install kubectl --classic
|
||||||
|
|
||||||
kubectl version --client
|
kubectl version --client
|
||||||
```
|
```
|
||||||
|
|
||||||
{{% /tab %}}
|
{{% /tab %}}
|
||||||
|
|
||||||
{{% tab name="Homebrew" %}}
|
{{% tab name="Homebrew" %}}
|
||||||
If you are on Linux and using [Homebrew](https://docs.brew.sh/Homebrew-on-Linux) package manager, kubectl is available for [installation](https://docs.brew.sh/Homebrew-on-Linux#install).
|
If you are on Linux and using [Homebrew](https://docs.brew.sh/Homebrew-on-Linux) package manager, kubectl is available for [installation](https://docs.brew.sh/Homebrew-on-Linux#install).
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
brew install kubectl
|
brew install kubectl
|
||||||
|
|
||||||
kubectl version --client
|
kubectl version --client
|
||||||
```
|
```
|
||||||
|
|
||||||
{{% /tab %}}
|
{{% /tab %}}
|
||||||
|
|
||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
## Install kubectl on macOS
|
## Install kubectl on macOS
|
||||||
|
|
||||||
### Install kubectl binary with curl on macOS
|
### Install kubectl binary with curl on macOS
|
||||||
|
@ -129,6 +136,7 @@ kubectl version --client
|
||||||
```
|
```
|
||||||
sudo mv ./kubectl /usr/local/bin/kubectl
|
sudo mv ./kubectl /usr/local/bin/kubectl
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Test to ensure the version you installed is up-to-date:
|
4. Test to ensure the version you installed is up-to-date:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -144,6 +152,7 @@ If you are on macOS and using [Homebrew](https://brew.sh/) package manager, you
|
||||||
```
|
```
|
||||||
brew install kubectl
|
brew install kubectl
|
||||||
```
|
```
|
||||||
|
|
||||||
or
|
or
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -188,11 +197,13 @@ If you are on macOS and using [Macports](https://macports.org/) package manager,
|
||||||
To find out the latest stable version (for example, for scripting), take a look at [https://storage.googleapis.com/kubernetes-release/release/stable.txt](https://storage.googleapis.com/kubernetes-release/release/stable.txt).
|
To find out the latest stable version (for example, for scripting), take a look at [https://storage.googleapis.com/kubernetes-release/release/stable.txt](https://storage.googleapis.com/kubernetes-release/release/stable.txt).
|
||||||
|
|
||||||
2. Add the binary in to your PATH.
|
2. Add the binary in to your PATH.
|
||||||
|
|
||||||
3. Test to ensure the version of `kubectl` is the same as downloaded:
|
3. Test to ensure the version of `kubectl` is the same as downloaded:
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl version --client
|
kubectl version --client
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes) adds its own version of `kubectl` to PATH.
|
[Docker Desktop for Windows](https://docs.docker.com/docker-for-windows/#kubernetes) adds its own version of `kubectl` to PATH.
|
||||||
If you have installed Docker Desktop before, you may need to place your PATH entry before the one added by the Docker Desktop installer or remove the Docker Desktop's `kubectl`.
|
If you have installed Docker Desktop before, you may need to place your PATH entry before the one added by the Docker Desktop installer or remove the Docker Desktop's `kubectl`.
|
||||||
|
@ -209,9 +220,10 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle
|
||||||
install-kubectl.ps1 [-DownloadLocation <path>]
|
install-kubectl.ps1 [-DownloadLocation <path>]
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}If you do not specify a `DownloadLocation`, `kubectl` will be installed in the user's temp Directory.{{< /note >}}
|
{{< note >}}If you do not specify a `DownloadLocation`, `kubectl` will be installed in the user's temp Directory.
|
||||||
|
{{< /note >}}
|
||||||
|
|
||||||
The installer creates `$HOME/.kube` and instructs it to create a config file
|
The installer creates `$HOME/.kube` and instructs it to create a config file.
|
||||||
|
|
||||||
2. Test to ensure the version you installed is up-to-date:
|
2. Test to ensure the version you installed is up-to-date:
|
||||||
|
|
||||||
|
@ -219,11 +231,14 @@ If you are on Windows and using [Powershell Gallery](https://www.powershellgalle
|
||||||
kubectl version --client
|
kubectl version --client
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}Updating the installation is performed by rerunning the two commands listed in step 1.{{< /note >}}
|
{{< note >}}
|
||||||
|
Updating the installation is performed by rerunning the two commands listed in step 1.
|
||||||
|
{{< /note >}}
|
||||||
|
|
||||||
### Install on Windows using Chocolatey or Scoop
|
### Install on Windows using Chocolatey or Scoop
|
||||||
|
|
||||||
To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org) package manager or [Scoop](https://scoop.sh) command-line installer.
|
1. To install kubectl on Windows you can use either [Chocolatey](https://chocolatey.org) package manager or [Scoop](https://scoop.sh) command-line installer.
|
||||||
|
|
||||||
{{< tabs name="kubectl_win_install" >}}
|
{{< tabs name="kubectl_win_install" >}}
|
||||||
{{% tab name="choco" %}}
|
{{% tab name="choco" %}}
|
||||||
|
|
||||||
|
@ -236,6 +251,8 @@ To install kubectl on Windows you can use either [Chocolatey](https://chocolatey
|
||||||
|
|
||||||
{{% /tab %}}
|
{{% /tab %}}
|
||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
2. Test to ensure the version you installed is up-to-date:
|
2. Test to ensure the version you installed is up-to-date:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -265,13 +282,14 @@ To install kubectl on Windows you can use either [Chocolatey](https://chocolatey
|
||||||
New-Item config -type file
|
New-Item config -type file
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}Edit the config file with a text editor of your choice, such as Notepad.{{< /note >}}
|
{{< note >}}Edit the config file with a text editor of your choice, such as Notepad.{{< /note >}}
|
||||||
|
|
||||||
## Download as part of the Google Cloud SDK
|
## Download as part of the Google Cloud SDK
|
||||||
|
|
||||||
You can install kubectl as part of the Google Cloud SDK.
|
You can install kubectl as part of the Google Cloud SDK.
|
||||||
|
|
||||||
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).
|
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/).
|
||||||
|
|
||||||
2. Run the `kubectl` installation command:
|
2. Run the `kubectl` installation command:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -293,6 +311,7 @@ Check that kubectl is properly configured by getting the cluster state:
|
||||||
```shell
|
```shell
|
||||||
kubectl cluster-info
|
kubectl cluster-info
|
||||||
```
|
```
|
||||||
|
|
||||||
If you see a URL response, kubectl is correctly configured to access your cluster.
|
If you see a URL response, kubectl is correctly configured to access your cluster.
|
||||||
|
|
||||||
If you see a message similar to the following, kubectl is not configured correctly or is not able to connect to a Kubernetes cluster.
|
If you see a message similar to the following, kubectl is not configured correctly or is not able to connect to a Kubernetes cluster.
|
||||||
|
@ -350,18 +369,17 @@ You now need to ensure that the kubectl completion script gets sourced in all yo
|
||||||
```shell
|
```shell
|
||||||
echo 'source <(kubectl completion bash)' >>~/.bashrc
|
echo 'source <(kubectl completion bash)' >>~/.bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
- Add the completion script to the `/etc/bash_completion.d` directory:
|
- Add the completion script to the `/etc/bash_completion.d` directory:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl completion bash >/etc/bash_completion.d/kubectl
|
kubectl completion bash >/etc/bash_completion.d/kubectl
|
||||||
```
|
```
|
||||||
- If you have an alias for kubectl, you can extend shell completion to work with that alias:
|
If you have an alias for kubectl, you can extend shell completion to work with that alias:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
echo 'alias k=kubectl' >>~/.bashrc
|
echo 'alias k=kubectl' >>~/.bashrc
|
||||||
echo 'complete -F __start_kubectl k' >>~/.bashrc
|
echo 'complete -F __start_kubectl k' >>~/.bashrc
|
||||||
```
|
```
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
bash-completion sources all completion scripts in `/etc/bash_completion.d`.
|
bash-completion sources all completion scripts in `/etc/bash_completion.d`.
|
||||||
|
@ -382,7 +400,7 @@ The kubectl completion script for Bash can be generated with `kubectl completion
|
||||||
However, the kubectl completion script depends on [**bash-completion**](https://github.com/scop/bash-completion) which you thus have to previously install.
|
However, the kubectl completion script depends on [**bash-completion**](https://github.com/scop/bash-completion) which you thus have to previously install.
|
||||||
|
|
||||||
{{< warning>}}
|
{{< warning>}}
|
||||||
there are two versions of bash-completion, v1 and v2. V1 is for Bash 3.2 (which is the default on macOS), and v2 is for Bash 4.1+. The kubectl completion script **doesn't work** correctly with bash-completion v1 and Bash 3.2. It requires **bash-completion v2** and **Bash 4.1+**. Thus, to be able to correctly use kubectl completion on macOS, you have to install and use Bash 4.1+ ([*instructions*](https://itnext.io/upgrading-bash-on-macos-7138bd1066ba)). The following instructions assume that you use Bash 4.1+ (that is, any Bash version of 4.1 or newer).
|
There are two versions of bash-completion, v1 and v2. V1 is for Bash 3.2 (which is the default on macOS), and v2 is for Bash 4.1+. The kubectl completion script **doesn't work** correctly with bash-completion v1 and Bash 3.2. It requires **bash-completion v2** and **Bash 4.1+**. Thus, to be able to correctly use kubectl completion on macOS, you have to install and use Bash 4.1+ ([*instructions*](https://itnext.io/upgrading-bash-on-macos-7138bd1066ba)). The following instructions assume that you use Bash 4.1+ (that is, any Bash version of 4.1 or newer).
|
||||||
{{< /warning >}}
|
{{< /warning >}}
|
||||||
|
|
||||||
### Upgrade Bash
|
### Upgrade Bash
|
||||||
|
@ -454,9 +472,9 @@ You now have to ensure that the kubectl completion script gets sourced in all yo
|
||||||
|
|
||||||
- If you installed kubectl with Homebrew (as explained [above](#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything.
|
- If you installed kubectl with Homebrew (as explained [above](#install-with-homebrew-on-macos)), then the kubectl completion script should already be in `/usr/local/etc/bash_completion.d/kubectl`. In that case, you don't need to do anything.
|
||||||
|
|
||||||
{{< note >}}
|
{{< note >}}
|
||||||
the Homebrew installation of bash-completion v2 sources all the files in the `BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work.
|
The Homebrew installation of bash-completion v2 sources all the files in the `BASH_COMPLETION_COMPAT_DIR` directory, that's why the latter two methods work.
|
||||||
{{< /note >}}
|
{{< /note >}}
|
||||||
|
|
||||||
In any case, after reloading your shell, kubectl completion should be working.
|
In any case, after reloading your shell, kubectl completion should be working.
|
||||||
{{% /tab %}}
|
{{% /tab %}}
|
||||||
|
@ -489,6 +507,7 @@ compinit
|
||||||
{{% /tab %}}
|
{{% /tab %}}
|
||||||
{{< /tabs >}}
|
{{< /tabs >}}
|
||||||
|
|
||||||
|
|
||||||
{{% /capture %}}
|
{{% /capture %}}
|
||||||
|
|
||||||
{{% capture whatsnext %}}
|
{{% capture whatsnext %}}
|
||||||
|
|
|
@ -1,43 +1,43 @@
|
||||||
{{ .Page.Scratch.Add "tabset-counter" 1 }}
|
{{- .Page.Scratch.Add "tabset-counter" 1 -}}
|
||||||
{{ $tab_set_id := .Get "name" | default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize }}
|
{{- $tab_set_id := .Get "name" | default (printf "tabset-%s-%d" (.Page.RelPermalink) (.Page.Scratch.Get "tabset-counter") ) | anchorize -}}
|
||||||
{{ $tabs := .Scratch.Get "tabs" }}
|
{{- $tabs := .Scratch.Get "tabs" -}}
|
||||||
{{ if .Inner }}{{/* We don't use the inner content, but Hugo will complain if we don't reference it. */}}{{ end }}
|
{{- if .Inner -}}{{- /* We don't use the inner content, but Hugo will complain if we don't reference it. */ -}}{{- end -}}
|
||||||
<div id="{{ $tab_set_id }}">
|
<div id="{{ $tab_set_id }}">
|
||||||
<ul>
|
<ul>
|
||||||
{{ range $i, $e := $tabs }}
|
{{- range $i, $e := $tabs -}}
|
||||||
{{ $id := printf "%s-%d" $tab_set_id $i }}
|
{{- $id := printf "%s-%d" $tab_set_id $i -}}
|
||||||
<li><a href="#{{ $id }}">{{ trim .name " " }}</a></li>
|
<li><a href="#{{ $id }}">{{- trim .name " " -}}</a></li>
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
</ul>
|
</ul>
|
||||||
{{ range $i, $e := $tabs }}
|
{{- range $i, $e := $tabs -}}
|
||||||
{{ $id := printf "%s-%d" $tab_set_id $i }}
|
{{- $id := printf "%s-%d" $tab_set_id $i -}}
|
||||||
<div id="{{ $id }}">
|
<div id="{{ $id }}">
|
||||||
{{ with .content }}
|
{{- with .content -}}
|
||||||
{{ . }}
|
{{- . -}}
|
||||||
{{ else }}
|
{{- else -}}
|
||||||
{{ if eq $.Page.BundleType "leaf" }}
|
{{- if eq $.Page.BundleType "leaf" -}}
|
||||||
{{/* find the file somewhere inside the bundle. Note the use of double asterisk */}}
|
{{- /* find the file somewhere inside the bundle. Note the use of double asterisk */ -}}
|
||||||
{{ with $.Page.Resources.GetMatch (printf "**%s*" .include) }}
|
{{- with $.Page.Resources.GetMatch (printf "**%s*" .include) -}}
|
||||||
{{ if ne .ResourceType "page" }}
|
{{- if ne .ResourceType "page" -}}
|
||||||
{{/* Assume it is a file that needs code highlighting. */}}
|
{{- /* Assume it is a file that needs code highlighting. */ -}}
|
||||||
{{ $codelang := $e.codelang | default ( path.Ext .Name | strings.TrimPrefix ".") }}
|
{{- $codelang := $e.codelang | default ( path.Ext .Name | strings.TrimPrefix ".") -}}
|
||||||
{{ highlight .Content $codelang "" }}
|
{{- highlight .Content $codelang "" -}}
|
||||||
{{ else}}
|
{{- else -}}
|
||||||
{{ .Content }}
|
{{- .Content -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ else}}
|
{{- else -}}
|
||||||
{{ $path := path.Join $.Page.File.Dir .include }}
|
{{- $path := path.Join $.Page.File.Dir .include -}}
|
||||||
{{ $page := site.GetPage "page" $path }}
|
{{- $page := site.GetPage "page" $path -}}
|
||||||
{{ with $page }}
|
{{- with $page -}}
|
||||||
{{ .Content }}
|
{{- .Content -}}
|
||||||
{{ else }}
|
{{- else -}}
|
||||||
{{ errorf "[%s] tabs include not found for path %q" site.Language.Lang $path}}
|
{{- errorf "[%s] tabs include not found for path %q" site.Language.Lang $path -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
{{ end }}
|
{{- end -}}
|
||||||
</div>
|
</div>
|
||||||
{{ $elem := $tab_set_id | safeJS }}
|
{{- $elem := $tab_set_id | safeJS -}}
|
||||||
<script>$(function(){$("#{{ $elem }}").tabs();});</script>
|
<script>$(function(){$("#{{ $elem }}").tabs();});</script>
|
Loading…
Reference in New Issue