You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hop.apache.org by ha...@apache.org on 2020/12/19 12:30:32 UTC
[incubator-hop-website] branch master updated: HOP-2319 top bar
menu disappears when using any item in documentation menu
This is an automated email from the ASF dual-hosted git repository.
hansva pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-hop-website.git
The following commit(s) were added to refs/heads/master by this push:
new 1717469 HOP-2319 top bar menu disappears when using any item in documentation menu
new 70944d0 Merge pull request #13 from bamaer/master
1717469 is described below
commit 1717469eebe4f98af14e5f7f26124bc9725aa034
Author: Bart Maertens <ba...@know.bi>
AuthorDate: Sat Dec 19 10:25:32 2020 +0100
HOP-2319 top bar menu disappears when using any item in documentation menu
---
antora-ui-hop/src/helpers/withMenuData.js | 49 +++++++++++++++++++++++++++
antora-ui-hop/src/partials/header-content.hbs | 6 +---
2 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/antora-ui-hop/src/helpers/withMenuData.js b/antora-ui-hop/src/helpers/withMenuData.js
new file mode 100644
index 0000000..a0381d6
--- /dev/null
+++ b/antora-ui-hop/src/helpers/withMenuData.js
@@ -0,0 +1,49 @@
+'use strict'
+
+const fs = require('fs')
+const path = require('path')
+const toml = require('toml')
+const matches = /http\S+/
+
+let configPath = path.join(process.cwd(), 'config.toml')
+try {
+ fs.accessSync(configPath)
+} catch (err) {
+ configPath = path.resolve(process.cwd(), '../config.toml')
+ fs.accessSync(configPath)
+}
+
+const data = fs.readFileSync(configPath, 'utf8')
+const hugoConfig = toml.parse(data)
+const mainMenu = hugoConfig.menu.main
+
+const createMenu = (item) => {
+ return {
+ url: item.url || '#',
+ name: item.name,
+ pre: item.pre,
+ children: mainMenu.filter((child) => child.parent === item.identifier).map(createMenu),
+ }
+}
+
+const menuData = mainMenu.filter((item) => typeof item.parent === 'undefined').map(createMenu)
+
+module.exports = (options) => {
+ const siteRootPath = options.data.root.siteRootPath
+ const mappedMenuData = menuData.map((item) => mapItem(item, siteRootPath))
+ return options.fn(this, {
+ data: {
+ items: mappedMenuData,
+ },
+ })
+}
+
+const mapItem = (item, siteRootPath) => {
+ const url = item.url === '#' ? '#' : matches.test(item.url) ? item.url : siteRootPath + item.url
+ return {
+ url,
+ name: item.name,
+ pre: item.pre,
+ children: item.children.map((child) => mapItem(child, siteRootPath)),
+ }
+}
diff --git a/antora-ui-hop/src/partials/header-content.hbs b/antora-ui-hop/src/partials/header-content.hbs
index fcd2149..9d72ea9 100644
--- a/antora-ui-hop/src/partials/header-content.hbs
+++ b/antora-ui-hop/src/partials/header-content.hbs
@@ -15,11 +15,7 @@
{{#if children}}
<div class="navbar-dropdown">
{{#each children}}
- {{#hasPrefix url }}
<a class="navbar-item" href="{{url}}">{{name}}</a>
- {{else}}
- <a class="navbar-item" href="{{../../../siteRootPath}}{{url}}">{{name}}</a>
- {{/hasPrefix}}
{{/each}}
</div>
{{/if}}
@@ -37,7 +33,7 @@
<a href="https://chat.project-hop.org" title="Chat with us" target="_blank"><svg height="30" width="30" viewBox="0 0 30 30" class="brand-icon"><path d="m 23.399705,7.0517653 c -0.811583,-1.755522 -1.98643,-3.2324028 -3.542396,-4.4727237 0.04144,0.8420009 0.131904,2.6427217 0.131904,2.6427217 0,0 0.09696,0.1272 0.13632,0.182401 1.572478,2.199681 2.147037,4.6376017 1.623358,7.2857637 -1.050239,5.309843 -6.218105,8.549046 -11.455186,7.224805 C 5.6960779,18.752172 2.6254257,14.043529 [...]
<a href="https://twitter.com/projhop" title="Follow us on Twitter" target="_blank"><svg height="30" width="30" viewBox="0 0 30 30" class="brand-icon"><path d="M12 2c5.514 0 10 4.486 10 10s-4.486 10-10 10-10-4.486-10-10 4.486-10 10-10zm0-2c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6.5 8.778c-.441.196-.916.328-1.414.388.509-.305.898-.787 1.083-1.362-.476.282-1.003.487-1.564.597-.448-.479-1.089-.778-1.796-.778-1.59 0-2.758 1.483-2.399 3.023-2.045-.103-3.8 [...]
<a href="https://www.linkedin.com/company/hop-project/" title="Follow us on LinkedIn" target="_blank"><svg height="30" width="30" viewBox="0 0 30 30" class="brand-icon"><path d="M19 0h-14c-2.761 0-5 2.239-5 5v14c0 2.761 2.239 5 5 5h14c2.762 0 5-2.239 5-5v-14c0-2.761-2.238-5-5-5zm-11 19h-3v-11h3v11zm-1.5-12.268c-.966 0-1.75-.79-1.75-1.764s.784-1.764 1.75-1.764 1.75.79 1.75 1.764-.783 1.764-1.75 1.764zm13.5 12.268h-3v-5.604c0-3.368-4-3.113-4 0v5.604h-3v-11h3v1.765c1.396-2.586 7-2.7 [...]
- <a href="https://www.youtube.com/channel/UCGlcYslwe03Y2zbZ1W6DAGA" title="Subscribe to our YouTube channel" target="_blank"><svg height="30" width="30" viewBox="0 0 30 30" class="brand-icon"><path fill-rule="evenodd" d="M4.652 0h1.44l.988 3.702.916-3.702h1.454l-1.665 5.505v3.757h-1.431v-3.757l-1.702-5.505zm6.594 2.373c-1.119 0-1.861.74-1.861 1.835v3.349c0 1.204.629 1.831 1.861 1.831 1.022 0 1.826-.683 1.826-1.831v-3.349c0-1.069-.797-1.835-1.826-1.835zm.531 5.127c0 .372-.19.646-.5 [...]
+ <a href="https://www.youtube.com/channel/UCGlcYslwe03Y2zbZ1W6DAGA" title="Subscribe to our YouTube channel" target="_blank"><svg height="30" width="30" viewBox="0 0 30 30" class="brand-icon"><path fill-rule="evenodd" d="M4.652 0h1.44l.988 3.702.916-3.702h1.454l-1.665 5.505v3.757h-1.431v-3.757l-1.702-5.505zm6.594 2.373c-1.119 0-1.861.74-1.861 1.835v3.349c0 1.204.629 1.831 1.861 1.831 1.022 0 1.826-.683 1.826-1.831v-3.349c0-1.069-.797-1.835-1.826-1.835zm.531 5.127c0 .372-.19.646-.5 [...]
<a href="https://github.com/project-hop/" title="Collaborate on GitHub"><svg class="brand-icon" viewBox="0 0 22 22"><path fill-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32 [...]
</div>
<button class="navbar-burger" data-target="topbar-nav" type="button">