项目作者: ohseesoftware

项目描述 :
A Statamic v3 add-on to use GitHub's Gists to host code blocks.
高级语言: PHP
项目地址: git://github.com/ohseesoftware/oh-see-gists.git
创建时间: 2020-05-18T04:12:29Z
项目社区:https://github.com/ohseesoftware/oh-see-gists

开源协议:MIT License

下载


Oh See Gists

Current Release
Build Status Badge
Coverage Status
Maintainability Score
Downloads
MIT License

Use GitHub Gists to embed your code snippets on your site. Example: https://ohseemedia.com/posts/hooks-can-only-be-called-inside-the-body-of-a-function-component-reactjs-error/

Installation

Install the add-on:

composer require ohseesoftware/oh-see-gists

Publish the add-on’s assets:

php artisan vendor:publish --tag=oh-see-gists

This will publish:

  • a config file for the GitHub API
  • views in the resources/views directory
  • fieldsets in the resources/fieldsets directory

Usage

Add your GitHub token to your .env file

You’ll need to create a new personal access token. You can do so here: https://github.com/settings/tokens/new.

The token only needs the gist scope.

Add the token as OH_SEE_GISTS_GITHUB_TOKEN in your .env file.

Add the fieldset to your blueprint(s)

The fieldset that will be published is named gist_block. You will need to update your blueprints to reference the fieldset wherever you want it to be used. As an example in bard:

  1. type: bard
  2. sets:
  3. gist_content:
  4. display: Gist
  5. fields:
  6. - import: gist_block

Naming

There are two very important naming conventions you have to follow:

  • The gist_content name for the fieldset is very important. The add-on references this key so you cannot change it.
  • Your bard block has to be named content for the add-on to save to your GitHub Gists. Otherwise, you will be just creating code blocks on your Statamic site.

Use the partial in your templates

The add-on publishes a partial for you to use in your templates to render the Gists. You can use it like so:

  1. {{ bard_content }}
  2. {{ if type == "gist_content" }}
  3. {{ partial src="partials/gist_content" }}
  4. {{ /if }}
  5. {{ /bard_content }}