Test:
Ran a separate server on port 3000
```
Checking if port 3000 is free...
Extracting translateable strings from files...
Loading translation files...
Generating Metadata for Docs....
Generating Metadata for Docs....
server.js triggered...
Generating Metadata for Docs....
Extracting translateable strings from files...
listening on port: 3000
Open http://localhost:3000/
Port 3000 is in use
```
Fixes#124
I want to be able to tweak the default tokenizer for syntax highlighting. The current one isn't as good as it could be.
With this PR, I would be able to add this to the siteConfig and it would give me the Prism access so that I can get proper syntax highlighting:
```js
prism: function(Prism) {
Prism.languages.javascript = Prism.languages.extend("javascript", {
keyword: /\b(alias|as|async|await|base class|...|with)\b/,
constant: /\b[A-Z][a-zA-Z0-9_]*\b/,
builtin: /\bopen_file|...|invariant_violation|invariant|getcwd\b/,
function: /\b[_$a-z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/,
});
},
```
Without this a build failure would occur for those that are not using the languages.js file.
e.g.,
```
sitemap.js triggered...
module.js:471
throw err;
^
Error: Cannot find module '/home/ubuntu/fasttext-website/website/languages.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at module.exports (/home/ubuntu/fasttext-website/website/node_modules/docusaurus/lib/server/sitemap.js:48:15)
at execute (/home/ubuntu/fasttext-website/website/node_modules/docusaurus/lib/server/generate.js:316:5)
at Object.<anonymous> (/home/ubuntu/fasttext-website/website/node_modules/docusaurus/lib/build-files.js:31:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
Error: generating html failed
```
* added a note about needing more than one language to be enabled to allow for a drop down
* Removing debug statements
* Add 'Help Translate' to translatable strings, improves error messages around missing translated strings, calls write-translations on some routes
* Adds sitemap.xml to live server and build. Versioning not supported. -- Also did some file name and module cache cleanups.
* Add the ability to provide custom layout
When I designed the system, I added the ability to provide a custom layout that would use arbitrary JavaScript to render some custom pages. This is why files are called "DocsLayout.js", "BlogPostLayout.js"... This ability to customize it was [ripped out](https://github.com/facebook/react-native/blob/master/website/server/convert.js#L78) during the migration to Docusaurus but I need it for the project I'm working on right now (that should remain unnamed!).
This adds back the ability to do it in a way that fits the third party system. In order to provide a new layout:
1) Add a `layout` field in the header of your markdown file:
```js
---
layout: mylayout
---
```
2) In your `siteConfig`, add
```js
layouts: {
mylayout: function({React, Marked}) {
return class extends React.Component {
render() {
return React.createElement('div', {}, this.props.metadata.layout);
}
}
}
}
```
I think that it's a reasonable to add and would unblock me :)
* Update DocsLayout.js
My hack of checking if the body was empty wasn't correct :(
```js
---
id: String
title: String
layout: stdlib
---
```
The above would be treated as pure content. Now it's working properly :)
This isn't needed and we don't need to keep up with it everytime we push a package.
We only have to keep up with the versioning in the main package.json
I was getting this error when running the examples:
```
Error: It looks like you've enabled language support, but haven't provided translated files. The document with id: 'en-doc1' doesn't exist.
```
However, this error was an indirect result of me not renaming the `docs-examples-from-docusaurus` directory to `docs` since I had `doc` in my
`headerLinks` in the example siteConfig.js.
So let's check the headerLinks and make sure we have the required directories.
Here is an example of the error if I try to load a Docusaurus site just after running `npm run examples` without having renamed the directories.
```
Error: You have 'doc' in your headerLinks, but no 'docs' folder exists one level up from 'website' folder. Are you running the examples? If so, make sure you rename 'docs-examples-from-docusaurus' to 'docs'.
at /Users/joelm/dev/test/website/node_modules/docusaurus/lib/core/nav/HeaderNav.js:226:15
:
:
```
Test Plan: Tested a local package in verdaccio