Giter Site home page Giter Site logo

reimerwilliam / silverstripe-headless-rest-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from northcreation-agency/silverstripe-headless-rest-api

0.0 1.0 0.0 29 KB

A customizable rest api to Silverstripe for usage with front end frameworks such as Nuxt or Next JS.

License: BSD 3-Clause "New" or "Revised" License

JavaScript 11.19% PHP 88.81%

silverstripe-headless-rest-api's Introduction

Silverstripe CMS Headless rest api

This module adds a customizable rest api to Silverstripe for usage with front end frameworks such as Nuxt or Next JS. It adds three end points for fetching navigation and other common fields, site tree and url specific fields.

Using with Nuxt or Next JS

Tutorial: Headless Silverstripe with Next.JS

Tutorial: Headless Silverstripe with Nuxt.JS

Requirements

  • SilverStripe ^4.0

Installation

Add the following section to your composer.json

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/olivernorden-silverstripe/silverstripe-headless-rest-api"
        }
    ],

Run

composer require olivernorden/silverstripe-headless-rest

Note: When you have completed your module, submit it to Packagist or add it as a VCS repository to your project's composer.json, pointing to the private repository URL.

Default api end points

  1. /headless-api/v1/url/<url> will return all fields pertaining to .
  2. /headless-api/v1/common will return all fields pertaining to navigation and other common fields.
  3. /headless-api/v1/sitetree will return all pages with their fields.

Adding more fields to api

You can add more fields to any of the api end points.

/headless-api/v1/url/

#app/_config/headless-fields.yml
---
Name: custom-headless-rest-fields
---
SilverStripe\CMS\Model\SiteTree:
  headlessFields:
    Title: Title
    Content: Content
    ClassName: ClassName
  

/headless-api/v1/common

#app/_config/headless-common-fields.yml
---
Name: custom-headless-rest-common-fields
---
OliverNorden\HeadlessRest\HeadlessRestController:
    headlessCommonFields:
        Navigation:
            fields:
                Lead: Lead
        SiteConfig:
            fields:
                TagLine: TagLine

/headless-api/v1/sitetree

#app/_config/headless-sitetree-fields.yml
---
Name: custom-headless-rest-sitetree-fields
---
OliverNorden\HeadlessRest\HeadlessRestController:
    headlessSiteTreeFields:
      AbsoluteURL: getAbsoluteURL

Maintainers

Bugtracker

Bugs are tracked in the issues section of this repository. Before submitting an issue please read over existing issues to ensure yours is unique.

If the issue does look like a new bug:

  • Create a new issue
  • Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots and screencasts can help here.
  • Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, Operating System, any installed SilverStripe modules.

Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.

Development and contribution

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.

silverstripe-headless-rest-api's People

Contributors

knirb avatar oliver-norden avatar reimerwilliam avatar

Watchers

James Cloos 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.