From f766bf3eaf23573954abf0a81426d939d5ca8eaa Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Fri, 27 Nov 2020 19:39:21 -0500 Subject: [PATCH] Run prettier --- .eslintrc.js | 11 ++------ .prettierrc | 4 +-- gatsby-config.js | 18 ++++++------ gatsby-node.js | 14 ++++++---- src/components/item.tsx | 8 +++--- src/components/navbar.tsx | 37 ++++++++++++++++--------- src/pages/404.tsx | 21 ++++++++------ src/pages/projects/index.tsx | 20 ++++---------- src/templates/note.tsx | 35 +++++++++++++----------- src/templates/notes.tsx | 53 ++++++++++++++++++++++++------------ src/utils/typography.js | 17 ++++++++---- 11 files changed, 133 insertions(+), 105 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index efaac63..09759a8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -1,14 +1,9 @@ module.exports = { root: true, parser: '@typescript-eslint/parser', - plugins: [ - '@typescript-eslint', - ], + plugins: ['@typescript-eslint'], globals: { __PATH_PREFIX__: true, }, - extends: [ - 'eslint:recommended', - 'plugin:@typescript-eslint/recommended', - ], -}; \ No newline at end of file + extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'], +}; diff --git a/.prettierrc b/.prettierrc index 33d2cfa..81ed141 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,4 +1,4 @@ { - "arrowParens": "avoid", - "semi": false + "singleQuote": true, + "jsxSingleQuote": true, } diff --git a/gatsby-config.js b/gatsby-config.js index 09ebc78..9af589b 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -41,7 +41,7 @@ module.exports = { // you may use this to prevent Prism from re-processing syntax. // This is an uncommon use-case though; // If you're unsure, it's best to use the default value. - classPrefix: "language-", + classPrefix: 'language-', // This is used to allow setting a language for inline code // (i.e. single backticks) by creating a separator. // This separator is a string and will do no white-space @@ -71,8 +71,8 @@ module.exports = { // existing language" below. languageExtensions: [ { - language: "superscript", - extend: "javascript", + language: 'superscript', + extend: 'javascript', definition: { superscript_types: /(SuperType)/, }, @@ -86,8 +86,8 @@ module.exports = { // Customize the prompt used in shell output // Values below are default prompt: { - user: "root", - host: "localhost", + user: 'root', + host: 'localhost', global: false, }, // By default the HTML entities <>&'" are escaped. @@ -100,13 +100,13 @@ module.exports = { resolve: 'gatsby-remark-smartypants', options: { dashes: 'oldschool', - } + }, }, - ] - } + ], + }, }, { - resolve: 'gatsby-plugin-mdx-frontmatter' + resolve: 'gatsby-plugin-mdx-frontmatter', }, ], }; diff --git a/gatsby-node.js b/gatsby-node.js index 2d377ad..3dc119c 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -1,4 +1,4 @@ -const path = require("path"); +const path = require('path'); exports.createPages = async ({ actions, graphql, reporter }) => { const { createPage } = actions; @@ -28,15 +28,17 @@ exports.createPages = async ({ actions, graphql, reporter }) => { return; } - const posts = result.data.allMdx.edges.filter(({ node }) => !node.frontmatter.hidden); + const posts = result.data.allMdx.edges.filter( + ({ node }) => !node.frontmatter.hidden + ); const postsPerPage = 10; const numPages = Math.ceil(posts.length / postsPerPage); - const rootPath = "/notes"; + const rootPath = '/notes'; Array.from({ length: numPages }).forEach((_, i) => { createPage({ path: rootPath + (i === 0 ? '' : `/${i + 1}`), - component: path.resolve("./src/templates/notes.tsx"), + component: path.resolve('./src/templates/notes.tsx'), context: { limit: postsPerPage, skip: i * postsPerPage, @@ -44,7 +46,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => { currentPage: i + 1, rootPath, }, - }) + }); }); // Must decouple to ensure hidden pages are still rendered, just excluded from @@ -58,7 +60,7 @@ exports.createPages = async ({ actions, graphql, reporter }) => { }, }); }); -} +}; exports.createSchemaCustomization = ({ actions: { createTypes } }) => { createTypes(` type Mdx implements Node { diff --git a/src/components/item.tsx b/src/components/item.tsx index 5af89c4..14bcf27 100644 --- a/src/components/item.tsx +++ b/src/components/item.tsx @@ -1,10 +1,10 @@ -import React from "react"; -import style from "./item.module.css"; -import { Link } from "gatsby"; +import React from 'react'; +import style from './item.module.css'; +import { Link } from 'gatsby'; export default (props) => (

{props.title}

{props.subtitle}

-); \ No newline at end of file +); diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index 1adfff1..12f1b52 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -1,20 +1,31 @@ import React from 'react'; -import { Link } from "gatsby"; +import { Link } from 'gatsby'; -const ExactLink = (props) => - {props.children} -; +const ExactLink = (props) => ( + + {props.children} + +); export default function Navbar() { return ( +

+ + Edward Shen + +

+

+ Projects +

+

+ Notes +

+ ); -}; \ No newline at end of file +} diff --git a/src/pages/404.tsx b/src/pages/404.tsx index 0e076ba..a5e90ee 100644 --- a/src/pages/404.tsx +++ b/src/pages/404.tsx @@ -1,17 +1,22 @@ import { PageProps } from 'gatsby'; import React from 'react'; -import Navbar from "../components/navbar"; +import Navbar from '../components/navbar'; export default ({ location }: PageProps): JSX.Element => { const messages = [

- In your attempt to search for {location.pathname}, you seem to - have gotten lost instead. Fret not, for there is always a path home. + In your attempt to search for {location.pathname}, you seem + to have gotten lost instead. Fret not, for there is always a path{' '} + home. +

, +

+ Not all who wander are lost, but you seem to be. Go home?

, -

Not all who wander are lost, but you seem to be. Go home?

]; - return <> - - {messages[Math.floor(Math.random() * messages.length)]} - ; + return ( + <> + + {messages[Math.floor(Math.random() * messages.length)]} + + ); }; diff --git a/src/pages/projects/index.tsx b/src/pages/projects/index.tsx index 946ea72..2c3c775 100644 --- a/src/pages/projects/index.tsx +++ b/src/pages/projects/index.tsx @@ -1,22 +1,12 @@ -import React from "react"; +import React from 'react'; import Navbar from '../../components/navbar'; -import Item from "../../components/item"; +import Item from '../../components/item'; export default (): JSX.Element => ( <> - - - + + + ); diff --git a/src/templates/note.tsx b/src/templates/note.tsx index 9d4152a..1e29781 100644 --- a/src/templates/note.tsx +++ b/src/templates/note.tsx @@ -1,27 +1,30 @@ -import React from "react"; +import React from 'react'; import Navbar from '../components/navbar'; -import { graphql } from "gatsby"; +import { graphql } from 'gatsby'; import { MDXRenderer } from 'gatsby-plugin-mdx'; export default ({ data }) => { const { frontmatter, body } = data.mdx; - return <> - -
-

{frontmatter.title}

- {body} -
- ; + return ( + <> + +
+

{frontmatter.title}

+ {body} +
+ + ); }; export const query = graphql` -query NotesIndexQuery($id: String!) { - mdx(id: {eq: $id}) { - frontmatter { - title + query NotesIndexQuery($id: String!) { + mdx(id: { eq: $id }) { + frontmatter { + title + } + tableOfContents + body } - tableOfContents - body } -}`; +`; diff --git a/src/templates/notes.tsx b/src/templates/notes.tsx index b2acae6..df7586c 100644 --- a/src/templates/notes.tsx +++ b/src/templates/notes.tsx @@ -3,10 +3,10 @@ * See note.tsx for rendering a single note. */ -import React from "react"; -import Navbar from "../components/navbar"; -import { graphql } from "gatsby"; -import style from "./notes.module.css"; +import React from 'react'; +import Navbar from '../components/navbar'; +import { graphql } from 'gatsby'; +import style from './notes.module.css'; export default ({ data, pageContext }): JSX.Element => { const posts = data.allMdx.edges; @@ -14,9 +14,20 @@ export default ({ data, pageContext }): JSX.Element => { let prevPageLink = null; if (currentPage === 2) { - prevPageLink = <<; + prevPageLink = ( + + << + + ); } else if (currentPage !== 1) { - prevPageLink = <<; + prevPageLink = ( + + << + + ); } const shouldDisplayNav = numPages !== 1; @@ -25,41 +36,47 @@ export default ({ data, pageContext }): JSX.Element => { <> {posts.map(({ node }) => { - const frontmatter = node.frontmatter + const frontmatter = node.frontmatter; return ( - ) + ); })} - {shouldDisplayNav && + {shouldDisplayNav && (

{prevPageLink} {currentPage} - {currentPage !== numPages && + {currentPage !== numPages && ( + className={style.nextPageLink} + > >> - } + )}

- } + )} - ) -} + ); +}; export const query = graphql` query IndexQuery($skip: Int!, $limit: Int!) { allMdx( sort: { order: DESC, fields: [frontmatter___date] } - filter: { fileAbsolutePath: { glob: "**/src/notes/*" }, frontmatter: {hidden: {ne: true}} } + filter: { + fileAbsolutePath: { glob: "**/src/notes/*" } + frontmatter: { hidden: { ne: true } } + } limit: $limit skip: $skip ) { @@ -76,4 +93,4 @@ export const query = graphql` } } } -` +`; diff --git a/src/utils/typography.js b/src/utils/typography.js index 90b2ecd..8e6f28a 100644 --- a/src/utils/typography.js +++ b/src/utils/typography.js @@ -1,20 +1,25 @@ -import Typography from "typography"; +import Typography from 'typography'; const typography = new Typography({ baseFontSize: '18px', baseLineHeight: 1.666, headerFontFamily: [ - 'M PLUS 1p', 'Helvetica Neue', 'Segoe UI', 'Helvetica', 'Arial', 'sans-serif' + 'M PLUS 1p', + 'Helvetica Neue', + 'Segoe UI', + 'Helvetica', + 'Arial', + 'sans-serif', ], bodyFontFamily: ['Georgia', 'serif'], googleFonts: [ { - name: "M PLUS 1p", + name: 'M PLUS 1p', styles: ['100', '400'], - } - ] + }, + ], }); // Export helper functions export const { scale, rhythm, options } = typography; -export default typography; \ No newline at end of file +export default typography;