Skip to content

Commit

Permalink
feat(www): add link to rule source on GitHub (denoland#1264)
Browse files Browse the repository at this point in the history
By following this link users can learn how the rule is implemented,
and discover details about corner cases.

Also it eases potential contributions, if something needs to be fixed
or improved about the current rule.
  • Loading branch information
Delapouite authored May 5, 2024
1 parent f9d86e9 commit 217f44b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions www/routes/rules/[name].tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import IconBrandGithub from "https://deno.land/x/[email protected]/tsx/brand-github.tsx";

import jsonData from "../../static/docs.json" with { type: "json" };

import { Handlers, PageProps } from "$fresh/server.ts";
Expand Down Expand Up @@ -26,6 +28,9 @@ export const handler: Handlers<RuleData> = {

export default function RulePage(props: PageProps) {
const rule: RuleData = props.data;
const ruleSlug = rule.code.replaceAll("-", "_");
const sourceLink =
`https://github.com/denoland/deno_lint/blob/main/src/rules/${ruleSlug}.rs`;

return (
<div>
Expand All @@ -42,6 +47,15 @@ export default function RulePage(props: PageProps) {
<main>
<Rule rule={rule} open />
</main>
<footer>
<a class="hover:underline" href={sourceLink}>
<IconBrandGithub
title="View rule source on GitHub"
class="w-5 h-5 mr-1 inline"
/>
Rule source
</a>
</footer>
</div>
);
}

0 comments on commit 217f44b

Please sign in to comment.