Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ALT-1508] feat: add gatsby project to templates and add readmes for templates and test-apps #896

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions examples/gatsby/gatsby-spa/.env.development.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Rename this file to .env.development and fill in the values for the following environment variables
GATSBY_CTFL_ENVIRONMENT=
GATSBY_CTFL_SPACE=
GATSBY_CTFL_ACCESS_TOKEN=
GATSBY_CTFL_PREVIEW_ACCESS_TOKEN=
GATSBY_CTFL_EXPERIENCE_TYPE=
GATSBY_CTFL_DOMAIN=
4 changes: 4 additions & 0 deletions examples/gatsby/gatsby-spa/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
.cache/
public
src/gatsby-types.d.ts
63 changes: 63 additions & 0 deletions examples/gatsby/gatsby-spa/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Studio Experiences with Gatsby single page application example

## 🚀 Enabling Gatsby with Experiences
1. **Update ExperienceSlugExample.tsx**

Go to `ExperienceSlugExample.tsx` and fill out the following two consts

```
const slug = ''
const localeCode = '';
```

2. **Update env.local.example for useContentfulClient.ts**

Go to `.env.development.example` and fill out the following fields and rename the file to `.env.development`

```
GATSBY_CTFL_ENVIRONMENT=
GATSBY_CTFL_SPACE=
GATSBY_CTFL_ACCESS_TOKEN=
GATSBY_CTFL_PREVIEW_ACCESS_TOKEN=
GATSBY_CTFL_EXPERIENCE_TYPE=
GATSBY_CTFL_DOMAIN=
```

3. **Create the Experience in the Contentful Experienecs UI**

In the settings tab of Experiences, ensure that your Slug field matches the slug in step 1. Save your changes and publish to see this Gatsby project hooked up with Contentful Experiences.
Comment on lines +26 to +28
Copy link
Contributor

@primeinteger primeinteger Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These steps may need to mention what Content Preview URL to configure. I can't figure it out. I tried:

  • http://localhost:8000 -> shows the gatsby index page (not studio-enabled)
  • http://localhost:8000/{entry.fields.slug} -> shows the 404 page (even though I hardcoded the slug variable in ExperienceSlugExample.tsx to match the slug of my experience and published it)
    Screenshot 2025-01-09 at 9 29 18 AM
    Screenshot 2025-01-09 at 9 28 57 AM

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the README to make it work properly


## 🚀 Quick start

1. **Create a Gatsby site.**

Use the Gatsby CLI to create a new site, specifying the minimal TypeScript starter.

```shell
# create a new Gatsby site using the minimal TypeScript starter
npm init gatsby -- -ts
```

2. **Start developing.**

Navigate into your new site’s directory and start it up.

```shell
cd my-gatsby-site/
npm run develop
```

3. **Open the code and start customizing!**

Your site is now running at http://localhost:8000!

Edit `src/pages/index.tsx` to see your site update in real-time!

4. **Learn more**

- [Documentation](https://www.gatsbyjs.com/docs/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
- [Tutorials](https://www.gatsbyjs.com/docs/tutorial/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
- [Guides](https://www.gatsbyjs.com/docs/how-to/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
- [API Reference](https://www.gatsbyjs.com/docs/api-reference/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
- [Plugin Library](https://www.gatsbyjs.com/plugins?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
- [Cheat Sheet](https://www.gatsbyjs.com/docs/cheat-sheet/?utm_source=starter&utm_medium=readme&utm_campaign=minimal-starter-ts)
15 changes: 15 additions & 0 deletions examples/gatsby/gatsby-spa/gatsby-config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { GatsbyConfig } from "gatsby"

const config: GatsbyConfig = {
siteMetadata: {
title: `gatsby-spa`,
siteUrl: `https://www.yourdomain.tld`,
},
// More easily incorporate content into your pages through automatic TypeScript type generation and better GraphQL IntelliSense.
// If you use VSCode you can also use the GraphQL plugin
// Learn more at: https://gatsby.dev/graphql-typegen
graphqlTypegen: true,
plugins: [],
}

export default config
Loading
Loading