This article originally appeared on The Fulcrum.
In this article we take a quick look at how to use JavaScript in your Bear Blog website.
JavaScript
JS is used to bring interactivity to your website. And the most recognizable use is for forms.
I will be honest here and say most frontend JS code today is crap, especially in platforms like React. But vanilla (pure and plain) JavaScript can be useful (in micro doses) in your Bear Blog.
This is especially true if it’s for a small organization or solopreneur that needs some online publishing or marketing functionality.
This is the fourth post in our "how to" series of building your Bear site / blog. The first, second, and third are on Markdown, CSS, and HTML.
As mentioned above, I am not a fan of JS. It's a bloated clusterfuck of a language in my opinion. And in any event it's usually forced into projects when simpler (built for purpose) and easier to use programming options exist. This includes HTML and CSS, BTW.
In general, its use should be kept to a “bear” minimum. ;)
Fortunately, using JS with your Bear site is an easier process than you would expect. You won't need to attend a coding boot camp to accomplish some simple things.
Go Pro
To use JS in Bear you need a pro account. Which is fine, because if you need its functionality you are probably a professional with professional resources. Plus, Herman deserves to earn a living just like the rest of us. And JavaScript increases your compute and his costs.
So, if you're logged in, sign up here.
I had to in order to be able to write this article based on experience. Unlike say AI making it up by scrapping the website documentation and GitHub repository.
Extensions
The easiest way to add JS to your Bear site is via official Bear extensions.
You just paste code from their GitHub repository into your footer via the footer editor under Advanced Settings. As opposed to in your header which would slow your site's loading time down.
For an example, the pagination extension paginates your posts list on the Blog page and gets rid of the unsightliness of the default list (which shows every post you ever posted).
Note that every extension must be placed in an HTML script tag. So, type < script> before the extension code and < /script> after it. Be sure to remove the blank space after the first < bracket.
Next, go to the link, use the copy icon (near the top right corner) to copy the JS code, paste it into your footer, on line 15 insert spaces on each side of the words Previous and Next, adjust the number of posts to show (which defaults to 20 on line 20), and save. 1 You’re done.
Really, it’s that simple.
Table of Contents and Link Previews are other justifiable uses of JavaScript.
You can even get real fancy and add JS extensions to the Bear admin area like Version History.
Vanilla JS
You can also write your own JS aka Vanilla JavaScript but now you are entering the realm of being a "programmer". Which is not simple and not necessary for most sites. And it's not in the scope of this article. But, the world could be your oyster.
You can learn JS with a lot of effort. Just don't use platforms like React, Angular, Vue, Svelte, etc. Vanilla JS will be more than enough for your website. And don't fucking use AI. The effort of learning is worth it.
Wrapping it up
So, this is the shortest article in the series. That's because JavaScript should be the least used language we covered. We only use the pagination and aria current extensions on our Bear site.
Ideally, you would not use JS at all, even if you go pro for the other benefits that plan offers.
Explore More
CTAs
- Please share this article.
- Follow us on Surf or at @[email protected] on the Fediverse or at @thefulcrum.eurosky.social on the Atmosphere for daily coverage.
- Read, live, and share The Techno Anarchist Manifesto!
- Escape techshit with the LESS Stack.
And please build something for a community! We're promoting the LESS stack via our Manade project.
-
For a smaller blog 5 or 10 would be a better option. ↩
Top comments (0)