Replies: 17 comments 3 replies
-
Thanks for submitting your feature request. It triggers me to look into some kind of customizable "modules" approach. I prefer the current npm setup, where all files are bundled and served without the need of a CDN - and are updated by dependabot automatically. But as you mention already, you wouldn't want to include a lot of unnecessary files either. Would you mind sharing your current code as an example? I'll look into the KaTeX documentation, it looks like a mix of Node.js and Browser is needed. |
Beta Was this translation helpful? Give feedback.
-
Sure. I added the file <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css" integrity="sha384-GvrOXuhMATgEsSwCs4smul74iXGOixntILdUW9XmUC6+HX0sLNAK3q71HotJqlAn" crossorigin="anonymous">
<!-- The loading of KaTeX is deferred to speed up page rendering -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-cpW21h6RZv/phavutF+AuVYrr+dA8xD9zs6FwLpaCct6O9ctzYFfFr4dgmgccOTx" crossorigin="anonymous"></script>
<!-- To automatically render math in text elements, include the auto-render extension: -->
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>
<script>document.addEventListener("DOMContentLoaded",function(){renderMathInElement(document.body,{delimiters:[{left:"$$",right:"$$",display:true},{left:"$",right:"$",display:false}]})});</script> In the file in the file Content-Security-Policy = """\
default-src 'self'; \
script-src 'self' \
https://utteranc.es/client.js https://cdn.jsdelivr.net \
'sha256-zqrgdmVTCHeZA3joAgSlAjQWAQSAPSJwoKyRhD8nqnc=' 'sha256-Yl2Mo78PNibh19ibhdKx03FFbKW9+8fljFAUUyUY1IQ=' \
'sha256-avLhcj2GD+l0pju24dWnj9qz5CZkAxQ6WrkK1IaSva4='; \
style-src 'self' 'unsafe-hashes' https://utteranc.es https://fonts.googleapis.com https://www.youtube.com https://cdn.jsdelivr.net \
'sha256-kFAIUwypIt04FgLyVU63Lcmp2AQimPh/TdYjy04Flxs=' 'sha256-XzJlZKVo+ff9ozww9Sr2p/2TbJXITZuaWMZ9p53zN1U=' \
'sha256-hqhQ1AAR6jgr9lel8hs9sNOeqSwsGx6HH+B7TkLcmyY=' ;\
object-src 'none'; \
base-uri 'self'; \
connect-src 'self' \
https://cdn.jsdelivr.net; \
font-src 'self' https://fonts.gstatic.com https://cdn.jsdelivr.net; \
frame-src 'self' https://utteranc.es https://www.youtube-nocookie.com https://www.youtube.com; \
img-src 'self' https://i.vimeocdn.com https://i.ytimg.com https://img.youtube.com; \
manifest-src 'self'; \
media-src 'self' \
""" In the markdown file This is what I used for testing in the markdown file: This is an inline $-b \pm \sqrt{b^2 - 4ac} \over 2a$ formula
This is not an inline formula:
$$x = a_0 + \frac{1}{a_1 + \frac{1}{a_2 + \frac{1}{a_3 + a_4}}}$$
$$\forall x \in X, \quad \exists y \leq \epsilon$$ That should be it. Note that I am not an expert in Latex, so I use CodeCogs to help me build the equations. |
Beta Was this translation helpful? Give feedback.
-
Thanks for sharing! I've added a new feature request #323 to track the "modules" approach too. I'll use your code and the KaTeX npm library as a case example. Feel free to share your thoughts in either issue. The feature might require a significant code change, so I can't commit to any schedule yet. However, the summer break is coming up, which might give me some ample time to work on this... |
Beta Was this translation helpful? Give feedback.
-
That would be a great way to add additional functionality. |
Beta Was this translation helpful? Give feedback.
-
After some experimentation I believe to have found a satisfactory approach to include configurable Hugo modules. The findings are described in #323. The next steps:
Feel free to comment! |
Beta Was this translation helpful? Give feedback.
-
I've read through all that and it would be great if that will work. My experience with Hugo is limited to working through the book, 'Hugo in Action' and modifying the Hinode template, so I might not be the one adding very meaningful comments. That said, I do have a comment related to your last bullet point. Some modules are essential to have on a site. Being able to search is one of them. It should be a basic module. The only reason to make it possible for such a module to remove it, is if someone wants to replace it with another search module. Having a site that you cannot search, is bad in my opinion. I think it is fine to have core components that the template cannot do without. And for these 3 specific components I'm not sure if anyone will use the option to remove or replace them. As such I think the balance between the effort you put into it and how often it would be used is off. |
Beta Was this translation helpful? Give feedback.
-
Thanks with your elaborate feedback! It's of great help to have an outside-in perspective. I agree with your remark - the core modules are unlikely to be disabled and should be included by default. The main reason to put these core libraries into to modules is to standardize the approach and thus to minimize maintenance. For now, it has low priority. |
Beta Was this translation helpful? Give feedback.
-
I released an alpha version of the new module system. The basic functionality has been implemented, although there are probably a few things to iron out. I plan to work on the KaTeX module next, I'll keep you posted. |
Beta Was this translation helpful? Give feedback.
-
Nice. I will try it out later this week. |
Beta Was this translation helpful? Give feedback.
-
I checked it out and it looks quit nice. It works offline (once the modules are downloaded), which is good. Once it is out of the alpha stage, I would like to try to convert my additions to Hinode into a module (currently these are a gallery and a different way of displaying single images). |
Beta Was this translation helpful? Give feedback.
-
Thanks for taking the time to do an initial review. Meanwhile, I have now included the KaTeX module and updated the docs. A live preview is available on https://modules--gethinode-docs.netlify.app (it's updated on every push to the modules branch, so it might be unstable).
Would you care to elaborate on that? The documentation is available on https://modules--gethinode-docs.netlify.app/docs/configuration/modules/ (subject to change).
I agree that Bootstrap is an essential component of Hinode. Actually, I included a check in
I'd be very interested in your experience with developing custom modules. I've prepared a guide on https://modules--gethinode-docs.netlify.app/guides/modules/ to get you started. If you're willing, you might want to share your modules with the OSS community too? |
Beta Was this translation helpful? Give feedback.
-
Before I elaborate on not being able to not install a module, I'll have a closer look at the documentation first, because the error is probably on my side :) As to Bootstrap, after writing my post I noticed also the re-opened post about the Go modules and it makes sense in that context. For the record, I was not challenging your decision. It was just me failing to grasp what the benefits of such a move were. My gallery module resembles Katex. Not from the context, but from the steps needed to get it working. So I will use the Katex module as a reference and I will read the documentation first, this time. And I will put everything in Github; the site, modules and the projects. I work in a self-hosted Gitea environment and as I am working on three different computers in my home, I use Gitea to sync between those computers. As a result my commits are quite often breaking the software, which doesn't matter as I am the only one having access to the repository. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your feedback, appreciate it! Let me know if you need any help with the module development. I used Gitea in the past myself (self-hosted on a NAS), so I'm not too unfamiliar with the challenge to keep it up and running. :-) I'll update the Hinode template next and aim for a final release of v0.16 soon. There's one optimization left (the alphabetical sort of folders and files in |
Beta Was this translation helpful? Give feedback.
-
Done! The docs and template have been updated too. Let me know if you encounter any issues. |
Beta Was this translation helpful? Give feedback.
-
Thanks for giving it try! I can imagine the guide requires more clarification. Before revising the guide, let's see if we can get your module up and running. I created a fork of your module in my personal account. I pushed several changes to the npm run start This is a screenshot of the local site. It renders a grid of example images, however, it appears the thumbnails are not scaled correctly yet. They do open when you click on them. A few observations regarding your initial code:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I have a different request, related to the |
Beta Was this translation helpful? Give feedback.
-
I think having the ability to show (Latex) formulas in my markdown files is a nice feature. It is not something that I use often, but it is a nice feature to have available.
I have currently added it to the template myself. I am using Katex, the other option would be mathjax. I am currently using the version where I load the javascript and CSS files in
partials/assets/katex.html
and inlayouts/partials/head/head.html
I conditionally load the Katex partial, depending on whether or not in the frontmattermath
is set totrue
. This makes it not load on every page. Obviously, I also needed to modifyserver.toml
to allow these external files to be loaded.There is also a nodejs solution that I have not tried. Nor did I try the mathjax option. If you think it would be a nice addition to include in the template, I'll leave it to you to decide what the best solution is. If you don't like it, that is also fine, given that I already have a working solution :)
Beta Was this translation helpful? Give feedback.
All reactions