Include local js file in build using obsidian

I am building a site with notes for a class. It works with an external js file, but I want to host the js file locally. How?

In detail:
The site uses the scratchblocks plugin to process certain pre/code blocks. If you look at the page now, you can see an image at the top (which shows what my end result will be) and part of the text properly processed code (see here). This shows I am able to get it to work by using an external version of the necessary js file. But I what i want is to host the js file locally. Currently it works by including a line to the digital garden page template, and a short set of lines of javascript that references the function in the script. I have tried placing the js file in various places on the site (that is the github repo it is built from), and I have tried a host of src references, e.g. , /, …/, /src/site/, /js/, _includes/, but every time I get an error 404 as the file is never added to the build (I have downloaded them and checked). If i use an external src (https://…etc.) it works fine, as shown. I just want to be able to get a local version to load, and be able to reference in my code.

I am building the site using Obsidian and a slightly modified version of the obsidian digital garden plugin. The point being that most of the build/setup up is automatic, not built by me (i.e. I am not clear on the details of the package files, commits, syncs etc), but that may not be relevant.

Thanks in advance for your time…

Hi @ksdavidc,

Are you looking for:

thanks for the reply. Well, that is the kind of thing I want, but I would like to do it without having to install eleventy, which seems like a bit of overkill just to add one file.

Aren’t you using Eleventy already? I sent you an Eleventy-specific link because it appeared that you’re using it.

Oh? OK, but which link is that? my links are digital garden links, and a github link. Is there an error in my links?

Ignore the last reply. I misread your comment.

No, I am not using 11ty, just obsidian and an obsidian plugin. It might help me if you could tell me what made it appear that way…

I don’t know what Obsidian is, but here’s why it appears you’re using eleventy:

Your repo has this file:

image

This is from your package.json:

image

You’re using .njk templates:

image

You’ve a file structure that Eleventy sites generally have:

image

tl/dnr: I got it. I added a line to the eleventy.js file to create a static folder.

I see where you are coming from. Just as you don’t know Obsidian, I don’t know Eleventy, so I had no idea what you were talking about. How that can be is explained as follows:

Obsidian is a markdown editor. It has a plugin called Obsidian digital garden. What it does, if I understand correctly, though I don’t really know by what magic it does this, is take the contents of my markdown, and send it to netlify to turn into a digital garden site. It does this “automatically, on demand”, ie. behind the scenes for me. I just press go.

It seems to do this via a clone that is autogenerated for me of their repo, some details of which are in the configuration on its site, the steps of which I followed to set it up.

That clone is what you were looking at, and lo and behold, yes it does use 11ty, whatever that is. For me it was just a black box. I had just modified the html a little bit to add the scripts I mentioned. I don’t really understand how it takes this repo and sends it to netlify, but I can see now that you are right that 11ty, unbeknownst to me is/was involved.

Thus, with your help, I did find the configuration file and added the line, and the js file did upload.

Thank you.