- Notifications
You must be signed in to change notification settings - Fork 4
feat: improve examples and move routing logic #31
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
Merged
+703 −195
Merged
Changes from 1 commit
Commits
Show all changes
12 commits Select commit Hold shift + click to select a range
0e943cc feat: improve example loading and add more examples
brettkolodny 94361e0 fix: make copy more presentable
brettkolodny 6edd26c chore: move routing logic and share code loading to the backend
brettkolodny 8fbb7ef feat: give examples their own url
brettkolodny 99c9cd4 chore: remove connections example
brettkolodny 43ba750 chore: move asset path logic and shared headers into new utils.tsx
brettkolodny befd0bf feat: 404 page
brettkolodny a2743eb chore: move max code size into top level const
brettkolodny 30e6be8 chore: add external link icons to example links
brettkolodny bc95498 feat: add query param to auto open examples dropdown
brettkolodny aa10349 fix: use url sep
brettkolodny fb9caad fix: use proper prod asset paths
brettkolodny 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
chore: move asset path logic and shared headers into new utils.tsx
- Loading branch information
commit 43ba7504ab48438174dc3eabaeb1dab91a9f4141
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,40 @@ | ||
| import path from "node:path"; | ||
| import type { FC } from "react"; | ||
| | ||
| export const getAssetPath = (assetPath: string): string => { | ||
| if (import.meta.env.PROD) { | ||
| const pathParts = assetPath.split(path.sep); | ||
| return pathParts[pathParts.length - 1]; | ||
| } else { | ||
| return assetPath; | ||
| } | ||
| }; | ||
| | ||
| // Along with the vite React plugin this enables HMR within react while | ||
| // running the dev server. | ||
| export const HmrScript: FC<{ url: URL }> = ({ url }) => { | ||
| if (import.meta.env.PROD) { | ||
| return null; | ||
| } | ||
| | ||
| const injectClientScript = ` | ||
| import RefreshRuntime from "${url.origin}/@react-refresh"; | ||
| RefreshRuntime.injectIntoGlobalHook(window); | ||
| window.$RefreshReg$ = () => {}; | ||
| window.$RefreshSig$ = () => (type) => type; | ||
| window.__vite_plugin_react_preamble_installed__ = true; | ||
| `; | ||
| | ||
| return <script type="module">{injectClientScript}</script>; | ||
| }; | ||
| | ||
| export const BaseHeader = () => { | ||
| return ( | ||
| <> | ||
| <meta charSet="UTF-8" /> | ||
| <link rel="icon" type="image/svg+xml" href={getAssetPath("/logo.svg")} /> | ||
| <link rel="stylesheet" href={getAssetPath("/src/client/index.css")} /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
| </> | ||
| ); | ||
| }; |
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.
Maybe not necessary for this PR but you could add some validation to check if the example slug is valid