mirror of
https://github.com/Stone-Red-Code/website.git
synced 2026-09-04 17:25:59 +02:00
feat(resources): remove intro from language home
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { graphql, useStaticQuery } from "gatsby"
|
||||
import sort from "ramda/es/sort"
|
||||
import React, { FC, HTMLAttributes, memo } from "react"
|
||||
import React, { FC, HTMLAttributes, memo, useMemo } from "react"
|
||||
import "react-perfect-scrollbar/dist/css/styles.css"
|
||||
import { IAllResourcesQuery, IFileOrFolder, IFolder } from "../../types"
|
||||
import { getPath, humanize } from "../../utils"
|
||||
@@ -47,17 +47,30 @@ function plantTree(item: IFileOrFolder, single?: boolean) {
|
||||
|
||||
const Language = memo(
|
||||
({ item, single }: { item: IFolder; single: boolean }) => {
|
||||
const children = useMemo(() => {
|
||||
if (single) {
|
||||
return item.children.filter((child) => {
|
||||
const [, , , title] = child.title.split("/")
|
||||
return title !== "intro"
|
||||
})
|
||||
}
|
||||
|
||||
return item.children
|
||||
}, [item.children, single])
|
||||
|
||||
return (
|
||||
<SC.TreeWrapper>
|
||||
{!single && <SC.LanguageLabel>{humanize(item.title)}</SC.LanguageLabel>}
|
||||
<SC.Children>
|
||||
{item.children.map((node) => plantTree(node))}
|
||||
</SC.Children>
|
||||
<SC.Children>{children.map((node) => plantTree(node))}</SC.Children>
|
||||
</SC.TreeWrapper>
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
function sortTree(tree: IFileOrFolder[]) {
|
||||
return sort((a, b) => a.title.localeCompare(b.title), tree)
|
||||
}
|
||||
|
||||
interface IResourcesList extends HTMLAttributes<HTMLDivElement> {
|
||||
relativeDirectory?: string
|
||||
}
|
||||
@@ -81,7 +94,7 @@ export const ResourcesList: FC<IResourcesList> = (props) => {
|
||||
}
|
||||
|
||||
const tree = useBuildTree(filteredResources)
|
||||
const sortedTree = sort((a, b) => a.title.localeCompare(b.title), tree)
|
||||
const sortedTree = sortTree(tree)
|
||||
const isSingle = Boolean(props.relativeDirectory)
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user