Skip to main content

Components

Do you have multiple templates and you want to share components between these templates? Create a /components directory in the root of your deck. Then, you can import the components as usual.

mkdir components
DECK-NAME/โ”‚   ...โ”œโ”€โ”€ components/โ”‚   โ””โ”€โ”€ Title.jsโ”œโ”€โ”€ templates/โ”‚   โ”œโ”€โ”€ blog-post.jsโ”‚   โ””โ”€โ”€ home.jsโ”‚   ...

Here is an example:

components/Title.js
import React from "react";
export function Title(props) {  return <h1 {...props} />;}
templates/home.js
import React from "react";import { Title } from "../components/Title";
export default function HomeTemplate({ variables })) {  return <Title>{variables.title}</Title>;}