Skip to content

Commit

Permalink
fix: deno run examples point to raw githubusercontent domain
Browse files Browse the repository at this point in the history
  • Loading branch information
numbertheory committed May 18, 2024
1 parent 8e0e4b1 commit 1a19e80
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/DenoByExample/ByExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ 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 +95,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 +173,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 1a19e80

Please sign in to comment.