-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[embedding] feat: allow user configured navbar site #1535
Open
Evidlo
wants to merge
15
commits into
docsifyjs:develop
Choose a base branch
from
Evidlo:develop
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 10 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c12c68e
allow user configured navbar selection
Evidlo 2b0db83
Merge branch 'develop' into develop
sy-records bb46a88
Merge branch 'develop' into develop
sy-records 69def1c
Merge branch 'develop' into develop
sy-records a989914
Merge branch 'develop' into develop
Koooooo-7 f830976
Merge branch 'develop' into develop
sy-records fe30b70
add tests for nav_el option
Evidlo cf05a6f
fix tests to use innerHTML
Evidlo 74a0af0
Merge branch 'develop' into develop
Evidlo 8e5f080
Merge branch 'develop' into develop
trusktr d9871e1
Merge branch 'develop' into develop
Koooooo-7 738c39a
rename to camel case
Evidlo cdde500
dont merge nav when using custom nav element
Evidlo 288d05d
Merge branch 'develop' into develop
Evidlo 02daac4
use navEl when rendering
Evidlo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,6 +88,19 @@ window.$docsify = { | |
}; | ||
``` | ||
|
||
## nav_el | ||
|
||
- Type: `String` | ||
- Default: `null` | ||
|
||
The DOM element to use for rendering the navbar. It can be a CSS selector string or an actual [HTMLElement](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement). If `null`, the first `<nav>` element on the page is used. If it doesn't exist, it is created at the top of the DOM. | ||
|
||
```js | ||
window.$docsify = { | ||
nav_el: '#navbar, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The configuration option would be |
||
}; | ||
``` | ||
|
||
## loadSidebar | ||
|
||
- Type: `Boolean|String` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const docsifyInit = require('../helpers/docsify-init'); | ||
|
||
describe(`Navbar tests`, function() { | ||
test('specify custom navbar element in config with nav_el', async () => { | ||
const docsifyInitConfig = { | ||
html: ` | ||
<html> | ||
<body> | ||
<nav id="mynav"></nav> | ||
<div id="app"></nav> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are closing |
||
</body> | ||
</html> | ||
`, | ||
markdown: { | ||
navbar: ` | ||
- [Foo](foo) | ||
- [Bar](bar) | ||
`, | ||
homepage: ` | ||
# hello world | ||
foo | ||
`, | ||
}, | ||
config: { | ||
nav_el: '#mynav', | ||
}, | ||
}; | ||
|
||
await docsifyInit(docsifyInitConfig); | ||
|
||
// Check that our custom <nav> element contains nav links | ||
let navHTML; | ||
navHTML = await page.$eval('#mynav', el => el.innerHTML); | ||
expect(navHTML).toMatch('<li><a href="#/foo" title="Foo">Foo</a></li>'); | ||
navHTML = await page.$eval('#mynav', el => el.innerHTML); | ||
expect(navHTML).toMatch('<li><a href="#/bar" title="Bar">Bar</a></li>'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on the source, this option accepts a string only (not an HTMLElement). Either the description or the source needs to be updated to match.