-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
React for rendering website with plugins #1543
Merged
Conversation
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
Add shapes for these states
Fix injection of DOM properties not working on the browser
A feature idea: it is often that a larger table looks good on a bigger monitor, but when looking at it on a smaller screen (like a laptop screen), it's hard to notice that some parts of the table are not shown at all. My idea is to make it to resize dynamically with the screen size/zoom/font size, so the table fits always on the screen (even if it's not pretty). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Hello ✨
This PR is a reimplementation of the client side of GitBook. See the Goals section for details about the ambition of this PR.
This PR is still early and a 👷 WIP. The goal is to gain feedback from plugin developers about the proposed API and from users about the expected website features.
Problem
The mission of the GitBook toolchain is to provide an extensible/pluggable static generator with theming, suited for documentation.
Since version 3.0.0, GitBook "Node.js side" is already getting more stable and faster over time.
But GitBook frontend is still backed by jQuery and is hard to extend (theming, functionalities). Interactive functionalities are hard to implement (ex:
theme-api
,code-tabs
,comment
, etc), and even harder to make compatible with different themes (ex: plugincomment
only works on the default theme an API theme).Goals
Some idea of plugins that can easily be implemented:
Inspirations
Proposal
From the user point of view, this PR will change nothing, expect that the website output by GitBook will gain more interactive features.
From the plugin developer point of view, this PR will change the whole API to extend the website. Plugin will define:
main
in thepackage.json
), it will define generation hooks and blocksbrowser
in thepackage.json
), it will define how the plugin extend the websiteTechnologies
react-helmet
react-redux
Workflow for generating a page
gitbook-core
creates a redux store with the JSONgitbook-core
render the injected componentBody
react-helmet
head dataAPI of
gitbook-core
gitbook-core
will be the core node.js / browser API, exposing:Components injection
Extensibility is based on the concept taken from Nylas N1 (Building Plugins for React Apps).
A plugin can register a component for a certain role. For example this plugin will register a panel to render in the sidebar:
Plugins and themes can also render components that matched a certain criteria:
Connect to the store
gitbook-core
is backed by Redux and store the state of the page (same as the JSON output).Components can connect themselves to the store (backed by
react-redux
):Extend the store
The store contains the state of current page (
page
,summary
,readme
, etc).But plugins can extend the store:
Template blocks and interactivity
In GitBook
<= 3.x.x
, blocks were node.js code returning HTML code to replace Liquid tags:With this new implementation, blocks are defined in the node.js entry point of the plugin to map props from block's arguments:
Then the plugin code can register a component to render this block:
Themes
GitBook with
gitbook-core
will render as an entry point the component matching the rolebody
usingInjectedComponent
.Similar to GitBook 3.x.x, themes will be plugins extending the default one or replacing the role
body
. Themes are really the one in control of calling/rendering most of the roles. For example, the default theme would define standard roles such assidebar:x
,toolbar:left
, etc.How to test it
Clone the repository, then run: