mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-12-20 03:14:06 -06:00
Add group component
This commit is contained in:
parent
c238dd16d9
commit
7ad5c16495
23
quartz/components/Group.tsx
Normal file
23
quartz/components/Group.tsx
Normal file
@ -0,0 +1,23 @@
|
||||
import { concatenateResources } from "../util/resources"
|
||||
import { QuartzComponent, QuartzComponentConstructor, QuartzComponentProps } from "./types"
|
||||
|
||||
interface GroupConfig {
|
||||
components: QuartzComponent[]
|
||||
}
|
||||
|
||||
export default ((config: GroupConfig) => {
|
||||
const Group: QuartzComponent = (props: QuartzComponentProps) =>
|
||||
config.components
|
||||
.map((c: QuartzComponent) => ({ component: c }))
|
||||
.map((it: { component: QuartzComponent} ) => (<it.component {...props} />))
|
||||
|
||||
|
||||
Group.afterDOMLoaded = concatenateResources(
|
||||
...config.components.map((c) => c.afterDOMLoaded),
|
||||
)
|
||||
Group.beforeDOMLoaded = concatenateResources(
|
||||
...config.components.map((c) => c.beforeDOMLoaded),
|
||||
)
|
||||
Group.css = concatenateResources(...config.components.map((c) => c.css))
|
||||
return Group
|
||||
}) satisfies QuartzComponentConstructor<GroupConfig>
|
||||
@ -23,6 +23,7 @@ import Breadcrumbs from "./Breadcrumbs"
|
||||
import Comments from "./Comments"
|
||||
import Flex from "./Flex"
|
||||
import ConditionalRender from "./ConditionalRender"
|
||||
import Group from "./Group"
|
||||
|
||||
export {
|
||||
ArticleTitle,
|
||||
@ -50,4 +51,5 @@ export {
|
||||
Comments,
|
||||
Flex,
|
||||
ConditionalRender,
|
||||
Group
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user