0.12.0 β€’ Published 2 years ago

hexo-renderer-react-styled v0.12.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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

Example

  • theme directory example
└── your-theme
    β”œβ”€β”€ layout
    β”‚   β”œβ”€β”€ components
    β”‚   β”‚   β”œβ”€β”€ header.tsx
    β”‚   β”‚   └── index.ts
    β”‚   β”œβ”€β”€ index.tsx
    β”‚   └── layout.tsx
    └── tsconfig.json
  • page view example
// 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<HexoComponentProps> = props => {
  const {page} = props;

  return (
    <Index>
      <Main>
        <Posts posts={page.posts} />
      </Main>
      <Sidebar>
        <Github />
      </Sidebar>
    </Index>
  );
};

export default Component;

Try it ?πŸ™Š

Usage

Installation:

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.

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.

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

usage example

import markdownCSS from './markdown.css';

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

Who Use

  • hexo-theme-wanghu - β€œεΏ˜δΉŽβ€οΌˆ δ»ΏηŸ₯乎主钘 οΌ‰

License

MIT License.

0.12.0

2 years ago

0.11.1

2 years ago

0.11.0

2 years ago

0.10.0

2 years ago

0.9.0

2 years ago

0.8.0

2 years ago

0.7.0

2 years ago

0.6.0

2 years ago

0.5.0

2 years ago

0.4.0

2 years ago

0.3.0

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago