docusaurus/lib/server/routing.js
Yangshun Tay 9d4a5d5359
Prettify all JavaScript files (#964)
* Prettify all JavaScript files

* Make trailingComma all

* Delete v2/.prettierignore

* Remove v2 Prettier commands in package.json
2018-09-17 15:34:55 +08:00

46 lines
904 B
JavaScript

/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
function blog(baseUrl) {
return new RegExp(`^${baseUrl}blog/.*html$`);
}
function docs(baseUrl) {
return new RegExp(`^${baseUrl}docs/.*html$`);
}
function dotfiles() {
return /(?!.*html$)^\/.*\.[^\n/]+$/;
}
function feed(baseUrl) {
return new RegExp(`^${baseUrl}blog/(feed.xml|atom.xml)$`);
}
function noExtension() {
return /\/[^.]*\/?$/;
}
function page(baseUrl) {
const gr = regex => regex.toString().replace(/(^\/|\/$)/gm, '');
return new RegExp(
`(?!${gr(docs(baseUrl))}|${gr(blog(baseUrl))})^${baseUrl}.*.html$`,
);
}
function sitemap(baseUrl) {
return new RegExp(`^${baseUrl}sitemap.xml$`);
}
module.exports = {
blog,
docs,
dotfiles,
feed,
page,
noExtension,
sitemap,
};