Link to static JSON file - docusaurus

In Docusaurus V2 how to link to a JSON file in the static folder?
I tried the following in a markdown file:
An exemple, is the following [JSON dataset](../../static/data/solar-radiation.json).
But Docusaurus then produce the following error:
./static/data/solar-radiation.json (./node_modules/file-loader/dist/cjs.js?name=assets/files/[name]-[hash].[ext]!./static/data/solar-radiation.json)
Module parse failed: Unexpected token e in JSON at position 0 while parsing near 'export default __web...'
File was processed with these loaders:
* ./node_modules/file-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
SyntaxError: Unexpected token e in JSON at position 0 while parsing near 'export default __web...'
at JSON.parse (<anonymous>)
My file is a valid JSON. For some reason, instead of displaying a static file Docusaurus seems to try to parse it...

I saw the same problem. My temporary solution is:
Change file name from .md to .mdx
Add this link to your json file
<a target="_blank" href="/json/file.json" download="file.json">Download</a>

I've also had the same problem!
According to the Issue #3561 on the Docusaurus GitHub, word from one of the developers is that the current best practise is to use the pathname:// prefix in front of your URL. To use your example:
An exemple, is the following
[JSON dataset](pathname://../../static/data/solar-radiation.json).
Apparently the reason why this happens is because there is a conflict between the babel-loader (used to load code) and the file-loader (used to load static assets). The pathname:// prefix skips both of these loaders, and just creates a link instead.

Related

error: failed to encode '---------_dict.sql' from UTF-8 to Windows-1250

when I download the repository I get this error from the git
error: failed to encode '---------_dict.sql' from UTF-8 to Windows-1250.
Then while I want to commit and push I get the same error with the same files with the .sql extension. Anyone have any idea? Someone had a similar problem? Could it be related to the .gitattributes file which has
* .sql text working-tree-encoding = Windows-1250
This error message means that some part of the conversion failed, most likely because the contents of the file cannot be converted to windows-1250. It's likely that the file contains UTF-8 sequences corresponding to Unicode characters that have no representation in windows-1250.
You should contact the author of the repository and notify them of this problem and ask them to fix it. In your local system, you can add .git/info/attributes which has the following to force the files to UTF-8 instead:
*.sql text working-tree-encoding=UTF-8
Note that if you do this, you must ensure that the files you check in are actually UTF-8 and not windows-1250.

WebStorm's Safe Delete doesn't check XML file

I'm deleting a CSS file that is referenced in an XML file. I select "Safe delete (with usage search)" and "Search in comments and strings" but the reference in the XML file is not found.
The XML file is in a directory included in the project. The XML file contains the complete file name in a string.
Are there some settings for Safe Delete somewhere or something more general that might exclude XML files?
Thanks for any help.
<resourceSet name="HeaderStylesCss" type="css">
<resource path="~/Legacy/Content/Css/HeaderStyles.css"/>
</resourceSet>
path value is treated as simple string, so CSS file usage is not found and thus not taken into account when deleting a file.
You can try injecting File reference language in path="" value manually via Alt+Enter, Inject language or reference:
but paths starting with ~ won't work there, I'd suggest using relative paths rather than absolute

eclipse-neon bower-install can't run due to error in the file

I create javascript project and bower.json. After adding dependencies as follow gives me red-cross on project->bower_components->bootstrap->grunt->change-version.js file and query->src file:
"dependencies":{
"bootstrap":"~3.3.7"
}
This is first problem:
Description Resource Path Location Type
Expected name at 2:1 .eslintrc.json /gruntTest/bower_components/jquery/src line 2 JSON Problem
Second problem:
Description Resource Path Location Type
Unexpected token ILLEGAL change-version.js /gruntTest/bower_components/bootstrap/grunt line 1 JavaScript Problem
I assumed that eclipse neon doesn't need to download Nodeclipse & Enide and try to practice from scratch thats the reason error happened.
Nodeclipse & Enide must installed before practicing nodejs in eclipse.
I followed this link and worked great.
http://www.nodeclipse.org

LESS Compiler: Unexpected token u

When I attempt to compile a LESS template in Visual Studio using Web Essentials, I receive an error that says "Unexpected token u" with no file name, no line number, and no column number. Why is this happening?
Go to %USERPROFILE%\AppData\Local\Microsoft\VisualStudio\12.0\Extensions which is the folder where per-user Visual Studio extensions reside. WebEssentials will be located in a subfolder with a randomly generated name.
From inside the WebEssentials folder, open up the file Resources\nodejs\tools\server\services\srv-less.js and go to line 65, which reads:
map = JSON.parse(output.map);
The problem is source map output may be the undefined value. JSON.parse can only parse strings, so it casts that to the string value "undefined" before parsing, but JSON does not recognize that as valid token. (It only understands the null value, not the undefined value.)
So... change line 65 to read:
map = JSON.parse(output.map || "null");
And voilĂ ; LESS compilation on files with empty output works again.
Source:
https://github.com/madskristensen/WebEssentials2013/issues/1696
From my experience, this error occurs when LESS attempts to output a CSS file from a LESS file, and the resulting CSS file is empty. In my case, this happened after removing some font-face declarations, which left the resulting CSS file empty. LESS would not compile until I added a class that would output to the CSS file.
Details may be found here: https://github.com/madskristensen/WebEssentials2013/issues/1696
I'm adding this to StackOverflow because I'm unable to access Github at my workplace. I hope this helps someone.
You can also add in your less file an important comment /**/ or #charset "utf-8"; as described here https://github.com/madskristensen/WebEssentials2013/issues/1696

Pig problem with load file with complicated name

i need to load file in pig which has a long and complicated name:
dealnews-2011-04-01T12:00:00:00.211-02:00.csv
Pig complained:
ERROR org.apache.pig.tools.grunt.Grunt - ERROR 2999: Unexpected internal error. java.net.URISyntaxException: Relative path in absolute URI:
anyone knows what's the problem? Thanks.
If it's forming a URI from that, the : is a reserved character.
Think about it: file://a:b ... this would be taken as an FTP login.
Your error message seems to complain that what's left after the string is parsed is a relative path (I guess 00.csv after the last colon). Obviously no longer the whole filename.
You will need to escape any reserved characters in the filename before forming a URI.
You could do this on the command line, with for example:
ls | sed -e 's/:/%3A/g'
to transform the colons in the filename.
Or you could rename any files in the directory that use any of ";?:#&=+,$"
not exactly the same case, but we got:
ERROR 2999: Unexpected internal error. java.net.URISyntaxException cannot be cast to java.lang.Error
java.lang.ClassCastException: java.net.URISyntaxException cannot be cast to java.lang.Error
for everything we tried to load, and the problem was that the PIG_CONF_DIR env variable was pointing to a folder that did not exist. We've reset it in the .bash_profile to a folder with valid core-site.xml and mapred-site.xml and everything's good now.
export PIG_CONF_DIR=/my_good_folder