From 33175796a94eca42fc71444476750ea1fb8e0309 Mon Sep 17 00:00:00 2001 From: liuboaibc Date: Fri, 4 Sep 2020 16:25:23 +0800 Subject: [PATCH] add docs search --- assets/scss/common.scss | 31 +++++++++++++++++++++++++++++++ assets/scss/doc.scss | 21 +++++++++++++++++++-- assets/scss/docs.scss | 9 +++++++++ assets/scss/footer.scss | 1 + config/_default/config.toml | 6 +++--- content/en/search/_index.md | 4 ---- content/zh/search/_index.md | 4 ---- i18n/zh.yaml | 28 +++++++++++++++++++++++++++- layouts/docs/list.html | 3 +++ layouts/docs/single.html | 5 ++++- layouts/partials/css.html | 1 + layouts/partials/head.html | 7 +++++++ layouts/partials/header.html | 20 -------------------- layouts/partials/searchInput.html | 28 ++++++++++++++++++++++++++++ layouts/partials/share.html | 3 +-- static/js/share.js | 19 ------------------- 16 files changed, 134 insertions(+), 56 deletions(-) delete mode 100644 content/en/search/_index.md delete mode 100644 content/zh/search/_index.md create mode 100644 layouts/partials/searchInput.html delete mode 100644 static/js/share.js diff --git a/assets/scss/common.scss b/assets/scss/common.scss index 2d9dceac5..53a5c7586 100644 --- a/assets/scss/common.scss +++ b/assets/scss/common.scss @@ -226,6 +226,37 @@ section { } } +.search-input-div { + position: relative; + height: 36px; + padding-left: 18px; + padding-right: 40px; + border-radius: 18px; + background-color: #ffffff; + + .algolia-autocomplete { + width: 100%; + height: 100%; + } + + input { + width: 100%; + height: 20px; + margin-top: 8px; + font-size: 14px; + line-height: 20px; + border: none; + outline: none; + color: #657480; + } + + svg { + position: absolute; + right: 18px; + top: 11px; + } +} + .notices { margin: 20px 0; position: relative; diff --git a/assets/scss/doc.scss b/assets/scss/doc.scss index 05f242e0c..447d56aa1 100644 --- a/assets/scss/doc.scss +++ b/assets/scss/doc.scss @@ -11,6 +11,10 @@ body { padding-bottom: 20px; background-image: url("/images/docs/banner.png"); + .common-layout { + position: relative; + } + .breadcrumbnav { li { display: inline; @@ -31,7 +35,7 @@ body { .title-div { height: 20px; - margin-top: 6px; + margin-top: 20px; h1 { display: inline-block; vertical-align: middle; @@ -57,6 +61,19 @@ body { } } } + + .search-div { + position: absolute; + bottom: 0px; + right: 0px; + width: 560px; + margin-top: 20px; + + @media only screen and (max-width: $mobile-max-width) { + position: relative; + width: 100%; + } + } } .section-menu { @@ -605,7 +622,7 @@ body { .aside-fixed { position: fixed; - top: 250px; + top: 260px; left: 50%; transform: translateX(500px); } diff --git a/assets/scss/docs.scss b/assets/scss/docs.scss index d43603eeb..15a391cb6 100644 --- a/assets/scss/docs.scss +++ b/assets/scss/docs.scss @@ -31,6 +31,15 @@ width: 100%; } } + + .search-div { + width: 560px; + margin-top: 20px; + + @media only screen and (max-width: $mobile-max-width) { + width: 100%; + } + } } } diff --git a/assets/scss/footer.scss b/assets/scss/footer.scss index 8c0cd5353..429e39b0e 100644 --- a/assets/scss/footer.scss +++ b/assets/scss/footer.scss @@ -48,6 +48,7 @@ margin-left: 16px; color: #ccd3db; border: none; + outline: none; background-color: #f5f8f9; } diff --git a/config/_default/config.toml b/config/_default/config.toml index 0c70fb458..5cf8fd157 100644 --- a/config/_default/config.toml +++ b/config/_default/config.toml @@ -96,12 +96,12 @@ hasChildren = true [[languages.en.menu.main]] weight = 4 name = "Documentation" -URL = "https://kubesphere.io/docs/" +hasChildren = true [[languages.en.menu.main]] parent = "Documentation" name = "v3.0.0" - URL = "https://kubesphere.io/docs" + URL = "docs/" weight = 1 [[languages.en.menu.main]] @@ -227,7 +227,7 @@ name = "文档中心" [[languages.zh.menu.main]] parent = "文档中心" name = "v3.0.0" - URL = "https://kubesphere.com.cn/docs" + URL = "docs/" weight = 1 [[languages.zh.menu.main]] diff --git a/content/en/search/_index.md b/content/en/search/_index.md deleted file mode 100644 index 6e2878d22..000000000 --- a/content/en/search/_index.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: search - ---- \ No newline at end of file diff --git a/content/zh/search/_index.md b/content/zh/search/_index.md deleted file mode 100644 index 6e2878d22..000000000 --- a/content/zh/search/_index.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: search - ---- \ No newline at end of file diff --git a/i18n/zh.yaml b/i18n/zh.yaml index effb94cb1..c95eb2e24 100644 --- a/i18n/zh.yaml +++ b/i18n/zh.yaml @@ -51,4 +51,30 @@ - id: background image translation: 背景图片 - id: kubesphere console screenshot - translation: kubesphere console 截图 \ No newline at end of file + translation: kubesphere console 截图 +- id: Learn More + translation: 查看更过 +- id: Download this page (PDF) + translation: 下载该页 (PDF) +- id: Last updated + translation: 最新更新 +- id: What’s on this Page + translation: 页面内容 +- id: Last + translation: 上一篇 +- id: Next + translation: 下一篇 +- id: edit + translation: 编辑 +- id: feedback + translation: 反馈 +- id: share + translation: 分享 +- id: note + translation: 注解 +- id: tip + translation: 提示 +- id: info + translation: 信息 +- id: warning + translation: 警告 \ No newline at end of file diff --git a/layouts/docs/list.html b/layouts/docs/list.html index 1a91f0927..11c75f434 100644 --- a/layouts/docs/list.html +++ b/layouts/docs/list.html @@ -5,6 +5,9 @@

{{ .title }}

{{ .content }}

+
+ {{ partial "searchInput" . }} +
{{ end }} diff --git a/layouts/docs/single.html b/layouts/docs/single.html index 6021d44d8..1ce008e72 100644 --- a/layouts/docs/single.html +++ b/layouts/docs/single.html @@ -20,6 +20,10 @@
+ +
+ {{ partial "searchInput" . }} +
@@ -141,7 +145,6 @@ {{ if .IsPage }} {{ end }} - + +{{ if .IsDescendant (.GetPage "/docs") }} + +{{ end }} + diff --git a/layouts/partials/header.html b/layouts/partials/header.html index 944607948..2fd04624f 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -199,26 +199,6 @@ var bindClickClose = function() { var language = '{{.Site.Language.Lang}}' -var bindClickDocs = function() { - var host = window.location.origin - $('a').click(function(e) { - var name = $(this).data('docs') - if (name === 'Documentation') { - e.preventDefault() - if (host === 'https://kubesphere.com.cn/' || host === 'https://kubesphere.io/') { - if (language === 'zh') { - window.open('https://kubesphere.com.cn/docs/zh-CN/') - } else { - window.open('https://kubesphere.io/docs/') - } - } else { - window.open('/docs/') - } - } - }) -} -bindClickDocs() - bindClickClose() bindScrollChangeHeader() diff --git a/layouts/partials/searchInput.html b/layouts/partials/searchInput.html new file mode 100644 index 000000000..3e1cf4283 --- /dev/null +++ b/layouts/partials/searchInput.html @@ -0,0 +1,28 @@ +
+ + + + + + + +
+ \ No newline at end of file diff --git a/layouts/partials/share.html b/layouts/partials/share.html index 3e9fd5b23..08ff0bd33 100644 --- a/layouts/partials/share.html +++ b/layouts/partials/share.html @@ -14,5 +14,4 @@ hackernews icon - - \ No newline at end of file + \ No newline at end of file diff --git a/static/js/share.js b/static/js/share.js deleted file mode 100644 index 9f5fc6b83..000000000 --- a/static/js/share.js +++ /dev/null @@ -1,19 +0,0 @@ -var title = document.title -var bindClickShare = function() { - var url = window.location.href - var urlObj = { - twitter: 'http://twitter.com/share?url=' + url + '&text=' + title, - reddit: 'http://reddit.com/submit?url=' + url + '&title=' + title, - facebook: 'http://www.facebook.com/sharer.php?u=' + url, - linkedin: 'http://www.linkedin.com/shareArticle?mini=true&url=' + url, - hackernews: 'https://news.ycombinator.com/submitlink?u=' + url + '&t=' + title, - } - $('a').click(function(e) { - var type = $(this).data('type') - if (type) { - e.preventDefault() - window.open(urlObj[type]) - } - }) -} -bindClickShare() \ No newline at end of file