Skip to content

How to incorporate custom javascript #1457

Answered by MasterOdin
dannyduncan asked this question in Q&A
Discussion options

You must be logged in to vote

The //= require lines in the JS files are a custom pre-processor command that middleman-sprockets handles. In all_nosearch.js for example, for the //= require ./app/_copy line is replaced by the contents of https://github.com/slatedocs/slate/blob/main/source/javascripts/app/_copy.js (./app/_copy.js from the relative directory) in that preprocessing step.

Right now, your options to add your own JS would probably be:

  1. Add new code / require to all_nosearch.js (the require lines are relative to the location of that file).
  2. Add a new script load to the layout.erb file.

Replies: 1 comment 1 reply

Comment options

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

Answer selected by dannyduncan
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