/code-snippet-template

Self-host code snippets using gh-page and highlight.js

Primary LanguageHTML

Code snippets template

A simple boiler plate repo to stores all the code snippets and display it as an iframe. For now just tested javascript and with Dracula theme. Update template.html file to change the base content of the website. Under the hood it uses highlight.js with line-number plugin and dracula theme. Use github action and update the gh-page.

How to

  1. Create a new repo
  2. Select this template during creating a new repo
  3. Give Github Action permission to read and write the repo. Under Setting > Action > Workflow Permission
  4. Re-run the workflow under the Action Tab |> To Create a branch <|
  5. Enable Github Page under Setting > Pages
  6. Select Deploy from branch
  7. Under Branch select gh-page dropdown.
  8. Click save
  9. Goto: https://username.github.io/repo_name/sample-file.html

Sample

With line highlighter

Config

To customize the code that's in the source folder, create a file with the same name with .config.json ext.

sample-file.js => sample-file.config.json

{
  "highlightLines": [1,2,3],
  "lineNumberStartAt": 10
}

Remove the sample-file.js and sample-file.config.json