[WIP] Finish initial SSR (server side rendering) and add tests.
Summary
Moved from https://github.com/anikethsaha/docsify/pull/3
Expands on stuff from https://github.com/docsifyjs/docsify/pull/1128 (this PR includes those changes) which fixes #1126.
This will PR do the following (WIP):
-
replaces custom URL analysis (custom regex) with DOM APIs that are known to work in
isExternal -
adds tests for it
-
fixes SSR because
isExternalis used there, and to test it there we must fix it (one line fix) -
adds tests for SSR now that it is fixed
-
[x] uses DOM APIs (JSDOM in Node.js and SSR, otherwise native APIs) for the
isExternalfunction -
[x] consolidate
isExternalso all code imports the same version -
[ ] initial tests for server-renderer (WIP, we can't test DOMPurify in SSR if SSR isn't working, so first we get SSR working and add a simple test for it)
-
[ ] add tests for isExternal and DOMPurify (WIP)
-
[ ] cleanup (remove comments, use conventional commit messages, etc)
What kind of change does this PR introduce? (check at least one)
- [x] Bugfix
- [ ] Feature
- [ ] Code style update
- [x] Refactor
- [ ] Docs
- [ ] Build-related changes
- [x] tests
- [ ] Other, please describe:
Does this PR introduce a breaking change? (check one)
- [ ] Yes
- [x] No
If yes, please describe the impact and migration path for existing applications:
The PR fulfills these requirements:
- [x] When resolving a specific issue, it's referenced in the PR's title (e.g.
fix #xxx[,#xxx], where "xxx" is the issue number)
#1126
You have tested in the following browsers: (Providing a detailed version will be better.)
- [ ] Chrome
- [ ] Firefox
- [ ] Safari
- [ ] Edge
- [ ] IE
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/docsify-core/docsify-preview/2CFnWQmsbQ8UvXud3MuYLjBhAyDS
✅ Preview: https://docsify-preview-git-fix-validating-remote-c-cfafef-docsify-core.vercel.app
This pull request is automatically built and testable in CodeSandbox.
To see build info of the built libraries, click here or the icon next to each commit SHA.
Latest deployment of this branch, based on commit 6be29650eb31ffd6dcc7493962dd52a3ec11c021:
| Sandbox | Source |
|---|---|
| confident-ptolemy-9qr4s | Configuration |
All pages in SSR more are working except for the "Embed Files" page. This one works when you load another page then switch to it (in that case it fetches the markdown, and processes it client side), but if you press refresh while on that page then it will cause the server to try to generate the page on the server-side and there will be a server-side error.
Otherwise, it appears to work. Working on playwright tests now.
I merged develop (playwright), will push soon...
is this independent of #1276 ?
Yep, independent of that PR (merged develop into here, now writing the tests with playwright, the conversion is fairly straight forward).
Also, if its still in WIP, can you convert this into draft.
:+1:
- [ ] Make sure any issue with https://github.com/docsifyjs/docsify/issues/1427 is fixed
any progress on this? We would really like to get SSR working
I just pushed a working concept! The commit describes a few things that don't work, but for basic without plugins or Vue components it will work.
Up next we need to figure how to handle plugins, and Vue components (@jhildenbiddle).
We need to call some parts of plugins during SSR markdown handling, and other parts of plugins on the client side where they can control the resulting DOM.
Search and cover page aren't working (they have some URL mis-handling, similar to what I fixed in this PR in other areas of the code, just needs some more work. Next time!).
I made an update to the title to better reflect what this has become (finishing the initial SSR implementation). A side-effect of it is adding tests for some features (that was the original intent of the PR).