Code Monkey home page Code Monkey logo

gatsbyjs-multilanguage-website's Introduction

A Gatsby Website using Storyblok

This is the demo project for the step by step guide for Gatsby and Storyblok.

Demo: https://gatsby-multilanguage-website.vercel.app/

Build Setup

# install dependencies
$ npm install # Or yarn install

# serve with hot reload at localhost:8000
$ npm run develop # or yarn dev

Setup

  1. Register at Storyblok for free.
  2. Duplicate Example Space by clicking this link: https://app.storyblok.com/#!/build/95016
  3. Follow our Gatsby Storyblok Guide

For detailed explanation on how things work, checkout the Gatsby docs and for the whole Setup you can have a look at our step by step guide for Gatsby and Storyblok

Add Content

The following content structure is needed for this boilerplate.

Content

  • Home (page)
  • en (folder)
    • settings (settings)
    • blog (folder)
      • first post (blogpost)
  • de (folder)
    • home (page)
    • settings (settings)
    • blog (folder)
      • erster eintrag (blogpost)
  • authors (folder)
    • jane doe (author)

gatsbyjs-multilanguage-website's People

Contributors

christianzoppi avatar lisilinhart avatar schabibi1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gatsbyjs-multilanguage-website's Issues

Enhancement: More complete multilingual implementation

Hi, I have played around with this tutorial and starter, and I can think of a couple of use cases that could be covered.

Although the website is multilingual, the language switcher doesn't work as it should work.
When a language is selected it should redirect to that same page, but translated. Currently, it redirects to the translated homepage, which is less than ideal.

I was able to implement a more complete multilingual system a while ago, but I'm starting from scratch now.

Basically having a single file tree (instead of a folder per language), coupled with translated slugs. Then I expose the translated URLs for each page and use that in the language switcher.

I remember having to do a lot of workarounds back in the days because it wasn't possible to query for those translated slugs in a clean way.

Enhancement

The basic logic of this tutorial has been the same for a couple of years.

Would it be possible to create a new (more advanced) tutorial, that would cover more use cases?

TypeError: Cannot read property 'node' of undefined

Featured Articles not working giving node undefined error. Any idea how can I fix that?

import React from 'react'
import { useStaticQuery, graphql } from "gatsby"
import Link from 'gatsby-link'

export default function ArticleTeaser({ blok }){
  const { articles, authors } = useStaticQuery(graphql`
  query Articles {
    articles: allStoryblokEntry(filter: {field_component: {eq: "blogpost"}}) {
      edges {
        node {
          name
          full_slug
          content
        }
      }
    }
    authors: allStoryblokEntry(filter: {field_component: {eq: "author"}}) {
      edges {
        node {
          name
          uuid
          content
        }
      }
    }
  } 
  `)
  let article = articles.edges.filter(({ node }) => node.full_slug === blok.article.cached_url)
  let content = article.length ? JSON.parse(article[0].node.content) : {};
  let  { author } = content
  let thisAuthor = authors.edges.filter(({ node }) => node.uuid === author)
  let authorContent = thisAuthor.length ? JSON.parse(thisAuthor[0].node.content) : {};

  return (
      <Link to={`/${article[0].node.full_slug}`} className="py-16 block transition hover:opacity-50">
        <img src={content.image} className="pb-10 w-full"/>
        <h2 className="pb-6 text-lg font-bold">{content.title}</h2>
        <p className="pb-6 text-gray-700 leading-loose">{content.intro}</p>
        <p className="text-gray-700">{authorContent.name}</p>
      </Link>
  )
}

Question: How to manage generic translations

Hey,

this is a great tutorial to follow on implementing Storyblok into a Gatsby application. As your goal was to approach a multilingual site: How would you handle component translations in this context? One route could be to do everything in Storyblok but this could become messy pretty fast. Is there a way to add something like i18next on top of the application to manage generic translations?

Thanks,
Johannes

Nav Item not updating without restarting gatsby

Hi, I have been playing around with your repo. It's working smoothly. All editable blocks are working as expect except for the nav_items. Nav Items do not get refreshed unless and until the server is restarted. Can you please let me know what can be the issue here? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.