mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-09 23:27:28 +02:00
Fix bad routing regex for docs & blogs (#795)
* fix bad routing regex for docs & blogs * extract to routing.js & add test * add more test case * address code review * prettier
This commit is contained in:
parent
5a8e9a9ff1
commit
66b2033546
3 changed files with 86 additions and 3 deletions
|
@ -20,6 +20,7 @@ function execute(port, options) {
|
|||
const path = require('path');
|
||||
const color = require('color');
|
||||
const getTOC = require('../core/getTOC');
|
||||
const {docsRouting, blogRouting} = require('../core/routing');
|
||||
const mkdirp = require('mkdirp');
|
||||
const glob = require('glob');
|
||||
const chalk = require('chalk');
|
||||
|
@ -129,10 +130,10 @@ function execute(port, options) {
|
|||
extractTranslations();
|
||||
reloadSiteConfig();
|
||||
|
||||
// handle all requests for document pages
|
||||
const app = express();
|
||||
|
||||
app.get(/\/docs\/.*html$/, (req, res, next) => {
|
||||
// handle all requests for document pages
|
||||
app.get(docsRouting(siteConfig.baseUrl), (req, res, next) => {
|
||||
let url = req.path.toString().replace(siteConfig.baseUrl, '');
|
||||
|
||||
// links is a map from a permalink to an id for each document
|
||||
|
@ -275,7 +276,7 @@ function execute(port, options) {
|
|||
});
|
||||
|
||||
// Handle all requests for blog pages and posts.
|
||||
app.get(/\/blog\/.*html$/, (req, res) => {
|
||||
app.get(blogRouting(siteConfig.baseUrl), (req, res) => {
|
||||
// Regenerate the blog metadata in case it has changed. Consider improving
|
||||
// this to regenerate on file save rather than on page request.
|
||||
reloadMetadataBlog();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue