Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/boenfu/hexo-renderer-react-styled

Hexo renderer by react & styled-components
https://github.com/boenfu/hexo-renderer-react-styled

hexo hexo-renderer react styled-components

Last synced: 11 days ago
JSON representation

Hexo renderer by react & styled-components

Awesome Lists containing this project

README

        

# hexo-renderer-react-styled

😎 wow ~ use react + style-components write your hexo theme

## Features

- zero configure
- import sub components directly
- file extensions support `.tsx` `.ts` `.jsx` `.svg` `.css`
- auto transform svg source file to react component by [svgr](https://github.com/gregberge/svgr)

## Example

- theme directory example

```bash
└── your-theme
β”œβ”€β”€ layout
β”‚ β”œβ”€β”€ components
β”‚ β”‚ β”œβ”€β”€ header.tsx
β”‚ β”‚ └── index.ts
β”‚ β”œβ”€β”€ index.tsx
β”‚ └── layout.tsx
└── tsconfig.json
```

- page view example

```tsx
// index.tsx
import React, {FC} from 'react';
import styled from 'styled-components';
// import directly
import {Posts} from './components';
// see usage/svg
import Github from './icons/github.svg';
// see usage/css
import MarkdownCSS from './css/markdown.css';

const Index = styled.div`
// ... css
`;

const Main = styled.div`
// ... css
${MarkdownCSS}
`;

const Sidebar = styled.div`
// ... css
`;

// Perfect type hint
const Component: FC = props => {
const {page} = props;

return (








);
};

export default Component;
```

**Try it ?πŸ™Š**

## Usage

### Installation:

```bash
yarn add hexo-renderer-react-styled # Or npm install --save hexo-renderer-react-styled
```

**That's all, hexo will auto load**

### SVG

If need import ".svg" file, add module declare file for your project.

```ts
declare module '*.svg' {
const fc: (props: any) => any;
export default fc;
}
```

svgComplier will replace `#000`/`#000000` to `currentColor` by default

### CSS

If need import ".css" file, add module declare file for your project.

```ts
declare module '*.css' {
const text: string;
export default text;
}
```

usage example

```ts
import markdownCSS from './markdown.css';

const MarkdownContent = styled.div`
${markdownCSS}
`;
```

## Who Use

- [hexo-theme-wanghu](https://github.com/boenfu/hexo-theme-wanghu) - β€œεΏ˜δΉŽβ€οΌˆ δ»ΏηŸ₯乎主钘 οΌ‰

## License

MIT License.