GithubHelp home page GithubHelp logo

ngx-ggist's Introduction

GitHub gist on Angular 13

Demo Stackblitz License

Add a GitHub gist to your angular 13 project in an instant.


Table of Contents

Installation

Install with NPM

npm install ngx-ggist

If you get dependency errors, as a temporary solution you can force the installation:

npm install -f ngx-ggist

Usage

Import NgxGgistModule in your app

import { NgxGgistModule } from 'ngx-ggist';

@NgModule({
  imports: [
    NgxGgistModule
  ],
  ...
})
export class AppModule { }

Use Github Gist directive

Place the component anywhere in your template to display the gist.

<ngx-ggist></ngx-ggist>

Custom Properties

When you add the component to your project (as shown above), you will get the Hello world version of it. That's cool but, to show your own gists, you need to provide a couple of options to the component.

You will need just two properties: your user name and the script id: you can get both from the url of the GitHub gist, or when you copy the script for embedding the gist.

Optionally, you could also provide width, height, and a cool feature to highlight lines.

There are more configurations available, optional.

Name Type Description
user string Your GitHub user
scriptId string The script id of your gist, usually the last parameter in the URL.
(i.e. 4171e2f2b5ea64bdf974d6d2e5683cce)
width string A string to define the width of the gist container; default: 600px
(i.e. '100%')
height string A string to define the height of the gist container; default: inherit
(i.e. '400px')
lines array of number An array of numbers. Each number represents a line in your gist file and that line will be highlighted; none are highlighted by default.
(i.e. [1, 2, 3])

More examples

Example below, will display the gist 417...cce, on a 400px height container, highlighting lines 1, 2, 3.

<ngx-ggist
  user="jocelo"
  scriptId="4171e2f2b5ea64bdf974d6d2e5683cce"
  height="400px"
  [lines]="[1,2,3]" >
</ngx-ggist>

Author

Alfredo Alonso

ngx-ggist's People

Watchers

 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.