Skip to content

Render to Frontend with template Markdown or Code #8599

Closed Answered by duncanmcclean
tqt97 asked this question in Q&A
Discussion options

You must be logged in to vote

Hey 👋🏻

I've written a blog post about setting up Torchlight and Bard in Statamic, if you're interested.

If you'd prefer to use something local (eg. without the need for sending API requests for code embeds), you could look at implementing something like Shiki.

Here's a very quick tag I've created for Shiki:

<?php

namespace App\Tags;

use Illuminate\Support\Facades\Cache;
use Spatie\ShikiPhp\Shiki as ShikiPhp;
use Statamic\Tags\Tags;

class Shiki extends Tags
{
    /**
     * The {{ shiki :code="code" :language="language" }} tag.
     *
     * @return string|array
     */
    public function index()
    {
        return Cache::rememberForever('ShikiHighlight::'.md5($this->params->get('code'

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tqt97
Comment options

Answer selected by tqt97
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants