Skip to content

Commit

Permalink
chore: deno fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
crookse committed Dec 12, 2021
1 parent d32951e commit ed0e6f8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 21 deletions.
5 changes: 4 additions & 1 deletion pages/[...path_params].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import Layout from "../src/components/Layout";
import styled, { ThemeContext } from "styled-components";
import { titleCase } from "title-case";
import { useRouter } from "next/router";
import { convertFilenameToURL, formatLabel } from "../src/services/string_service";
import {
convertFilenameToURL,
formatLabel,
} from "../src/services/string_service";
import { publicRuntimeConfig } from "../src/services/config_service";
import ReactMarkdown from "react-markdown";
import * as Markdown from "../src/components/Markdown";
Expand Down
23 changes: 13 additions & 10 deletions src/components/Markdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ const flatten = (text, child) => {

const MARGIN_BOTTOM = "margin-bottom: 1.25rem !important;";


const LinkIcon = styled(Link)`
color: ${({ theme }) => theme.headingLinkIcon.color};
height: 25px;
Expand All @@ -41,18 +40,22 @@ const Heading = function (level) {
// The <h1> tags do not need an anchor because they are at the top of the
// page
if (level !== 1) {
linkedHeadingChildren.push((
<a key={`anchor_${slug}_${level}`} className="icon-link" href={`#` + slug}>
<LinkIcon key={`link_icon_${slug}_${level}`} className="icon" />
</a>
));
linkedHeadingChildren.push(
<a
key={`anchor_${slug}_${level}`}
className="icon-link"
href={`#` + slug}
>
<LinkIcon key={`link_icon_${slug}_${level}`} className="icon" />
</a>,
);
}

const renderLinkedHeading = React.createElement(
"h" + level,
{
key: JSON.stringify(props.children + level),
className: (level != 1) ? "heading-linked" : null
className: (level != 1) ? "heading-linked" : null,
},
linkedHeadingChildren,
);
Expand All @@ -69,9 +72,9 @@ const Heading = function (level) {
}

return (
<div className={props.className}>
{renderLinkedHeading}
</div>
<div className={props.className}>
{renderLinkedHeading}
</div>
);
};

Expand Down
2 changes: 1 addition & 1 deletion src/services/string_service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @returns A URL version of a filename.
*/
export function convertFilenameToURL(filename) {
return filename
return filename
.split("/") // Split the filename into path parts so we can clean up each part in `.map()`
.map((path) => {
// Remove all prefixed numbers and underscores from each path part. For example, a filename
Expand Down
4 changes: 2 additions & 2 deletions styles/theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const lightTheme = {
},
text: {
color: "#333333",
}
},
},
sideBar: {
background: "#f3f6f9",
Expand Down Expand Up @@ -89,7 +89,7 @@ export const darkTheme = {
},
text: {
color: "#f4f8ff",
}
},
},
markdown: {
heading2: {
Expand Down
17 changes: 10 additions & 7 deletions tests/unit/src/services/string_service.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import * as stringService from "../../../../src/services/string_service";

describe("string_service.js", () => {
describe.each(getConvertFilenameToURLVariables())("convertFilenameToURL()", (variables) => {
it("should convert filenames to URLs", () => {
const actual = stringService.convertFilenameToURL(variables.input);
expect(actual).toStrictEqual(variables.expected);
});
});
describe.each(getConvertFilenameToURLVariables())(
"convertFilenameToURL()",
(variables) => {
it("should convert filenames to URLs", () => {
const actual = stringService.convertFilenameToURL(variables.input);
expect(actual).toStrictEqual(variables.expected);
});
},
);
});

function getConvertFilenameToURLVariables() {
return [
{
input: "/docs/drash/v2.x/1_getting_started/1_introduction.md",
expected: "/drash/v2.x/getting-started/introduction",
}
},
];
}

0 comments on commit ed0e6f8

Please sign in to comment.