Skip to content

Commit

Permalink
feat: add torchlight
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcodes committed May 25, 2022
1 parent 643ff8a commit b1fe9fe
Show file tree
Hide file tree
Showing 12 changed files with 706 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ yarn-debug.log*
.pnp.js
# Yarn Integrity file
.yarn-integrity
.envrc
.torchlight-cache
1 change: 1 addition & 0 deletions bridgetown.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ url: "" # the base hostname & protocol for your site, e.g. https://example.com
permalink: pretty
template_engine: erb

highlighter: ""
# Other options you might want to investigate:
#
# base_path: "/" # the subpath of your site, e.g. /blog. If you set this option,
Expand Down
14 changes: 14 additions & 0 deletions frontend/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,17 @@ hr {
border-top: 2px dotted #bbb;
margin: 3rem 0;
}

pre {
@apply my-4 rounded overflow-x-auto;
}

pre code {
@apply block py-4 min-w-max;
}


pre code .line-number,
pre code .summary-caret {
@apply mr-4;
}
2 changes: 1 addition & 1 deletion frontend/styles/jit-refresh.css
Original file line number Diff line number Diff line change
@@ -1 +1 @@
/* 1653516523 */
/* 1653522500 */
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"esbuild-dev": "node esbuild.config.js --watch"
},
"devDependencies": {
"@tailwindcss/typography": "^0.5.2",
"@torchlight-api/torchlight-cli": "^0.1.2",
"esbuild": "^0.13.15",
"glob": "^7.2.0",
"postcss": "^8.4.0",
Expand Down
9 changes: 9 additions & 0 deletions plugins/builders/torchlight.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Builders::Torchlight < SiteBuilder
def build
hook :site, :post_write, priority: :high do
# next unless Bridgetown.env.production?

system "yarn torchlight"
end
end
end
4 changes: 3 additions & 1 deletion src/_layouts/page.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ layout: default

<h1><%= resource.data.title %></h1>

<%= yield %>
<article class="prose max-w-none">
<%= yield %>
</article>
4 changes: 3 additions & 1 deletion src/_layouts/post.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ layout: default

<h1><%= resource.data.title %></h1>

<%= yield %>
<article class="prose max-w-none">
<%= yield %>
</article>
41 changes: 36 additions & 5 deletions src/index.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
---
# Feel free to add content and custom Front Matter to this file.

layout: default
layout: page
title: "Welcome to your new Bridgetown website"
---

# Welcome to your new Bridgetown website.
> Tutorial coming soon to [andrewm.codes](https://andrewm.codes/)
## [Bridgetown](https://bridgetownrb.com/)

You can learn more about how to build and deploy your new website by reading the [Bridgetown documentation](https://www.bridgetownrb.com/docs).

Expand All @@ -16,7 +17,37 @@ If you run into any issues or have additional questions, please join us in our [

_Have fun and **good luck**!_

----
## [Torchlight](https://torchlight.dev)

Can be run as a hook on every build, but this can occasionally put you into a weird state where you have to reload to see the changes.

```ruby
class Builders::Torchlight < SiteBuilder
def build
hook :site, :post_write, priority: :high do
system "yarn torchlight"
end
end
end
```

There really isn't a need to run Torchlight everytime we rebuild the site though...

We can just run it at the end of our build process via the CLI or with a hook. Or we could only run it when BRIDGETOWN_ENV is set to `production`.

```ruby
class Builders::Torchlight < SiteBuilder
def build
hook :site, :post_write, priority: :high do
next unless Bridgetown.env.production?

system "yarn torchlight"
end
end
end
```

---

**Generated by v1.0.0**
{:style="text-align:center"}
4 changes: 3 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ module.exports = {
theme: {
extend: {},
},
plugins: [],
plugins: [
require("@tailwindcss/typography"),
],
}
64 changes: 64 additions & 0 deletions torchlight.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
module.exports = {
// Your token from https://torchlight.dev
token: process.env.TORCHLIGHT_TOKEN,

// The Torchlight client caches highlighted code blocks. Here you
// can define which directory you'd like to use. You'll likely
// want to add this directory to your .gitignore. Set to
// `false` to use an in-memory cache. You may also
// provide a full cache implementation.
cache: '.torchlight-cache',

// Which theme you want to use. You can find all of the themes at
// https://torchlight.dev/docs/themes.
theme: 'atom-one-dark',

// The Host of the API.
host: 'https://api.torchlight.dev',

// Global options to control block-level settings.
// https://torchlight.dev/docs/options
options: {
// Turn line numbers on or off globally.
lineNumbers: false,

// Control the `style` attribute applied to line numbers.
// lineNumbersStyle: '',

// Turn on +/- diff indicators.
diffIndicators: true,

// If there are any diff indicators for a line, put them
// in place of the line number to save horizontal space.
diffIndicatorsInPlaceOfLineNumbers: true

// When lines are collapsed, this is the text that will
// be shown to indicate that they can be expanded.
// summaryCollapsedIndicator: '...',
},

// Options for the highlight command.
highlight: {
// Directory where your un-highlighted source files live. If
// left blank, Torchlight will use the current directory.
input: './output',

// Directory where your highlighted files should be placed. If
// left blank, files will be modified in place.
output: '',

// Globs to include when looking for files to highlight.
includeGlobs: [
'**/*.htm',
'**/*.html'
],

// String patterns to ignore (not globs). The entire file
// path will be searched and if any of these strings
// appear, the file will be ignored.
excludePatterns: [
'/node_modules/',
'/vendor/'
]
}
}

1 comment on commit b1fe9fe

@vercel
Copy link

@vercel vercel bot commented on b1fe9fe May 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.