Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/georgesboris/gatsby-typescript-starter

Simple Gatsby starter with Typescript support.
https://github.com/georgesboris/gatsby-typescript-starter

Last synced: about 2 months ago
JSON representation

Simple Gatsby starter with Typescript support.

Awesome Lists containing this project

README

        

# Gatsby Typescript Starter

Simple gatsby starter with Typescript support.

## Component folder structure by example

```
/components
/components
/GlobalComponent
GlobalComponent.tsx

/ComponentA
/components
/ComponentASubComponent
ComponentASubComponent.tsx
ComponentA.tsx

/ComponentB
ComponentB.tsx
```

In the example above:

- `ComponentA` could import `ComponentASubComponent`
- `ComponentB` could **not** import `ComponentASubComponent`
- Both components could import `GlobalComponent`

```
/ComponentA
/components
/images
ComponentA.tsx
ComponentA.css
```

Each component folder should hold all it's related files including styles and other assets. There are almost no exceptions for sharing assets globally, so thread carefully.

## Component file structure by example

```javascript
/**
* Imports
*/

import React from 'react'

/**
* Types
*/

type Props = {
title: string
subtitle?: string
}

/**
* Styles (if using CSS-in-JS)
*/

const Wrapper = styled.section`
display: flex;
`

const Title = styled.h1`
font-weight: bold;
`

const Subtitle = styled.p`
font-size: 0.9em;
`

/**
* Main Component
*/

export default function MyComponent({ title, subtitle }: Props) {
return (

{title}
{subtitle && {subtitle}}

)
}

```