Skip to content

Commit

Permalink
Lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
kmturley committed Apr 15, 2021
1 parent b26ffcd commit 2a2eb7e
Show file tree
Hide file tree
Showing 7 changed files with 474 additions and 334 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build && next export",
"format": "prettier --write \"pages/**/*.ts\"",
"format": "prettier --write \"pages/**/*.{ts,tsx}\"",
"lint": "tslint -p tsconfig.json",
"start": "next start",
"test": "echo 'No tests were run'"
Expand Down
6 changes: 3 additions & 3 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../styles/global.css'
import { AppProps } from 'next/app'
import '../styles/global.css';
import { AppProps } from 'next/app';

export default function App({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />
return <Component {...pageProps} />;
}
111 changes: 53 additions & 58 deletions pages/docs/[slug].tsx
Original file line number Diff line number Diff line change
@@ -1,82 +1,77 @@
import { Component } from 'react'
import Container from '../../components/container'
import Layout from '../../components/layout'
import { getDocBySlug, getAllDocs } from '../../lib/api'
import Doc from '../../types/doc'
import markdownStyles from '../../styles/doc.module.css'
import remark from 'remark'
import html from 'remark-html'
import { withRouter, Router } from 'next/router'
import { Component } from 'react';
import Container from '../../components/container';
import Layout from '../../components/layout';
import { getDocBySlug, getAllDocs } from '../../lib/api';
import Doc from '../../types/doc';
import markdownStyles from '../../styles/doc.module.css';
import remark from 'remark';
import html from 'remark-html';
import { withRouter, Router } from 'next/router';

type DocProps = {
allDocs: Doc[],
doc: Doc,
router: Router
}

class DocPage extends Component<DocProps, {
allDocs: Doc[]
doc: Doc
router: Router
}> {
allDocs: Doc[];
doc: Doc;
router: Router;
};

class DocPage extends Component<
DocProps,
{
allDocs: Doc[];
doc: Doc;
router: Router;
}
> {
constructor(props: DocProps) {
super(props)
super(props);
this.state = {
allDocs: props.allDocs,
doc: props.doc,
router: props.router
}
router: props.router,
};
}

convertToSlug(text: string) {
return text
.toLowerCase()
.replace(/ /g,'-')
.replace(/[^\w-]+/g,'')
.toLowerCase()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '');
}

render() {
let content = this.state.doc.content.replace('/docs', `${this.state.router.basePath}/docs`)
content = content.replace(/<h2>(.*?)<\/h2>/g, (tag, title) => `<span id="${this.convertToSlug(title)}"></span>${tag}`)
let content = this.state.doc.content.replace('/docs', `${this.state.router.basePath}/docs`);
content = content.replace(
/<h2>(.*?)<\/h2>/g,
(tag, title) => `<span id="${this.convertToSlug(title)}"></span>${tag}`
);
return (
<Layout>
<Container docs={this.state.allDocs}>
<h1>{this.state.doc.title}</h1>
<div
className={markdownStyles.markdown}
dangerouslySetInnerHTML={{ __html: content }}
/>
</Container>
</Layout>
)
<Layout>
<Container docs={this.state.allDocs}>
<h1>{this.state.doc.title}</h1>
<div className={markdownStyles.markdown} dangerouslySetInnerHTML={{ __html: content }} />
</Container>
</Layout>
);
}
}
export default withRouter(DocPage)
export default withRouter(DocPage);

type Params = {
params: {
slug: string
}
}
slug: string;
};
};

async function markdownToHtml(markdown: string) {
const result = await remark().use(html).process(markdown)
return result.toString()
const result = await remark().use(html).process(markdown);
return result.toString();
}

export async function getStaticProps({ params }: Params) {
const allDocs = getAllDocs([
'title',
'slug'
])
const allDocs = getAllDocs(['title', 'slug']);

const doc = getDocBySlug(params.slug, [
'title',
'slug',
'content'
]) as Doc
const content = await markdownToHtml(doc.content || '')
const doc = getDocBySlug(params.slug, ['title', 'slug', 'content']) as Doc;
const content = await markdownToHtml(doc.content || '');

return {
props: {
Expand All @@ -86,20 +81,20 @@ export async function getStaticProps({ params }: Params) {
content,
},
},
}
};
}

export async function getStaticPaths() {
const docs = getAllDocs(['slug']) as Doc[]
const docs = getAllDocs(['slug']) as Doc[];

return {
paths: docs.map((doc) => {
return {
params: {
slug: doc.slug,
},
}
};
}),
fallback: false,
}
}
};
}
111 changes: 59 additions & 52 deletions pages/docs/index.tsx
Original file line number Diff line number Diff line change
@@ -1,69 +1,76 @@
import { Component } from 'react'
import Container from '../../components/container'
import Layout from '../../components/layout'
import styles from '../../styles/doc.module.css'
import { getAllDocs } from '../../lib/api'
import Head from 'next/head'
import Doc from '../../types/doc'
import { withRouter, Router } from 'next/router'
import { Component } from 'react';
import Container from '../../components/container';
import Layout from '../../components/layout';
import styles from '../../styles/doc.module.css';
import { getAllDocs } from '../../lib/api';
import Head from 'next/head';
import Doc from '../../types/doc';
import { withRouter, Router } from 'next/router';

type DocListProps = {
allDocs: Doc[],
router: Router
}

class DocList extends Component<DocListProps, {
allDocs: Doc[]
router: Router
}> {
allDocs: Doc[];
router: Router;
};

class DocList extends Component<
DocListProps,
{
allDocs: Doc[];
router: Router;
}
> {
constructor(props: DocListProps) {
super(props)
super(props);
this.state = {
allDocs: props.allDocs,
router: props.router
}
router: props.router,
};
}

render() {
return (
<>
<Layout>
<Head>
<title>Documentation</title>
</Head>
<Container docs={this.state.allDocs}>
<h1>Getting started</h1>
<p>System Requirements:</p>
<ul className={styles.markdownUl}>
<li className={styles.markdownLi}>Linux, MacOS or Windows</li>
<li className={styles.markdownLi}>NodeJS 12+</li>
</ul>
<p>To install the command line tool, run the command:</p>
<pre className={styles.markdownPre}>npm install @studiorack/cli -g</pre>
<p>Verify the tool has been installed by running:</p>
<pre className={styles.markdownPre}>studiorack --version</pre>
<h2 className={styles.markdownH2}>Music producers</h2>
<p>Follow our guide on how to start a music project and install plugins:</p>
<p><a href={`${this.state.router.basePath}/docs/02-create-a-project-config`} className={styles.markdownA}>Create a project config &gt;</a></p>
<h2 className={styles.markdownH2}>Plugin developers</h2>
<p>Jump straight to the advanced guide on how to create your own audio plugins:</p>
<p><a href={`${this.state.router.basePath}/docs/05-develop-new-plugins`} className={styles.markdownA}>Develop new plugins &gt;</a></p>
</Container>
</Layout>
</>
)
<>
<Layout>
<Head>
<title>Documentation</title>
</Head>
<Container docs={this.state.allDocs}>
<h1>Getting started</h1>
<p>System Requirements:</p>
<ul className={styles.markdownUl}>
<li className={styles.markdownLi}>Linux, MacOS or Windows</li>
<li className={styles.markdownLi}>NodeJS 12+</li>
</ul>
<p>To install the command line tool, run the command:</p>
<pre className={styles.markdownPre}>npm install @studiorack/cli -g</pre>
<p>Verify the tool has been installed by running:</p>
<pre className={styles.markdownPre}>studiorack --version</pre>
<h2 className={styles.markdownH2}>Music producers</h2>
<p>Follow our guide on how to start a music project and install plugins:</p>
<p>
<a href={`${this.state.router.basePath}/docs/02-create-a-project-config`} className={styles.markdownA}>
Create a project config &gt;
</a>
</p>
<h2 className={styles.markdownH2}>Plugin developers</h2>
<p>Jump straight to the advanced guide on how to create your own audio plugins:</p>
<p>
<a href={`${this.state.router.basePath}/docs/05-develop-new-plugins`} className={styles.markdownA}>
Develop new plugins &gt;
</a>
</p>
</Container>
</Layout>
</>
);
}
}
export default withRouter(DocList)
export default withRouter(DocList);

export const getStaticProps = async () => {
const allDocs = getAllDocs([
'title',
'slug'
])
const allDocs = getAllDocs(['title', 'slug']);

return {
props: { allDocs },
}
}
};
};
Loading

0 comments on commit 2a2eb7e

Please sign in to comment.