Coder Social home page Coder Social logo

astro-sb-starter's Introduction

The repository is based on new Project structure on Storyblok. You can use it as a template to start your own project with Storyblok, Astro and Netlify.

Usage

If you are first-time user of Storyblok, read the Getting Started guide to get a project ready in less than 5 minutes.

For further information on @storyblok/astro check the repository

Installation

Here the code to astro.config.mjs, replace the STORYBLOK_TOKEN_ACCESS in your .env file

import { defineConfig } from "astro/config";
import storyblok from "@storyblok/astro";
import tailwind from "@astrojs/tailwind";
import netlify from "@astrojs/netlify/functions";
import { loadEnv } from "vite";
const { PUBLIC_ENV, STORYBLOK_TOKEN_ACCESS} = loadEnv(import.meta.env.MODE, process.cwd(), "");
import basicSsl from '@vitejs/plugin-basic-ssl'

export default defineConfig({
  output: PUBLIC_ENV === 'preview' ? 'server' : 'static',
  adapter: PUBLIC_ENV === 'preview' ? netlify() : undefined,
  integrations: [
    storyblok({
      accessToken: STORYBLOK_TOKEN_ACCESS,
      bridge: PUBLIC_ENV !== 'production',
      components: {
        page: "storyblok/Page",
        feature: "storyblok/Feature",
        grid: "storyblok/Grid",
        teaser: "storyblok/Teaser",
      },
    }),
    tailwind(),
  ],
  vite: {
    server: {
      https: true,
    },
    plugins: [basicSsl()],
  },
});

You can check the .env.example

PUBLIC_ENV=preview
STORYBLOK_TOKEN_ACCESS=<your token access>

Dynamic Slug

ATTENTION : In this repository I'm using [...path].astro instead of [slug].astro.

In my opinion, using [...path].astro provide more flexibility with Storyblok, for further informations. Briefly, with [...path] you can generate any path depth you need.

Development

In this repository we use @vitejs/plugin-basic-ssl so the application will be launch at https://127.0.0.1:3000/ by default and you should not have any problem to embedded your app in Storyblok.

Alternative method

If you have some issue, you can also try this :

Use this command npm run dev-sb, in order to launch the application and the proxy so you can embedded your localhost in Storyblok

"dev-sb": "astro dev & local-ssl-proxy --source 3010 --target 3000 --cert localhost.pem --key localhost-key.pem"

If you haven't set any https://localhost:3010 yet, you need to use mkcert :

Deployment

What the purpose of PUBLIC_ENV ?

If you deploy your project in static for production, you won't see any change from Storyblok. If you set up one environment for production and another one for the preview mode which will be in SSR you can check your change before deploying in production.

In this repository I use Netlify but you can use any other adapter instead

astro-sb-starter's People

Contributors

mmackz avatar

Stargazers

 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.