Code Monkey home page Code Monkey logo

umbracocontentapi's Introduction

Nuget (with prereleases)

Umbraco Content Api

The Umbraco Content Api is a package that enables easy integration of Headless Api functionality into your project. The package includes converters for all default Umbraco porperty editors and allows developers to add to and replace them at will.

Out of the box easy to use, full DI support and fast.

Compatibility

  • The Umbraco Content Api 2.0.10 works with Umbraco 8.1.3+
  • The Umbraco Content Api 3.0.0+ works with Umbraco 8.7.0+
  • The Umbraco Content Api 4.0.0+ works with Umbraco 8.14.0+
  • The Umbraco Content Api 9.2.0+ works with Umbraco 9.0.0+

Basic Usage:

  1. Download the package from NuGet
  2. Install the package
  3. Create an UmbracoApiController
  4. Inject the content resolver
  5. Resolve the content
[Route("api/content")]
    public class ContentApiController : UmbracoApiController
    {
        private readonly Lazy<IContentResolver> _contentResolver;
        private readonly IPublishedContentQuery _publishedContent;

        public ContentApiController(
            Lazy<IContentResolver> contentResolver, IPublishedContentQuery publishedContent)
        {
            _contentResolver = contentResolver;
            _publishedContent = publishedContent;
        }

        [HttpGet("{id:guid}")]
        public IActionResult Get(Guid id)
        {
            var content = _publishedContent.Content(id);
            return Ok(_contentResolver.Value.ResolveContent(content));
        }
    }

Creating and adding a converter

To create a converter for your custom editor you need to implement the IConverter interface.

// Converter:
public class SampleConverter : IConverter
    {
        public string EditorAlias => "My.PropertyEditorAlias";

        public object Convert(object value)
        {
            // If the value is already in a json supported format, just return it.
            // Otherwise convert it to a friendly format here.
            return value;
        }
    }
// Composer:
    public void Compose(IUmbracoBuilder builder)
        {
            builder.Converters().Append<SampleConverter>();
        }

Replace an exsisting converter

To replace a converter just add the following to the composer:

builder.Converters()
    .Replace<ConverterToReplace, SampleConverter>();

Sample app login

email: [email protected] password: Password123!

Changelog

2.0.0

Added options params to all converters.

2.0.10

Added grid editor converters.

4.0.0

Added support for Umbraco MediaPicker 3

9.2.0

Added official support for Umbraco 9

Added default BlocklistConverter. The BlockListConverter will use the default converter if no specific converter is specified for the block's element type.

Migrated to Github Actions for package releases.

9.2.1

Reimplemented Legacy mediapicker

umbracocontentapi's People

Contributors

demd avatar jesperordrup avatar jesperbrasmussen avatar najdewit avatar nul800sebastiaan 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.