-
Notifications
You must be signed in to change notification settings - Fork 182
Open
Description
Currently the $page->getContent()
function only allows markdown files to be rendered.
Why?
I've got a content like this:
---
extends:
web: _layouts.post
amp: _layouts.amp
feed: _partials.feed-item
title: My First Blog Post
date: 2017-03-23
section: content
---
This post is *profoundly* interesting.
@include('_partials.image', ['src' => 'https://source.unsplash.com/random', 'alt' => ''])
If you curious about what does the _partials.image.blade.php
does, it just switching between img
tag and amp-img
tag for amp-html templates.
@switch($page->_meta->extending)
@case('instant-articles')
<figure data-feedback="fb:likes, fb:comments">
<img src="{{ $src }}" alt="{{ $alt }}">
@if($caption ?? false)
<figcaption>
<h1>{{ $caption }}</h1>
</figcaption>
@endif
</figure>
@break
@case('amp')
<figure>
<amp-img src="{{ $src }}" alt="{{ $alt }}"></amp-img>
@if($caption ?? false)
<figcaption>Caption</figcaption>
@endif
</figure>
@break
@default
<figure>
<img src="{{ $src }}" alt="{{ $alt }}">
@if($caption ?? false)
<figcaption>Caption</figcaption>
@endif
</figure>
@endswitch
Problems
The problem arise when I want to output the article into feed. When I use $page->getContent()
, it doesn't render the blade directive.
feed.blade.json
{
"user_comment": "This is a JSON Feed. A modern alternative of RSS.",
"version": "https://jsonfeed.org/version/1",
"title": "{{ $page->blogTitle }} Feed",
"home_page_url": "{{ $page->baseUrl }}",
"feed_url": "{{ $page->getUrl() }}",
"items": {!! $posts->map(function($item) {
return [
'id' => $item->getUrl('web'),
'content_html' => $item->getContent()
];
})->values() !!}
}
Leaving the code like this:
feed.json
{
"user_comment": "This is a JSON Feed. A modern alternative of RSS.",
"version": "https://jsonfeed.org/version/1",
"title": "Imam Susanto Blog Feed",
"home_page_url": "http://localhost:3000",
"feed_url": "http://localhost:3000/feed.json",
"items": [
{
"id": "http://localhost:3000/blog/my-first-blog-post",
"content_html":
"<p>This post is <em>profoundly</em> interesting.</p>\n<p>@include('_partials.image', ['src' => '<a href=\"https://source.unsplash.com/random\">https://source.unsplash.com/random</a>', 'alt' => ''])</p>"
},
{
"id": "http://localhost:3000/blog/my-second-blog-post",
"content_html":
"<p>This post is <em>profoundly</em> interesting.</p>\n<p>@include('_partials.image', ['src' => '<a href=\"https://source.unsplash.com/random\">https://source.unsplash.com/random</a>', 'alt' => ''])</p>"
}
]
}
Is it possible that blade files also included? So that files like post.blade.json
or post.blade.xml
will get the same treatment.
Thank you for reading this issue. Hope it helps.
Metadata
Metadata
Assignees
Labels
No labels