Comments (5)
Sorry, I realize now my initial message was not very clear.
I was, indeed, able to deploy Docz to Github Pages by using the base
property (site here). However, if you go to a specific component's page, refreshing the page will result in HTTP 404.
Which brings me to the reason I opened this issue: I think it's important that Docz pages be hostable on Github Pages. create-react-app
has this to say about routing and Github Pages:
You could switch from using HTML5 history API to routing with hashes. [...]
Alternatively, you can use a trick to teach GitHub Pages to handle 404 by redirecting to your index.html page with a special redirect parameter. [...]
To me, the first option is the more reasonable one: switch from BrowserRouter to HashRouter.
Of course, static individual pages would be ideal, but I realize it's much more work involved.
from docz.
Sure, now I got the message! Of course, I think that can be a good solution change the router type, but I think that is better use some property on configuration for that, like:
//doczrc.js
export default {
hashRouter: true
}
Because is kinda dangerous pass a Router
component to components!
from docz.
@danburzo you can deploy the site on github pages by changing the base
property on project configuration: https://www.docz.site/documentation/project-configuration#basic-config
Did you try this?
from docz.
Okay, for the hash routing solution, I guess a possible fix is to allow using either BrowserRouter or HashRouter here:
https://github.com/pedronauck/docz/blob/9284692fdc12f8be5d2bcccf3fcb141b142660d2/packages/docz/src/theme.tsx#L80
This may work well by exposing it as an option for themes?, e.g.:
diff --git a/packages/docz/src/theme.tsx b/packages/docz/src/theme.tsx
index c94a1da..c3d42b2 100644
--- a/packages/docz/src/theme.tsx
+++ b/packages/docz/src/theme.tsx
@@ -56,9 +56,11 @@ const initialContext: DataContext = {
export const dataContext = React.createContext(initialContext)
const DefaultWrapper: SFC = ({ children }) => <Fragment>{children}</Fragment>
+const DefaultRouter: CT = BrowserRouter;
export interface ThemeProps extends DataContext {
- wrapper?: CT
+ wrapper?: CT,
+ router?: CT,
children(WrappedComponent: CT): JSX.Element
}
@@ -68,6 +70,7 @@ export function theme(defaultConfig?: ThemeConfig): ThemeReturn {
return WrappedComponent => {
const Theme: CT<ThemeProps> = ({
wrapper: Wrapper = DefaultWrapper,
+ router: Router = DefaultRouter,
entries,
imports,
config = {},
@@ -77,11 +80,11 @@ export function theme(defaultConfig?: ThemeConfig): ThemeReturn {
return (
<dataContext.Provider value={value}>
- <BrowserRouter basename={BASE_URL}>
+ <Router basename={BASE_URL}>
<Wrapper>
<WrappedComponent />
</Wrapper>
- </BrowserRouter>
+ </Router>
</dataContext.Provider>
)
}
from docz.
Sounds good! I'd make a PR, but I haven't used TypeScript before and I'm a bit out of my league here as to how things work :)
from docz.
Related Issues (20)
- node_modules\.bin\gatsby HOT 3
- gh repo clone github/docs HOT 1
- Port not used from custom gatsby-config.js file
- Can't resolve '@emotion/core' HOT 9
- Error on first install. nError handler for invocation 'building-schema', error was 'TypeError: (0 , _buildASTSchema.getDescription) HOT 2
- Test out possibly breaking changes on security updates made from dependabot pull-requests HOT 3
- pnpm bare installs broken HOT 2
- What font is used in Docz image? HOT 3
- Error in setting up development environment HOT 4
- Release notes for 2.4.0 are missing HOT 1
- Multiple errors after installing docz HOT 11
- Error while initializing babel in docz HOT 3
- Can't resolve '@babel/runtime/helpers/esm/regeneratorRuntime'
- Error: Cannot find module 'typescript' docz HOT 2
- Add a visible notice on the documentation on why docz will not work
- Can we say that the project is Dead now? What are the alternatives? HOT 1
- how to use in react 18 HOT 4
- Error docz build
- When I try to run the project in the development environment, I get the following error: HOT 1
- An error occurred while accessing the file after local packaging.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docz.