mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 09:15:58 +02:00
refact: prefer function over lambdas
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import React, { PropsWithChildren } from "react"
|
||||
import * as SC from "./styles"
|
||||
|
||||
const Container = ({
|
||||
function Container({
|
||||
children,
|
||||
...restProps
|
||||
}: PropsWithChildren<{}>): JSX.Element => (
|
||||
<SC.ContainerWrapper {...restProps}>{children}</SC.ContainerWrapper>
|
||||
)
|
||||
}: PropsWithChildren<{}>): JSX.Element {
|
||||
return <SC.ContainerWrapper {...restProps}>{children}</SC.ContainerWrapper>
|
||||
}
|
||||
|
||||
export default Container
|
||||
|
||||
@@ -12,7 +12,7 @@ import DocsSidebar from "../DocsSidebar"
|
||||
import Footer from "../Footer"
|
||||
import * as SC from "./styles"
|
||||
|
||||
const DocsLayout = ({ children }: PropsWithChildren<{}>) => {
|
||||
function DocsLayout({ children }: PropsWithChildren<{}>) {
|
||||
const data = useStaticQuery(graphql`
|
||||
query {
|
||||
site {
|
||||
|
||||
@@ -55,7 +55,7 @@ const ALL_DOCS = graphql`
|
||||
}
|
||||
`
|
||||
|
||||
const plantTree = (item: IFileOrFolder) => {
|
||||
function plantTree(item: IFileOrFolder) {
|
||||
if (item.type === "file") {
|
||||
return (
|
||||
<SC.PageLink to={item.path} activeClassName="active">
|
||||
@@ -84,7 +84,7 @@ function Folder({ item }: { item: IFolder }) {
|
||||
)
|
||||
}
|
||||
|
||||
const DocsSidebar = () => {
|
||||
function DocsSidebar() {
|
||||
const docs = useStaticQuery<IAllDocsQuery>(ALL_DOCS)
|
||||
const tree = useBuildTree(docs)
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ import {
|
||||
IFileQuery,
|
||||
} from "./index"
|
||||
|
||||
const traverse = (
|
||||
function traverse(
|
||||
[head, ...tail]: string[],
|
||||
basePath = "/docs"
|
||||
): IFileOrFolder => {
|
||||
): IFileOrFolder {
|
||||
const path = basePath + "/" + head
|
||||
const isFile = !tail.length
|
||||
if (isFile) {
|
||||
@@ -30,7 +30,7 @@ const traverse = (
|
||||
}
|
||||
}
|
||||
|
||||
const generateFolder = ({
|
||||
function generateFolder({
|
||||
title,
|
||||
path,
|
||||
targets,
|
||||
@@ -38,7 +38,7 @@ const generateFolder = ({
|
||||
title: IFolder["title"]
|
||||
path: IFile["path"]
|
||||
targets: IFolder[]
|
||||
}): IFolder => {
|
||||
}): IFolder {
|
||||
const children = join(R.chain(target => target.children, targets))
|
||||
|
||||
return {
|
||||
@@ -49,13 +49,13 @@ const generateFolder = ({
|
||||
}
|
||||
}
|
||||
|
||||
const generateFile = ({
|
||||
function generateFile({
|
||||
title,
|
||||
path,
|
||||
}: {
|
||||
title: IFile["title"]
|
||||
path: IFile["path"]
|
||||
}): IFile => {
|
||||
}): IFile {
|
||||
return {
|
||||
title,
|
||||
path,
|
||||
@@ -63,7 +63,7 @@ const generateFile = ({
|
||||
}
|
||||
}
|
||||
|
||||
const join = ([head, ...tail]: IFileOrFolder[]): IFileOrFolder[] => {
|
||||
function join([head, ...tail]: IFileOrFolder[]): IFileOrFolder[] {
|
||||
if (!head) return []
|
||||
|
||||
const [similarFs, remaining] = R.partition(
|
||||
|
||||
@@ -5,10 +5,10 @@ export interface DocsSidebarSectionProps {
|
||||
readonly title: string
|
||||
}
|
||||
|
||||
const DocsSidebarSection = ({
|
||||
function DocsSidebarSection({
|
||||
title,
|
||||
children,
|
||||
}: PropsWithChildren<DocsSidebarSectionProps>) => {
|
||||
}: PropsWithChildren<DocsSidebarSectionProps>) {
|
||||
return (
|
||||
<div>
|
||||
<SC.SidebarTitle>{title}</SC.SidebarTitle>
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from "react"
|
||||
import * as SC from "./styles"
|
||||
import Container from "../Container"
|
||||
|
||||
const Footer = () => {
|
||||
function Footer() {
|
||||
return (
|
||||
<SC.FooterWrapper>
|
||||
<Container>
|
||||
|
||||
@@ -16,7 +16,7 @@ import * as SC from "./styles"
|
||||
import Scrollbar from "react-perfect-scrollbar"
|
||||
import "react-perfect-scrollbar/dist/css/styles.css"
|
||||
|
||||
const Layout = ({ children }: PropsWithChildren<{}>) => {
|
||||
function Layout({ children }: PropsWithChildren<{}>) {
|
||||
const data = useStaticQuery(graphql`
|
||||
query {
|
||||
site {
|
||||
|
||||
@@ -10,13 +10,13 @@ interface SEOProps {
|
||||
readonly title: string
|
||||
}
|
||||
|
||||
const SEO = ({
|
||||
function SEO({
|
||||
description,
|
||||
lang = "en",
|
||||
meta = [],
|
||||
keywords = [],
|
||||
title,
|
||||
}: SEOProps) => {
|
||||
}: SEOProps) {
|
||||
const { site } = useStaticQuery(
|
||||
graphql`
|
||||
query {
|
||||
|
||||
@@ -11,7 +11,7 @@ function MenuItem({ children, to }: PropsWithChildren<{ to: string }>) {
|
||||
)
|
||||
}
|
||||
|
||||
const Sidebar = () => {
|
||||
function Sidebar() {
|
||||
return (
|
||||
<SC.SidebarWrapper>
|
||||
<SC.Logo src={logo} />
|
||||
|
||||
Reference in New Issue
Block a user