【问题标题】:Gatsby partial component ShadowingGatsby 部分组件阴影
【发布时间】:2019-10-30 17:27:24
【问题描述】:

我正在尝试将基本组件作为 gatsby-theme 并将此主题用作我的 gatsby 项目的基础是否可行,因此在新项目中,我将隐藏我想要调整的组件随心所欲。

我的问题是我可以隐藏组件的一部分吗?

例如:

import React from "react";
import { ThemeProvider } from "styled-components";
import theme from "./theme";

import {
    TeaserContainer,
    ImageContainer,
    ImageWrapper,
    Title,
    Categories,
    ButtonContainer,
    Artist,
    FullWidthContainer,
    ReadTag
} from "./style.js";

const Teaser = () => {
    return (
        <ThemeProvider theme={theme}>
            <FullWidthContainer>
                <TeaserContainer>
                    <ImageContainer>
                        <ImageWrapper>
                            {
                                <img
                                    src="https://www.gonvillehotel.co.uk/wp-content/uploads/2019/06/Gatsby-Enchanted-Cinema-9.jpg"
                                    alt=""
                                />
                            }
                        </ImageWrapper>
                    </ImageContainer>
                    <Categories>Just categories</Categories>
                    <Title>Title</Title>
                    <ReadTag>Read it</ReadTag>
                    <p>Date</p>
                    <h1>Excerpt</h1>
                    <ButtonContainer>Button</ButtonContainer>
                    <Artist>
                        Submitted by <span>artist</span>
                    </Artist>
                </TeaserContainer>
            </FullWidthContainer>
        </ThemeProvider>
    );
};

export default Teaser;

如何,或者我可以说&lt;Artist&gt;标签,并在新项目中将其删除,而无需重写整个组件?

PS:gatsby 文档上的所有信息/教程都显示了如何隐藏整个组件或更改样式,但我想要的是在组件内删除/添加新标签/内容而不重写整个组件。

【问题讨论】:

    标签: gatsby


    【解决方案1】:

    简短回答:不,你不能。

    该问题的解决方案是将您的组件拆分为多个较小的组件,然后将它们隐藏起来。

    【讨论】:

      猜你喜欢
      • 2021-08-23
      • 2016-07-15
      • 1970-01-01
      • 2011-09-01
      • 1970-01-01
      • 2012-11-03
      • 1970-01-01
      • 2011-01-02
      • 2017-09-17
      相关资源
      最近更新 更多