{children}
-
-
+
+
-
+
)
}
-
-export default Layout
diff --git a/src/components/Layout/layout.scss b/src/components/Layout/layout.scss
index 1a050a5..5d5d82d 100644
--- a/src/components/Layout/layout.scss
+++ b/src/components/Layout/layout.scss
@@ -6,6 +6,7 @@ html {
-ms-text-size-adjust: 100%;
-webkit-text-size-adjust: 100%;
}
+
body {
margin: 0;
-webkit-font-smoothing: antialiased;
diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx
deleted file mode 100644
index f536205..0000000
--- a/src/components/Navbar/index.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import { Link } from "gatsby";
-import * as React from "react";
-import icon from "./icon.png";
-import { HeaderWrapper } from "./styles";
-
-// @todo maybe find alternative type for data
-const Navbar = ({ siteTitle }: any) => (
-
-
-
- {/* */}
-
-
- {siteTitle}
-
-
-
-
-
-
-)
-
-Navbar.propTypes = {
- siteTitle: String
-}
-
-Navbar.defaultProps = {
- siteTitle: ``,
-}
-
-export default Navbar;
diff --git a/src/components/Navbar/styles.tsx b/src/components/Navbar/styles.tsx
deleted file mode 100644
index f8812d3..0000000
--- a/src/components/Navbar/styles.tsx
+++ /dev/null
@@ -1,6 +0,0 @@
-import styled from "styled-components";
-
-export const HeaderWrapper = styled.header`
- background: #ba1a2e;
- marginBottom: 1.45rem;
-`;
\ No newline at end of file
diff --git a/src/components/SEO/index.tsx b/src/components/SEO/index.tsx
index 9d67c40..6597c85 100644
--- a/src/components/SEO/index.tsx
+++ b/src/components/SEO/index.tsx
@@ -3,13 +3,20 @@ import Helmet from "react-helmet"
import { useStaticQuery, graphql } from "gatsby"
interface SEOProps {
- readonly description: string;
- readonly lang: string;
- readonly meta: object[];
- readonly title: string;
+ readonly description?: string
+ readonly lang?: string
+ readonly meta?: any[]
+ readonly keywords?: string[]
+ readonly title: string
}
-const SEO = ({ description = "", lang = "en", meta = [], title }: SEOProps) => {
+export function SEO({
+ description,
+ lang = "en",
+ meta = [],
+ keywords = [],
+ title,
+}: SEOProps) {
const { site } = useStaticQuery(
graphql`
query {
@@ -66,9 +73,16 @@ const SEO = ({ description = "", lang = "en", meta = [], title }: SEOProps) => {
name: `twitter:description`,
content: metaDescription,
},
- ]}
+ ]
+ .concat(
+ keywords.length > 0
+ ? {
+ name: `keywords`,
+ content: keywords.join(`, `),
+ }
+ : []
+ )
+ .concat(meta)}
/>
)
-};
-
-export default SEO
+}
diff --git a/src/components/Sidebar/index.tsx b/src/components/Sidebar/index.tsx
index c0d3c9a..9c29190 100644
--- a/src/components/Sidebar/index.tsx
+++ b/src/components/Sidebar/index.tsx
@@ -1,9 +1,9 @@
-import React from "react"
+import React, { PropsWithChildren } from "react"
import logo from "../../images/tph-logo.png"
import * as SC from "./styles"
import ArrowRight from "../../icons/arrow-right.svg"
-function MenuItem({ children, to }: { children: React.ReactNode; to: string }) {
+function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) {
return (
{children}
@@ -11,7 +11,7 @@ function MenuItem({ children, to }: { children: React.ReactNode; to: string }) {
)
}
-const Sidebar = () => {
+export function Sidebar() {
return (
@@ -27,5 +27,3 @@ const Sidebar = () => {
)
}
-
-export default Sidebar
diff --git a/src/content/docs/javascript/promises/intro.md b/src/content/docs/javascript/promises/intro.md
index 636d98d..64b94db 100644
--- a/src/content/docs/javascript/promises/intro.md
+++ b/src/content/docs/javascript/promises/intro.md
@@ -31,8 +31,8 @@ called `getMembers` that retrieves all the members in a discord server. When we
function we see the following result.
```js
-const members = getMembers("The Programmers Hangout");
-console.log(members); // Promise {}
+const members = getMembers("The Programmers Hangout")
+console.log(members) // Promise {}
```
Normally, we would have expected to see an array of all the members but it takes time to
@@ -44,8 +44,8 @@ to access the actual members like so.
```js
getMembers("The Programmers Hangout").then(members => {
- console.log(members); // (32k) [{...}, {...}, {...}]
-});
+ console.log(members) // (32k) [{...}, {...}, {...}]
+})
```
This way we are able to make sure that we only try to `console.log` when the `getMembers` function has resolved and ready to be used.
@@ -63,15 +63,15 @@ You may have tried doing something like this before.
```js
// Incorrect code, don't copy!
-let results;
+let results
getWeather("Los Angeles").then(weather => {
- results = weather;
-});
+ results = weather
+})
console.log(results) // undefined
```
Why is `results` undefined? Because **Javascript doesn't wait**. Whenever a Promise is created,
-your code will continue to run until there's no more code left in the stack. Only then
+your code will continue to run until there's no more code left in the stack. Only then
will javascript try to run the `.then` callback of a Promise. Even if your Promise resolves
immediately you are going to have to wait until you've run all the code in the stack before
your `.then` callback has a chance to start running. This is due to the way the event loop works,
@@ -81,8 +81,8 @@ In order to fix this problem we need to move the `console.log` inside the `.then
```js
getWeather("Los Angeles").then(weather => {
- console.log(weather); // Sunny, probably
-});
+ console.log(weather) // Sunny, probably
+})
```
## Real World Example
@@ -94,14 +94,14 @@ You can try it in your browser if you want to test it out.
function getCharacters() {
return fetch(`https://rickandmortyapi.com/api/character`)
.then(response => response.json())
- .then(response => response.results);
+ .then(response => response.results)
}
getCharacters().then(characters => {
- console.log(characters); // (20) [{...}, {...}, {...}]
-});
+ console.log(characters) // (20) [{...}, {...}, {...}]
+})
```
Let's break down what's happening in this function
-// TODO: finish this
\ No newline at end of file
+// TODO: finish this
diff --git a/src/content/docs/javascript/promises/simplifying-promises.md b/src/content/docs/javascript/promises/simplifying-promises.md
index 730b721..261d1fb 100644
--- a/src/content/docs/javascript/promises/simplifying-promises.md
+++ b/src/content/docs/javascript/promises/simplifying-promises.md
@@ -15,9 +15,9 @@ function doAsync(number) {
return new Promise(function(resolve, reject) {
doDatabase().then(function(dbResult) {
otherDbFunction(dbResult).then(function(secondResult) {
- resolve(secondResult + 10);
+ resolve(secondResult + 10)
})
- });
+ })
})
}
```
@@ -29,9 +29,9 @@ already returns a promise, you can just return the original thing.
function doAsync(number) {
return doDatabase().then(function(dbResult) {
otherDbFunction(dbResult).then(function(secondResult) {
- return secondResult + 10;
+ return secondResult + 10
})
- });
+ })
}
```
@@ -40,11 +40,13 @@ is that they allow you do chain them sequentially.
```js
function doAsync(number) {
- return doDatabase().then(function(dbResult) {
- return otherDbFunction(dbResult)
- }).then(function(secondResult) {
- return secondResult + 10;
- });
+ return doDatabase()
+ .then(function(dbResult) {
+ return otherDbFunction(dbResult)
+ })
+ .then(function(secondResult) {
+ return secondResult + 10
+ })
}
```
@@ -56,17 +58,18 @@ function doAsync(number) {
return doDatabase()
.then(otherDbFunction)
.then(function(secondResult) {
- return secondResult + 10;
- });
+ return secondResult + 10
+ })
}
```
And you don't need those returns if you just have ES6 arrow functions
```js
-const doAsync = number => doDatabase()
- .then(otherDbFunction)
- .then(secondResult => secondResult + 10);
+const doAsync = number =>
+ doDatabase()
+ .then(otherDbFunction)
+ .then(secondResult => secondResult + 10)
```
Wow, that last one looks a lot cleaner to me than the first. Keeping that in mind, maybe we could be making some of our other functions cleaner as well
diff --git a/src/content/docs/php/design-patterns/singleton.md b/src/content/docs/php/design-patterns/singleton.md
index a25be15..1295460 100644
--- a/src/content/docs/php/design-patterns/singleton.md
+++ b/src/content/docs/php/design-patterns/singleton.md
@@ -13,7 +13,6 @@ There are multiple benefits to using a singleton class
- You're always going to pull the same instance of the class
- It's only instantiated once
- Use `$this` in a static-like context
--
By using a singleton instead of a static class we expose a cleaner class to use and we can use regular instance properties instead of static properties.
@@ -28,13 +27,13 @@ namespace Example;
class Singleton
{
-
+
/**
* The singleton instance
* @var Singleton
*/
private static $instance;
-
+
/**
* Get the instantiated singleton, or create it if it hasn't been instantiated yet.
* @return Singleton
@@ -44,7 +43,7 @@ class Singleton
// static::$instance =?? new static();
// The double ?'s is a null-coalesce operator. There's a link about it below.
static::$instance = static::$instance ?? new static();
-
+
return static::$instance;
}
@@ -57,12 +56,12 @@ To give a little functionality to our freshly baked Singleton we add these three
```php
private $word = "Pineapple";
-
+
public function getWord(): string {
// PHP_EOL is a constant for a new line (\r\n) or whichever your OS uses.
return $this->word . PHP_EOL;
}
-
+
public function setWord(string $word): void {
$this->word = $word;
}
diff --git a/src/pages/404.tsx b/src/pages/404.tsx
index 5d1fa25..788f166 100644
--- a/src/pages/404.tsx
+++ b/src/pages/404.tsx
@@ -1,14 +1,16 @@
import React from "react"
-import Layout from "../components/Layout"
-import SEO from "../components/SEO"
+import { Layout } from "../components/Layout"
+import { SEO } from "../components/SEO"
-const NotFoundPage = () => (
-
-
-
NOT FOUND
-
You just hit a route that doesn't exist... the sadness.
-
-)
+function NotFoundPage() {
+ return (
+
+
+
NOT FOUND
+
You just hit a route that doesn't exist... the sadness.
+
+ )
+}
export default NotFoundPage
diff --git a/src/pages/docs.tsx b/src/pages/docs.tsx
index 249bac7..d7e9399 100644
--- a/src/pages/docs.tsx
+++ b/src/pages/docs.tsx
@@ -1,13 +1,15 @@
import React from "react"
-import DocsLayout from "../components/DocsLayout"
-import SEO from "../components/SEO"
+import { DocsLayout } from "../components/DocsLayout"
+import { SEO } from "../components/SEO"
-const DocsPage = () => (
-
-
- the docs
-
-)
+function DocsPage() {
+ return (
+
+
+ the docs
+
+ )
+}
export default DocsPage
diff --git a/src/pages/docs/something.md b/src/pages/docs/something.md
deleted file mode 100644
index 5570c7f..0000000
--- a/src/pages/docs/something.md
+++ /dev/null
@@ -1 +0,0 @@
-# Hello
\ No newline at end of file
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index e8c1021..589c218 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,19 +1,20 @@
import React from "react"
import { Link } from "gatsby"
-import Layout from "../components/Layout"
-import SEO from "../components/SEO"
+import { Layout } from "../components/Layout"
+import { SEO } from "../components/SEO"
-const IndexPage = () => (
-
-
-
Hi people
-
Welcome to your new Gatsby site.
-
Now go build something great.
-
-
- Go to page 2
-
-)
+function IndexPage() {
+ return (
+
+
+
Hi people
+
Welcome to your new Gatsby site.
+
Now go build something great.
+
+ Go to page 2
+
+ )
+}
export default IndexPage
diff --git a/src/templates/languagePost.tsx b/src/templates/languagePost.tsx
index a0c94b8..4f83889 100644
--- a/src/templates/languagePost.tsx
+++ b/src/templates/languagePost.tsx
@@ -1,10 +1,10 @@
import React from "react"
import { graphql } from "gatsby"
-import SEO from "../components/SEO"
-import DocsLayout from "../components/DocsLayout"
+import { SEO } from "../components/SEO"
+import { DocsLayout } from "../components/DocsLayout"
// @todo maybe find alternative type for data
-const LanguagePost = ({ data }: any) => {
+function LanguagePost({ data }: any) {
const { html, frontmatter } = data.file.post
console.log(data)
return (
diff --git a/typings.d.ts b/typings.d.ts
index 677e3d5..8aab02b 100644
--- a/typings.d.ts
+++ b/typings.d.ts
@@ -1 +1,2 @@
declare module "*.svg"
+declare module "*.png"