mirror of
https://github.com/trailbaseio/trailbase.git
synced 2026-04-24 09:29:02 -05:00
docs: revert url construction for githubCodeReference. Thanks @lukasz0707. Fixes #145.
This commit is contained in:
@@ -96,7 +96,7 @@ sleeve:
|
||||
being enforced from the client all the way to the database[^4].
|
||||
- A more Node-like JS runtime with full ES6 support, built-in TypeScript
|
||||
transpilation, and V8 performance unlocking more of the JS ecosystem and enabling
|
||||
<a href={githubPath("/examples/collab-clicker-ssr")}>server-side rendering (SSR)</a>
|
||||
<a href={githubPath("examples/collab-clicker-ssr")}>server-side rendering (SSR)</a>
|
||||
with any popular JS framework.
|
||||
- Untethered access to SQLite with all its features and capabilities.
|
||||
- A wider set of first-class client libraries beyond JS/TS and Dart, including
|
||||
|
||||
@@ -24,7 +24,7 @@ participants.
|
||||
<div class="h-[24px]" />
|
||||
|
||||
The conclusion of this tutorial is part of the main code repository and can be found
|
||||
<a href={githubPath("/examples/collab-clicker-ssr")}>here</a>
|
||||
<a href={githubPath("examples/collab-clicker-ssr")}>here</a>
|
||||
or downloaded by running:
|
||||
|
||||
<Code
|
||||
@@ -207,7 +207,7 @@ The following sections will cover the major beats but skip over some incremental
|
||||
evolving glue code to avoid being overly redundant.
|
||||
Hopefully you can work things out with a little help from the compiler.
|
||||
If not, you can find the final product
|
||||
<a href={githubPath("/examples/collab-clicker-ssr")}>here</a>
|
||||
<a href={githubPath("examples/collab-clicker-ssr")}>here</a>
|
||||
to read along or after finishing the tutorial.
|
||||
|
||||
### 1. Setting up the Database
|
||||
@@ -409,7 +409,7 @@ const buttonStyle =
|
||||
|
||||
At this point you should hopefully have a little collaborative clicker *game* 🎉.
|
||||
If you got lost along the way - apologies . You can check out the final result
|
||||
<a href={githubPath("/examples/collab-clicker-ssr")}>here</a>.
|
||||
<a href={githubPath("examples/collab-clicker-ssr")}>here</a>.
|
||||
|
||||
|
||||
## What's Next?
|
||||
@@ -417,7 +417,7 @@ If you got lost along the way - apologies . You can check out the final result
|
||||
Thanks for making it to the end.
|
||||
Beyond the basic example above, the repository contains a more involved examples, such as:
|
||||
|
||||
* A <a href={githubPath("/examples/blog")}>Blog</a>
|
||||
* A <a href={githubPath("examples/blog")}>Blog</a>
|
||||
with both, a Web and Flutter UI, more complex APIs, authorization and custom
|
||||
user profiles.
|
||||
|
||||
|
||||
@@ -217,7 +217,7 @@ If you have any feedback, don't hesitate and reach out on
|
||||
Thanks for making it to the end.
|
||||
Beyond the basic example above, the repository contains a more involved examples, such as:
|
||||
|
||||
* A <a href={githubPath("/examples/blog")}>Blog</a>
|
||||
* A <a href={githubPath("examples/blog")}>Blog</a>
|
||||
with both, a Web and Flutter UI, more complex APIs, authorization and custom
|
||||
user profiles.
|
||||
* A collaborative clicker *game* demonstrating server-side rendering (SSR) with
|
||||
|
||||
@@ -121,7 +121,7 @@ export const demoLink = "https://demo.trailbase.io";
|
||||
<Image margin={0} class="p-0 m-0" width={42} height={52} src={flutterLogo} alt="Flutter" />
|
||||
</a>
|
||||
|
||||
<a href={githubPath("/client/swift/trailbase")}>
|
||||
<a href={githubPath("client/swift/trailbase")}>
|
||||
<Image margin={0} class="p-0 m-0" width={52} height={52} src={swiftLogo} alt="Swift" />
|
||||
</a>
|
||||
|
||||
@@ -137,7 +137,7 @@ export const demoLink = "https://demo.trailbase.io";
|
||||
<Image margin={0} class="p-0 m-0" width={52} height={52} src={rustLogo} alt="Rust" />
|
||||
</a>
|
||||
|
||||
<a href={githubPath("/client/go/trailbase")}>
|
||||
<a href={githubPath("client/go/trailbase")}>
|
||||
<Image margin={0} class="p-0 m-0" width={52} height={52} src={goLogo} alt="Go" />
|
||||
</a>
|
||||
</div>
|
||||
@@ -151,7 +151,7 @@ export const demoLink = "https://demo.trailbase.io";
|
||||
|
||||
[TanStack/db](https://tanstack.com/db/latest) ships with a TrailBase
|
||||
integration out-of-the-box, check out
|
||||
<a href={githubPath("/examples/tanstack-db-sync")}>example</a>.
|
||||
<a href={githubPath("examples/tanstack-db-sync")}>example</a>.
|
||||
|
||||
<div class="flex justify-center items-center">
|
||||
<a href="https://github.com/TanStack/db/tree/main/packages/trailbase-db-collection">
|
||||
|
||||
+11
-6
@@ -10,8 +10,11 @@ export function githubCodeReference(args: {
|
||||
path: string;
|
||||
match: string;
|
||||
}): string {
|
||||
const pwd = cwd();
|
||||
const root = join(pwd, "..");
|
||||
if (args.path.startsWith("/")) {
|
||||
throw new Error("expected relative path");
|
||||
}
|
||||
|
||||
const root = join(cwd(), "..");
|
||||
const path = join(root, args.path);
|
||||
|
||||
const buffer = readFileSync(path);
|
||||
@@ -31,7 +34,7 @@ export function githubCodeReference(args: {
|
||||
case 0:
|
||||
throw new Error(`Not match for '${args.match}' in: ${args.path}`);
|
||||
case 1:
|
||||
return join(`${repo}/blob/main/`, args.path) + `#L${matches[0]}`;
|
||||
return `${repo}/blob/main/${args.path}#L${matches[0]}`;
|
||||
default:
|
||||
throw new Error(
|
||||
`Ambiguous matches for '${args.match}' at lines: ${matches} in: ${args.path}`,
|
||||
@@ -42,12 +45,14 @@ export function githubCodeReference(args: {
|
||||
/// Creates and validates a Github repository link, like:
|
||||
/// https://github.com/trailbaseio/trailbase/tree/main/examples/blog.
|
||||
export function githubPath(path: string): string {
|
||||
const pwd = cwd();
|
||||
const root = join(pwd, "..");
|
||||
if (path.startsWith("/")) {
|
||||
throw new Error("expected relative path");
|
||||
}
|
||||
|
||||
const root = join(cwd(), "..");
|
||||
if (!existsSync(join(root, path))) {
|
||||
throw new Error(`Path not found: ${path}`);
|
||||
}
|
||||
|
||||
return join(`${repo}/blob/main/`, path);
|
||||
return `${repo}/blob/main/${path}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user