How do I modify Docusaurus appearances of the blog from a component library? - docusaurus

Creating Modified Blog Entries
I am new to React, and very much to Docusaurus, however, I've managed to get a decent looking DS site going. I am trying to capture some simple snippets to as "blog entries", just small factual snippets, etc. simple project summaries. I’ve hit the limit of the Docusaurus.config options and not sure how to expand the out of box components.
How do I begin to alter and edit Docusaurus to change the Blog page to be like "Cards" in component-speak? Ive seen some example in Infima, but not sure how to bridge that gap?
How can I easily replicate the Announcement Bar to also be at the bottom, like a Banner?
Thank You!

One possible arena for you to use is Bootstrap — specifically React-Bootstrap. They have a card component you could use where you link individual blog entries to that card. If you're comfortable with JavaScript, there's probably an automation you can build there, but hand-coded text is somewhat part and parcel with static-site generators.
If you want a different solution with the CSS code in your src file outright, CSSCodeLab has a React Card layout entry with an attached source code file. Some hand-coded text required, and not automatically integrated with a separate blog setup, but YMMV.
Otherwise Docusaurus' Showcase page does provide the card formatting. The source code for the page (coded at index.tsx) as well as the components are available.

Related

Prevent my Elm app from crashing when a 3rd party changes the DOM

I have an Elm app. A while ago I realized that my app was crashing locally when I used FontAwesome icons. I came to understand that it happened because I chose SVG icons and therefore FontAwesome was modifying the DOM. That conflicted with Elm's VDOM mechanism.
This was easy to fix--I migrated to the CSS version of FontAwesome that uses pseudo elements. Recently some users complained that the app in production freezes and they showed screenshots of states that were not matching the log data I had. It took a while until I realized that all these users had Google Translate automatically translated the page for them. Google Translate clearly alters the DOM, so I'm not surprised that it made Elm crash.
How can I prevent my Elm app from crashing? Is there a way to be notified if a 3rd party changes the DOM? So that I could even notify the user that they have an extension that interferes with the app.
I had the same problem as you and solved it by migrating to the Elm-FontAwesome library. Basically all you have to do is replace this syntax:
i [ Svga.class "fas fa-check" ] []
with this one:
Icon.viewIcon Icon.check
You can have a look to the example project for more details: https://github.com/Lattyware/elm-fontawesome-example
Have a look here - How we made Elm and Google Translate work together.
Their approach is to hijack the Elm replaceData method that is called by Elm during dom updates using the function below. You would run this just before giving Elm control of the dom.
HTMLFontElement.prototype.replaceData =
function replaceData(_0, _1, string) {
this.parentNode.replaceChild(
document.createTextNode(string),
this
);
};
Apparently, "Google Translate replaces every text node in the DOM with a tag containing at least one more tag – one for each sentence". For example:
<span>Insurello. Rätt ersättning till alla</span>
is translated into
<span><font><font>Insurello. </font><font>The right compensation for everyone</font></font></span>
This method avoids attempting to edit the span and instead replace it with a new one. Once the node is added, Google Translate will translate that text.
I don't know about preventing the crashes, but I think you should be able to register changes to the DOM with the current mutation observer API.
Before that were several deprecated mutation events like DOMSubtreeModified that could also help, but well they are deprecated.
This problem is very closely linked to that of Google Maps or Google Places Autocomplete in Elm. The solution I've used in the past is to provide a childless div with an id I can point to from JavaScript.
Because the div is childless, Elm does not look under the hood to check whether it has changed internally.
Check out this blog post or google "maps in elm" for instructions on how to do this
-- EDIT --
Ive read the question better and this will probably not work for Google translate issues as it changes all text in the entire DOM. Ill leave it here incase the question brings otger people who have more regular problems caused when a 3rd party changes the DOM

Displaying PDF on website using pdf.js

I want to put a file sample.pdf on my website, and want it to be displayed using pdf.js. What I want is to display my own file like the demo, with a toolbar, zooming in/out, etc. So far I can't do that yet.
I did check out the helloworld example, but it simply shows the file like an image, without toolbar, zooming in/out, etc. When I put another file with many pages instead of helloworld.pdf, it just shows the first page.
I am not quite sure what you are looking for but I was able to get this working exactly like the demo. Although you may not want to use that example viewer for your project, you can use the working code as a starting point for your own requirements.
For a simple test you can just clone the project somewhere under a web server into a directory like myproject and visit http://yourservername.com/myproject/web/viewer.html. You should see the pdf appear. This can be a starting point to working with this project. I did this running a very basic Apache server on Linux.
If you are not looking for an example styled like that the demo above you can also see this jsbin from the docs that show how to do something completely customized with working next/previous buttons to move between the pages (as you mentioned you were only seeing the first page).
As a note, it seems that this library does not work properly with Safari. You can see an issue about it here. Unfortunately this makes it unusable for me now as I need to support all current browsers.
Also, remember to watch for the warnings concerning CORS.

Identify the Content Carousel

Can anybody identify the carousel used on this site? It seems to work seamlessly with responsive sites and would with little css changes suit my design perfectly. The source shows something called anchorScroll.js but a search comes up with nothing.
It's a custom solution and not a plugin. Look for Application_NewsSpinner in http://cdn12.grohe.com/application/resources/javascript/scripts/common.js at line :1072
But don't steal code! It's fine to get inspired but you should find your own solution or take an official plugin! Take a look at http://finnrudolph.de/ImageFlow or http://www.jcoverflip.com/demo

Standalone video control example for Google TV jQuery Library?

The jQuery VideoControl is documented here:
https://developers.google.com/tv/web/lib/jquery/#gtv.jq.VideoControl
It takes a set of VideoParms. That are not specified.
It is used in the sample templates on this page:
https://developers.google.com/tv/web/docs/gtv-templates
I've taken apart the templates, but I'm having difficulty creating a simple example of a standalone video control. In the templates, the sidenav and carousel code are tied to how the videocontrol works. There is a relationship between the keyController and behavior (behaviorZones) that I can not find an explanation for.
Is there a standalone example somewhere? What needs to be setup with keycontroller, css, and behavior to get this going?
I'm not aware that there is a standalone videocontrol.js sample but it should be possible to set it up. Most of the necessary pieces are inside videocontrol.js, in particular in the videocontrol's constructor and this function: gtv.jq.VideoControl.prototype.makeControl.
keycontroller mapping is used to handling key inputs and some of the CSS are dynamically controlled within JS so there might be errors if you just rip them apart straight from the Template. You'd have to debug it using a solid tool like Chrome Developer Tools. You can watch tutorials of this tool here: http://www.youtube.com/results?search_query=chrome+developer+tools&oq=chrome+develop&aq=0&aqi=g3g-m2&aql=&gs_sm=3&gs_upl=1972l4015l0l6142l14l11l0l0l0l0l207l1476l3.5.3l11l0
Otherwise please send your error traces and/or code snippet for debugging help.
S

Problems Embedding Video using FCK Editor

I am using FCK Editor 2.6.4 and having problems trying to embed a (non-YouTube) video into a content area.
I found this previous question / post:
[EDIT -- as a new user, I am only able to post one link in this post. The post in question is titled, "Can I embed video using FCK Editor?")
and have investigated all of the proposed solutions, but none of them work properly:
1 -- Using the "Embed Flash" button in the control panel almost works. However, the video I am attempting to add contains a querystring with parameters, like this:
http://static.animoto.com/swf/w.swf?w=swf/vp1&e=1275795594&f=mGQklEgxXKs9vfEIdGnWsA&d=132&m=p&r=w&i=m&ct=Homes%20in%20Eagle%20Creek&cu=http://hometoindy.com/eagle-creek-real-estate.php&options=
and in using the Flash embed tool, it encodes all of the "&" characters to "& amp;", thus breaking them. If it were just for me, I could manually change them back, but clients who use this will not know how to do that.
2 -- I have installed the YouTube video plugin, and it works great... for YouTube. But it cannot be used to embed non-YouTube videos (it automatically changes the URL to YouTube, no matter what).
3 -- I have installed the EmbedMovies plugin, but it throws a javascript error when attempting to add a video file (such as the above) to a page. (The EmbedMovies plugin page on SourceForge says it has been updated for FCK Editor 2.6, but it does not work.)
4 -- Pasting directly into the editor window (of course) does not work. The only way I've been able to make this work is by pasting into the Source panel, and this is not a good option for clients who are not familiar with HTML.
So, is there a good, working plugin for FCK editor that will allow me to quickly and easily embed a video such as the one above into a content area? I don't need to be able to see or preview it in the editor window; I just need it to work when the page is loaded on the front end.
Thanks!
Given the question you found, and scarcity of answers to that, chances are that the plugin you want does not exist.
If your videos are actually from one, though non-standard, source, I can only repeat my advice from that topic - write your own plugin. I have code of plugin I wrote linked there, it should be easy to change it to accomodate your needs.