Skip to content

Commit

Permalink
Add GitHub actions step for validating prettier code style (#759)
Browse files Browse the repository at this point in the history
  • Loading branch information
junlarsen authored Apr 7, 2024
1 parent ab33e69 commit c373f8b
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 17 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,17 @@ jobs:
- name: Actually run the tests
run: cargo test --all
working-directory: tutorial-code
fmt-check:
name: Verify project code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install node dependencies
run: npm install

- name: Check formatting
run: npm run fmt:check
11 changes: 5 additions & 6 deletions components/content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,13 @@ export default function Content({
<section className="section content">
<div className="columns">
<div className="column is-two-thirds tk-markdown" ref={mdRef}>
<h1 className={`title ${isBlogRoute ? 'blog-title' : ''}`} id="">
<h1
className={`title ${isBlogRoute ? "blog-title" : ""}`}
id=""
>
{title}
</h1>
{isBlogRoute && (
<p className="description">
{description}
</p>
)}
{isBlogRoute && <p className="description">{description}</p>}
<div dangerouslySetInnerHTML={{ __html: body }}></div>
<Footer next={next} prev={prev} mdPath={mdPath} />
</div>
Expand Down
24 changes: 19 additions & 5 deletions components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@ export default function Footer() {
<div key={name} className="column is-one-third">
<p className="tk-lib-name">{name}</p>
<p>
<a href={docs} target="_blank">Docs</a>
<a href={docs} target="_blank">
Docs
</a>
</p>
<p>
<a href={github} target="_blank">Github</a>
<a href={github} target="_blank">
Github
</a>
</p>
</div>
));
Expand All @@ -38,7 +42,10 @@ export default function Footer() {
<div className="tk-help-links">
<p>
Get Help:
<a href="https://github.com/tokio-rs/tokio/discussions" target="_blank">
<a
href="https://github.com/tokio-rs/tokio/discussions"
target="_blank"
>
<GitHubIcon className="is-medium" />
</a>
<a href="https://discord.gg/tokio" target="_blank">
Expand Down Expand Up @@ -74,7 +81,10 @@ export default function Footer() {
<div className="container has-text-centered">
<p>
with the help of{" "}
<a href="https://github.com/tokio-rs/tokio/graphs/contributors" target="_blank">
<a
href="https://github.com/tokio-rs/tokio/graphs/contributors"
target="_blank"
>
our contributors
</a>
.
Expand All @@ -83,7 +93,11 @@ export default function Footer() {
<div className="container has-text-centered">
<p>
Hosted by{" "}
<a href="https://netlify.com" target="_blank" rel="sponsored nofollow">
<a
href="https://netlify.com"
target="_blank"
rel="sponsored nofollow"
>
Netlify
</a>
</p>
Expand Down
2 changes: 1 addition & 1 deletion lib/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const rehyperBlockquotePlusOptions = {
const rehypeHighlightOptions = {
languages: { rust: rust },
aliases: { rust: ["rs", "rust,compile_fail", "rust,ignore", "rust="] },
plainText: ['txt', 'text', "plain", "log"]
plainText: ["txt", "text", "plain", "log"],
};

export const toHTML = async (raw) => {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"build": "next build && npm run build:rss && next export",
"build:rss": "node ./scripts/generate-rss-feed.js",
"start": "next start",
"fmt": "prettier --write --prose-wrap always '{components,content,pages,lib,styles}/**/*.{js,jsx,ts,tsx,scss}'"
"fmt": "prettier --write --prose-wrap always '{components,content,pages,lib,styles}/**/*.{js,jsx,ts,tsx,scss}'",
"fmt:check": "prettier --check --prose-wrap always '{components,content,pages,lib,styles}/**/*.{js,jsx,ts,tsx,scss}'"
},
"dependencies": {
"@next/font": "^13.1.1",
Expand Down
8 changes: 7 additions & 1 deletion pages/[...slug].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ const menu = {
],
},
topics: {
nested: ["bridging", "shutdown", "tracing", "tracing-next-steps", "testing"],
nested: [
"bridging",
"shutdown",
"tracing",
"tracing-next-steps",
"testing",
],
},
glossary: {},
api: {
Expand Down
2 changes: 1 addition & 1 deletion pages/blog/[...slug].jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function getStaticProps({ params: { slug: slugParam } }) {
});

const page = content.loadPage(`blog/${slug}`);
page.body = await toHTML(page.body)
page.body = await toHTML(page.body);

let next = blog.getNextPost(slug);
let previous = blog.getPreviousPost(slug);
Expand Down
4 changes: 2 additions & 2 deletions styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ a:active {
font-size: $menu-font-size;
position: relative;
z-index: 2;

@include tablet {
max-width: 280px;
margin-left: auto;
Expand Down Expand Up @@ -729,7 +729,7 @@ a:active {
}

&.blog-title {
margin-bottom : 0rem;
margin-bottom: 0rem;
}
}

Expand Down

0 comments on commit c373f8b

Please sign in to comment.