1.0.0-rc.23 • Published 11 months ago

@bodiless/gatsby-theme-bodiless v1.0.0-rc.23

Weekly downloads
106
License
Apache-2.0
Repository
github
Last release
11 months ago

@bodiless/gatsby-theme-bodiless

TODO: description

Usage

const gatsbyThemeBodiless = require('@bodiless/gatsby-theme-bodiless');

// TODO: DEMONSTRATE API

Configuration

Gatsby image

Image processing arguments

To override default image processing arguments, use gatsbyImage.sharpArgs option. For example, to override default quality

  {
    resolve: '@bodiless/gatsby-theme-bodiless',
    options: {
      gatsbyImage: {
        sharpArgs: {
          quality: 70,
        },
      },
    },
  },

See gatsby-plugin-sharp doc to get a list of options you can override.

Configure Gatsby Image for default content

  1. Prepare default content data

    Install npm packages containing default content and/or create .json files on site level.

    Example of .json file containing default image data

    {
      "src": "./defaultImage.jpg",
      "alt": "My Test Alt",
      "title": "My Test Title",
      "preset": "fluid_withWebp"
    }

    src - contains path to image. The path can be relative or absolute. When relative path is specified, then the image will be resolved relative to the json. When absolute path is specified, then the image will be resolved relative to site's static directory.

    alt, title - image data provided by Bodiless.

    preset - image preset for which generate image variations.

  2. Configure default content sources

    Option A. (Recommended). Use default content auto-discovery mechanism. Add bodiless.content.json file on site level. Example of file

      [
        "./path/to/default/content/directory1",
        "./path/to/default/content/directory2"
      ]

    Option B. Use site's gatsby-config.js

    // site gatsby-config.js
    
    const {
      createDefaultContentPlugins,
    } = require('@bodiless/gatsby-theme-bodiless/dist/DefaultContent');
    
    module.exports = {
      plugins: {
        // your other plugins
        ...createDefaultContentPlugins(
          './path/to/default/content/directory1',
          './path/to/default/content/directory2'
        )
      }
    }
  3. Add DefaultContentQuery to each page that uses default content

    Open your page index file and extend a list of exported queries with DefaultContentQuery.

      export const query = graphql`
        query($slug: String!) {
          ...YourOtherQuery
          ...DefaultContentQuery
        }
      `;
  4. Use helpers to compose Gatsby Image components

import { useContentFrom } from '@bodiless/core';
import { asBodilessImage } from '@bodiless/components-ui';
import { withDefaultImageContent } from '@bodiless/components';
import {
  GatsbyImagePresets,
  withGatsbyImagePreset,
} from '@bodiless/gatsby-theme-bodiless';

const asEditableImage = withGatsbyImagePreset(GatsbyImagePresets.FluidWithWebp)(asBodilessImage);
const useDefaultImageNode = useContentFrom(['DefaultContent', 'contentful1']);
const Image = withDefaultImageContent(asEditableImage)(useDefaultImageNode)('image')('img');

// jsx
<Image />

Plugins

Robots.txt

gatsby-plugin-robots-txt is leveraged to automatically generate robots.txt for a site. The plugin is enabled by default and will generate the following robots.txt file.

User-agent: *
Allow: /

In order to disable robots.txt plugin, set ROBOTSTXT_ENABLED env variable to '0'

ROBOTSTXT_ENABLED='0'

In order to add sitemap.xml to the generated robots.txt file, set ROBOTSTXT_SITEMAP env variable to your site sitemap.xml

ROBOTSTXT_SITEMAP='https://www.example.com/sitemap.xml'

In order to add host to the generated robots.txt file, set ROBOTSTXT_HOST env variable to your site host

ROBOTSTXT_HOST='https://www.example.com/'

In order to define custom rules in the generated robots.txt, set ROBOTSTXT_POLICY env variable to JSON string containing a list of policies. Format required for policies is described in https://github.com/itgalaxy/generate-robotstxt/tree/65abc04050ee0bb7bc1612163eb5af8c416c6994#usage

ROBOTSTXT_POLICY='[{"userAgent":"*","allow":"/","disallow":"/search","crawlDelay":10}]'

or in your site gatsby-config.js

const policies = [
  {
    userAgent: '*',
    allow: '/',
    disallow: '/search',
    crawlDelay: 10,
  },
];
process.env.ROBOTSTXT_POLICY = JSON.stringify(policies);

CSS compilation

Tailwind CSS compilation is configured and enabled by default. One can disable css compilation by setting BODILESS_TAILWIND_THEME_ENABLED env variable to '0'.

Tailwind CSS compilation is configured using PostCSS approach. gatsby-plugin-postcss is leveraged for this purpose.

Exclude imported CSS from static builds

One can exclude css resources from static build by configuring BODILESS_ADMIN_ONLY_CSS_FILES environment variable. By default, all css resources are included to the static build.

1.0.0-rc.42

11 months ago

1.0.0-rc.41

11 months ago

1.0.0-rc.40

11 months ago

1.0.0-rc.39

11 months ago

1.0.0-rc.38

11 months ago

1.0.0-rc.35

1 year ago

1.0.0-rc.34

1 year ago

1.0.0-rc.37

1 year ago

1.0.0-rc.36

1 year ago

1.0.0-rc.24

1 year ago

1.0.0-rc.28

1 year ago

1.0.0-rc.27

1 year ago

1.0.0-rc.26

1 year ago

1.0.0-rc.25

1 year ago

1.0.0-rc.29

1 year ago

1.0.0-rc.31

1 year ago

1.0.0-rc.30

1 year ago

1.0.0-rc.33

1 year ago

1.0.0-rc.32

1 year ago

1.0.0-rc.23

1 year ago

1.0.0-rc.19

2 years ago

1.0.0-rc.18

2 years ago

1.0.0-rc.20

2 years ago

1.0.0-rc.22

1 year ago

1.0.0-rc.21

2 years ago

1.0.0-rc.17

2 years ago

1.0.0-rc.16

2 years ago

1.0.0-rc.15

2 years ago

1.0.0-rc.9

2 years ago

1.0.0-rc.7

2 years ago

1.0.0-rc.8

2 years ago

1.0.0-rc.5

2 years ago

1.0.0-rc.6

2 years ago

1.0.0-rc.13

2 years ago

1.0.0-rc.12

2 years ago

1.0.0-rc.10

2 years ago

1.0.0-rc.3

2 years ago

1.0.0-rc.4

2 years ago

1.0.0-rc.14

2 years ago

1.0.0-rc.2

2 years ago

1.0.0-rc.1

2 years ago

1.0.0-beta.11

2 years ago

1.0.0-beta.12

2 years ago

1.0.0-beta.10

2 years ago

1.0.0-beta.17

2 years ago

1.0.0-beta.18

2 years ago

1.0.0-beta.15

2 years ago

1.0.0-beta.16

2 years ago

1.0.0-beta.13

2 years ago

1.0.0-beta.14

2 years ago

1.0.0-beta.2

2 years ago

1.0.0-beta.3

2 years ago

1.0.0-beta.4

2 years ago

1.0.0-beta.5

2 years ago

1.0.0-beta.1

2 years ago

1.0.0-beta.6

2 years ago

1.0.0-beta.7

2 years ago

1.0.0-beta.9

2 years ago

0.3.6

2 years ago

0.3.5

2 years ago

0.3.7

2 years ago

0.3.2

2 years ago

0.3.4

2 years ago

0.3.3

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.10

3 years ago

0.1.2

3 years ago

0.2.9

3 years ago

0.2.8

3 years ago

0.2.7

3 years ago

0.2.6

3 years ago

0.2.5

3 years ago

0.2.4

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.72

3 years ago

0.0.71

3 years ago

0.0.70

3 years ago

0.0.69

3 years ago

0.0.68

3 years ago

0.0.67

3 years ago

0.0.66

3 years ago

0.0.65

3 years ago

0.0.64

3 years ago

0.0.63

3 years ago

0.0.62

3 years ago

0.0.61

3 years ago

0.0.60

3 years ago

0.0.59

3 years ago

0.0.58

4 years ago

0.0.57

4 years ago

0.0.56

4 years ago

0.0.55

4 years ago

0.0.54

4 years ago

0.0.53

4 years ago

0.0.52

4 years ago

0.0.51

4 years ago

0.0.50

4 years ago

0.0.49

4 years ago

0.0.48

4 years ago

0.0.47

4 years ago

0.0.45

4 years ago

0.0.46

4 years ago

0.0.44

4 years ago

0.0.43

4 years ago

0.0.41

4 years ago

0.0.42

4 years ago

0.0.40

4 years ago

0.0.39

4 years ago

0.0.38

4 years ago

0.0.37

4 years ago

0.0.36

4 years ago