Giter VIP home page Giter VIP logo

storyblok-demo-default's Introduction

Storyblok Default Demo

This frontend is shown when creating a new example space in your Storyblok account. It is built using Nuxt 3 and TailwindCSS. Feel free to explore and reuse the code.

Setup

  • Install the dependencies:
npm install
  • Install mkcert on your system: The installation instructions for macOS, Windows and Linux can be found in the mkcert Github repository.

  • Change the following in your package.json: nuxt dev -> nuxt dev --https --ssl-cert localhost.pem --ssl-key localhost-key.pem

  • Create a valid certificate by running the following command in your project folder:

mkcert localhost
  • Run your project:
npm run dev

Your project will now be served on https://localhost:3000.

Have a look at the Nuxt 3 deployment documentation for further information.

Some particularities to be aware of

Access token and path via URL parameters

For our particular use case, we needed one deployed frontend that could be used to display a large quantity of demo spaces that are generated on the fly. Therefore, the access tokens of these spaces are passed via URL parameters. In a more typical scenario, you would probably want to hardcode the access token or store it as an environment variable (the latter being the recommended approach). The changes you have to make are documented as comments in the following files:

  • nuxt.config.js
  • layouts/default.vue
  • pages/[...slug].vue

Internationalization and language detection

For the purpose of being used in product demos, it has to be possible that any language can be added in the internationalization settings in Storyblok and is detected automatically in the frontend subsequently. In order to ensure this, all currently active language codes are retrieved from the Storyblok space. When fetching a particular story based on the current route, it is checked whether any of the currently active language codes matches the first part of the route. For example, if the current route was https://localhost:3000/de/home and German had been added as a language, de would get added as the language parameter in the API request for the home story. You can take a look at the getLanguage composable to see how it works.

In a real-world project, you would usually know which languages are used on the website, allowing you to choose a simpler approach (e.g. a folder-based one).

Setting a real path for stories

The main drawback of handling internationalization as described above is that field-level translation will not working when setting a real path for certain stories (e.g. / instead of home). When setting a real path, the language code is no longer part of the route, thus making it impossible to detect.

storyblok-demo-default's People

Contributors

alexjoverm avatar alvarosabu avatar lisilinhart avatar manuelschroederdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

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.