jmheretik / kirby-vue-starterkit

Kirby + Vue.js
92 stars 2 forks source link
api json kirby kirby-starterkit nuxt template vue

Kirby + Vue.js starterkit

This project aims to be a starting point for people wanting to use Vue.js with Kirby as headless CMS.

It's a simple, zero-setup, 1:1 port of the Kirby 3 starterkit frontend (snippets, templates and their corresponding JS/CSS) to Vue.js single file components.

You can benefit from all the standard tools used in modern frontend development. For more details visit Vue CLI.


The frontend comes in 3 different flavours:

  1. API - the vue-api folder. The content is fetched using the Kirby's built-in REST API. This was made like a proof-of-concept project and needed a few workarounds to work properly.

  2. JSON - the vue-json folder. Here, the content is fetched using JSON content representations, which proved to be a much more suitable approach for now.

  3. NUXT - the vue-nuxt folder. Finally, this project too uses JSON content representations to fetch the content but also includes many of the goodies Nuxt.js has to offer (including the static site generation)!

Demo

ℹ️ inspect the network traffic to see the differences

Requirements

Setup

  1. choose the frontend variant that suits you best
  2. cd into its folder
  3. run npm install

Usage

Frontend

✔️ Make sure to follow the README in the project folder of your chosen variant.

Backend

Out of the box the backend is automatically served while developing using the PHP built-in development server.

Multi-language site

Simply follow this guide on how to enable multiple languages in Kirby: https://getkirby.com/docs/guide/languages/introduction, and don't forget to provide some way for your users to switch between those languages :)

ℹ️ I recommend adding new languages using the panel because of this nifty little detail:

The Panel automatically renames all existing content and file meta data files and includes the language extension.

Config

All Kirby related config is found in the kirby.config.js file:

Deploying

Deploy the contents of kirby folder to the production server.

⚠️ if you're also injecting into Kirby, make sure you build the Vue app first so the kirby folder contains everything needed

⚠️ don't forget to set debug and allowInsecure (if you're deploying to https) to false in kirby/site/config/config.php

Notes

I tried to make as little modifications to the original Starterkit as possible and package it all in an optional non-intrusive Kirby plugin. However, here is a list of all the changes made to the original starterkit: