Skip to content

Commit

Permalink
fix: deno run examples should point to raw githubusercontent domain (#…
Browse files Browse the repository at this point in the history
…471)

Co-authored-by: Jo Franchetti <jofranchetti@gmail.com>
  • Loading branch information
numbertheory and thisisjofrank committed May 20, 2024
1 parent 8e0e4b1 commit 45eed5c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/DenoByExample/ByExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ export default function ByExample({ example, examplesList }) {
origin: "https://github.com/denoland/deno-docs/blob/main/by-example/",
pathname: id,
},
rawUrl: {
origin:
"https://raw.githubusercontent.com/denoland/deno-docs/main/by-example/",
pathname: id,
},
data: [
parsed,
content,
Expand Down Expand Up @@ -91,6 +96,9 @@ function ExamplePage(props: PageProps<Data>) {
const url = `${props.url.origin}${props.url.pathname}${
example.files.length > 1 ? "/main" : ""
}`;
const rawUrl = `${props.rawUrl.origin}${props.rawUrl.pathname}${
example.files.length > 1 ? "/main" : ""
}`;

const contentNoCommentary = example.files.map((file) =>
file.snippets.map((snippet) => snippet.code).join("\n")
Expand Down Expand Up @@ -166,7 +174,7 @@ function ExamplePage(props: PageProps<Data>) {
<CodeBlock language="ts">
{example.run.startsWith("deno")
? example.run.replace("<url>", url)
: "deno run " + example.run.replace("<url>", url)}
: "deno run " + example.run.replace("<url>", rawUrl)}
</CodeBlock>
</>
)}
Expand Down

0 comments on commit 45eed5c

Please sign in to comment.