create pdf

Signed-off-by: liuboaibc <kukudehero@gmail.com>
This commit is contained in:
liuboaibc 2021-01-13 16:15:33 +08:00
parent ac6c4d3a05
commit c6e8b117ac
7 changed files with 669 additions and 2 deletions

View File

@ -145,3 +145,16 @@ Total in 2396 ms
#### Get the already built static content
You will find the previously generated content in the `public` directory.
## Create Docs PDF
```
hugo
```
```
cat ./public/all-docs/index.html | wkhtmltopdf --outline-depth 2 --enable-internal-links - ./static/pdf/all-docs.pdf
cat ./public/zh/all-docs/index.html | wkhtmltopdf --outline-depth 2 --enable-internal-links - ./static/pdf/all-docs-zh.pdf
```

View File

@ -1,4 +1,4 @@
baseURL = "https://kubesphere-v3.netlify.app"
baseURL = "https://kubesphere.io"
enableRobotsTXT = true

View File

View File

View File

@ -0,0 +1,7 @@
<p>
{{ if strings.HasPrefix .Destination "http" }}
<img src="{{ .Destination | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
{{ else }}
<img src="{{ .Destination | absURL | safeURL }}" alt="{{ .Text }}" {{ with .Title}} title="{{ . }}"{{ end }} />
{{ end }}
</p>

View File

@ -1 +1,11 @@
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if strings.HasPrefix .Destination "http" }} target="_blank" rel="noopener noreferrer"{{ end }}>{{ .Text }}</a>
{{ if strings.HasPrefix .Destination "http" }}
<a href="{{ .Destination | safeURL }}"{{ with .Title}} title="{{ . }}"{{ end }} target="_blank" rel="noopener noreferrer">{{ .Text }}</a>
{{ else }}
{{ $page := .Page.GetPage .Destination }}
{{ if $page }}
<a href="#{{ $page.UniqueID }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text }}</a>
{{ else}}
{{ $page := .Page.GetPage (substr .Destination 3 -1) }}
<a href="#{{ $page.UniqueID }}"{{ with .Title}} title="{{ . }}"{{ end }}>{{ .Text }}</a>
{{ end }}
{{ end }}

637
layouts/all-docs/list.html Normal file
View File

@ -0,0 +1,637 @@
<!DOCTYPE html>
<html lang="{{ with .Site.LanguageCode }}{{ . }}{{ else }}en-US{{ end }}">
<head>
<meta charset="utf-8">
<title>Kubesphere Doc</title>
<style>
html {
font-size: 24px;
}
li {
margin-top: 20px;
}
.md-body {
line-height: 2;
word-wrap: break-word;
color: #485b7f;
}
.md-body::before {
display: table;
content: '';
}
.md-body::after {
display: table;
clear: both;
content: '';
}
.md-body > *:first-child {
margin-top: 0 !important;
}
.md-body > *:last-child {
margin-bottom: 0 !important;
}
.md-body a {
color: #55bc8a;
text-decoration: none;
}
.md-body .absent {
color: #cb2431;
}
.md-body .anchor {
float: left;
padding-right: 4px;
margin-left: -20px;
line-height: 1;
}
.md-body .anchor:focus {
outline: none;
}
.md-body p,
.md-body blockquote,
.md-body ul,
.md-body ol,
.md-body dl,
.md-body table,
.md-body pre {
margin: 0 0 12px;
}
.md-body hr {
height: 0.25em;
padding: 0;
margin: 24px 0;
background-color: #e1e4e8;
border: 0;
}
.md-body blockquote {
padding: 0 1em;
border-left: 4px solid #cfd9df;
line-height: 1.71;
color: #8f94a1;
}
.md-body blockquote > p {
line-height: 1.71;
color: #8f94a1;
}
.md-body blockquote > :first-child {
margin-top: 0;
}
.md-body blockquote > :last-child {
margin-bottom: 0;
}
.md-body kbd {
display: inline-block;
padding: 3px 5px;
line-height: 10px;
color: #444d56;
vertical-align: middle;
background-color: #fafbfc;
border: solid 1px #c6cbd1;
border-bottom-color: #959da5;
border-radius: 3px;
box-shadow: inset 0 -1px 0 #959da5;
}
.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4,
.md-body h5,
.md-body h6 {
margin-top: 20px;
margin-bottom: 5px;
font-weight: 600;
line-height: 1.5;
color: #171c34;
}
.md-body h1 .octicon-link,
.md-body h2 .octicon-link,
.md-body h3 .octicon-link,
.md-body h4 .octicon-link,
.md-body h5 .octicon-link,
.md-body h6 .octicon-link {
color: #1b1f23;
vertical-align: middle;
visibility: hidden;
}
.md-body h1:hover .anchor,
.md-body h2:hover .anchor,
.md-body h3:hover .anchor,
.md-body h4:hover .anchor,
.md-body h5:hover .anchor,
.md-body h6:hover .anchor {
text-decoration: none;
}
.md-body h1:hover .anchor .octicon-link,
.md-body h2:hover .anchor .octicon-link,
.md-body h3:hover .anchor .octicon-link,
.md-body h4:hover .anchor .octicon-link,
.md-body h5:hover .anchor .octicon-link,
.md-body h6:hover .anchor .octicon-link {
visibility: visible;
}
.md-body h1 tt,
.md-body h1 code,
.md-body h2 tt,
.md-body h2 code,
.md-body h3 tt,
.md-body h3 code,
.md-body h4 tt,
.md-body h4 code,
.md-body h5 tt,
.md-body h5 code,
.md-body h6 tt,
.md-body h6 code {
font-size: inherit;
}
.md-body h1 {
padding-bottom: 0.3em;
border-bottom: 1px solid #eaecef;
}
.md-body h2 {
font-weight: normal;
line-height: 1.63;
color: #171c34;
text-shadow: 0 4px 8px rgba(35, 45, 65, 0.1);
}
.md-body ul,
.md-body ol {
padding-left: 2em;
}
.md-body ul > li {
list-style: disc;
}
.md-body ol > li {
list-style: decimal;
}
.md-body ul.no-list,
.md-body ol.no-list {
padding: 0;
list-style-type: none;
}
.md-body ul ul,
.md-body ul ol,
.md-body ol ol,
.md-body ol ul {
margin-top: 0;
margin-bottom: 0;
}
.md-body li {
word-wrap: break-word;
}
.md-body li > p {
margin-top: 16px;
}
.md-body li + li {
margin-top: 0.25em;
}
.md-body dl {
padding: 0;
}
.md-body dl dt {
padding: 0;
margin-top: 16px;
font-size: 1em;
font-style: italic;
font-weight: 600;
}
.md-body dl dd {
padding: 0 16px;
margin-bottom: 16px;
}
.md-body table {
display: table;
width: 100%;
overflow: auto;
border-collapse: collapse;
}
.md-body table a {
word-break: break-word;
}
.md-body table th {
font-weight: 600;
border-radius: 3px;
background-color: #ecf0f2;
border: solid 1px #cfd9df;
text-align: left;
}
.md-body table th,
.md-body table td {
padding: 6px 13px;
border: 1px solid #dfe2e5;
}
.md-body table tr {
background-color: #fff;
border-top: 1px solid #c6cbd1;
}
.md-body table tr:nth-child(2n) {
background-color: #f6f8fa;
}
.md-body table img {
background-color: transparent;
}
.md-body img {
max-width: 100%;
box-sizing: content-box;
background-color: #fff;
border-radius: 5px;
box-shadow: 0 4px 15px 0 rgba(7, 42, 68, 0.1);
}
.md-body img[align='right'] {
padding-left: 20px;
}
.md-body img[align='left'] {
padding-right: 20px;
}
.md-body .emoji {
max-width: none;
vertical-align: text-top;
background-color: transparent;
}
.md-body span.frame {
display: block;
overflow: hidden;
}
.md-body span.frame > span {
display: block;
float: left;
width: auto;
padding: 7px;
margin: 13px 0 0;
overflow: hidden;
border: 1px solid #dfe2e5;
}
.md-body span.frame span img {
display: block;
float: left;
}
.md-body span.frame span span {
display: block;
padding: 5px 0 0;
clear: both;
color: #24292e;
}
.md-body span.align-center {
display: block;
overflow: hidden;
clear: both;
}
.md-body span.align-center > span {
display: block;
margin: 13px auto 0;
overflow: hidden;
text-align: center;
}
.md-body span.align-center span img {
margin: 0 auto;
text-align: center;
}
.md-body span.align-right {
display: block;
overflow: hidden;
clear: both;
}
.md-body span.align-right > span {
display: block;
margin: 13px 0 0;
overflow: hidden;
text-align: right;
}
.md-body span.align-right span img {
margin: 0;
text-align: right;
}
.md-body span.float-left {
display: block;
float: left;
margin-right: 13px;
overflow: hidden;
}
.md-body span.float-left span {
margin: 13px 0 0;
}
.md-body span.float-right {
display: block;
float: right;
margin-left: 13px;
overflow: hidden;
}
.md-body span.float-right > span {
display: block;
margin: 13px auto 0;
overflow: hidden;
text-align: right;
}
.md-body code,
.md-body tt {
padding: 0.2em 0.4em;
margin: 0;
font-size: 85%;
background-color: rgba(27, 31, 35, 0.05);
border-radius: 3px;
}
.md-body code br,
.md-body tt br {
display: none;
}
.md-body del code {
text-decoration: inherit;
}
.md-body pre {
position: relative;
word-wrap: normal;
}
.md-body pre code {
display: inline-block;
white-space: pre;
padding: 1em;
font-family: Monaco;
line-height: 1.71;
color: #ffffff;
}
.md-body .highlight {
margin-bottom: 16px;
}
.md-body .highlight pre {
margin-bottom: 0;
word-break: normal;
}
.md-body .highlight pre,
.md-body pre {
margin-bottom: 20px;
overflow: auto;
font-size: 85%;
line-height: 1.45;
border-radius: 5px;
background-color: #242e42;
border: solid 1px #242e42;
}
.md-body .csv-data td,
.md-body .csv-data th {
padding: 5px;
overflow: hidden;
line-height: 1;
text-align: left;
white-space: nowrap;
}
.md-body .csv-data .blob-num {
padding: 10px 8px 9px;
text-align: right;
background: #fff;
border: 0;
}
.md-body .csv-data tr {
border-top: 0;
}
.md-body .csv-data th {
font-weight: 600;
background: #f6f8fa;
border-top: 0;
}
.md-body img {
max-width: 100%;
margin: 0 auto;
box-sizing: content-box;
background-color: #fff;
border-radius: 5px;
box-shadow: none;
}
.md-body blockquote {
padding: 4px 20px 4px 12px;
border-radius: 4px;
background-color: #ecf0f2;
}
.popular-page-div {
display: none;
}
a {
color: #00a971;
text-decoration: none;
}
a:hover {
color: #008a5c;
}
.notices {
margin: 20px 0;
position: relative;
}
.notices > p {
padding: 0 10px;
margin: 0!important;
height: 30px;
line-height: 30px;
color: #ffffff;
}
.notices > div {
padding: 10px;
}
.notices.note > p {
background: #6ab0de
}
.notices.note > div {
background: #e7f2fa;
}
.notices.tip > p {
background: #78C578
}
.notices.tip > div {
background: #E6F9E6;
}
.notices.info > p {
background: #F0B37E
}
.notices.info > div {
background: #FFF2DB;
}
.notices.warning > p {
background: #E06F6C
}
.notices.warning > div {
background: #FAE2E2;
}
.popular-page-div {
position: relative;
display: inline-block;
box-sizing: border-box;
width: 373px;
padding: 20px;
margin-top: 17px;
margin-left: 5px;
border-radius: 3px;
background-color: #f6f8fa;
}
.popular-page-div img {
position: absolute;
top: 50%;
left: 20px;
transform: translateY(-50%);
width: 40px;
height: 40px;
padding: 12px;
border-radius: 7px;
box-shadow: 0 4px 8px 0 rgba(36, 46, 66, 0.06), 0 8px 16px 0 rgba(36, 46, 66, 0.05);
background-color: #ffffff;
}
.popular-page-div div {
margin-left: 84px;
}
.popular-page-div h2 {
height: 24px;
font-size: 16px;
margin: 0;
text-align: left;
line-height: 1.5;
overflow: hidden;
}
.popular-page-div p {
max-height: 42px;
margin-top: 8px;
margin-bottom: 0;
font-size: 14px;
line-height: 1.5;
color: #31383e;
overflow: hidden;
}
</style>
</head>
<body>
<h1>Content</h1>
{{ define "table" }}
<li><a href="#{{ .File.UniqueID }}">{{ .LinkTitle }}</a></li>
{{ if .IsSection }}
<ul>
{{ range (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }}
{{ template "table" . }}
{{ end }}
</ul>
{{ end }}
{{ end }}
<ul>
{{ with .Site.GetPage "section" "docs" }}
{{ range (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }}
{{ template "table" . }}
{{ end }}
{{ end }}
</ul>
<div style="page-break-after:always;"></div>
<div style="page-break-before:always;"></div>
{{ define "content" }}
<h1 id="{{ .File.UniqueID }}">{{ .LinkTitle }}</h1>
<div class="md-body">
{{ .Content }}
</div>
<div style="page-break-after:always;"></div>
<div style="page-break-before:always;"></div>
{{ if .IsSection }}
{{ range (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }}
{{ template "content" . }}
{{ end }}
{{ end }}
{{ end }}
{{ with .Site.GetPage "section" "docs" }}
{{ range (union (where .Pages ".Params._build.render" "!=" false) .Sections).ByWeight }}
{{ template "content" . }}
{{ end }}
{{ end }}
</body>
</html>