Skip to content

Server side rendered component to Cradle CMS fetching article data in JSON format.

Notifications You must be signed in to change notification settings

CradleCMS/component-blog-article

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 

Repository files navigation

Blog article data component

Web component for Cradle CMS fetching article data in JSON format.

Setup steps

1. Add component file

Add the file article.liquid to the components folder.

2. JSON-article template

Add a article template article.json.liquid in folder templates for JSON output with the following content:

{% layout 'none' %}
{{ article | json | unescape }}

3. Include component code

Include the component code to the site with tag {% component 'article' %}.

A good practise to dcrease the payload and utilize the browser cache is to include all the components to the same js-file in assets folder and include in the theme with {{ 'components.js.liquid' | asset_url | script_tag }} but please note that one should remove the script tags in the js-component file article.liquid.

4. Use component on site

Use the component at the desired place by including <blog-article> as html tag and the url article containing the articles slug.

<blog-article url="{{ '<article handle with articles slug>' | url }}"></blog-article>

The URL contains the articles slug as it adds the article-context to the handle.

About

Server side rendered component to Cradle CMS fetching article data in JSON format.

Topics

Resources

Stars

Watchers

Forks

Languages