mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-11 08:07:26 +02:00
Add <doctype HTML> to HTML pages (#566)
* Add doctype to static rendering * Set content-type for CSS
This commit is contained in:
parent
0593ea0039
commit
946e2cef90
3 changed files with 43 additions and 23 deletions
|
@ -1,5 +1,4 @@
|
|||
/**
|
||||
|
||||
* Copyright (c) 2017-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
|
@ -7,27 +6,26 @@
|
|||
*/
|
||||
|
||||
function execute(port) {
|
||||
const extractTranslations = require('../write-translations.js');
|
||||
const extractTranslations = require('../write-translations');
|
||||
|
||||
const env = require('./env.js');
|
||||
const translation = require('./translation.js');
|
||||
const translation = require('./translation');
|
||||
const express = require('express');
|
||||
const React = require('react');
|
||||
const request = require('request');
|
||||
const renderToStaticMarkup = require('react-dom/server').renderToStaticMarkup;
|
||||
const fs = require('fs-extra');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const color = require('color');
|
||||
const toSlug = require('../core/toSlug.js');
|
||||
const toSlug = require('../core/toSlug');
|
||||
const mkdirp = require('mkdirp');
|
||||
const glob = require('glob');
|
||||
const chalk = require('chalk');
|
||||
const translate = require('./translate.js');
|
||||
const translate = require('./translate');
|
||||
const {renderToStaticMarkupWithDoctype} = require('./renderUtils');
|
||||
|
||||
const feed = require('./feed.js');
|
||||
const sitemap = require('./sitemap.js');
|
||||
// const sitemap = require("sitemap");
|
||||
const feed = require('./feed');
|
||||
const sitemap = require('./sitemap');
|
||||
|
||||
const CWD = process.cwd();
|
||||
|
||||
|
@ -250,7 +248,7 @@ function execute(port) {
|
|||
</DocsLayout>
|
||||
);
|
||||
|
||||
res.send(renderToStaticMarkup(docComp));
|
||||
res.send(renderToStaticMarkupWithDoctype(docComp));
|
||||
});
|
||||
|
||||
app.get('/sitemap.xml', function(req, res) {
|
||||
|
@ -293,7 +291,7 @@ function execute(port) {
|
|||
config={siteConfig}
|
||||
/>
|
||||
);
|
||||
const str = renderToStaticMarkup(blogPageComp);
|
||||
const str = renderToStaticMarkupWithDoctype(blogPageComp);
|
||||
|
||||
let path = (page > 0 ? 'page' + (page + 1) : '') + '/index.html';
|
||||
blogPages[path] = str;
|
||||
|
@ -344,7 +342,7 @@ function execute(port) {
|
|||
{rawContent}
|
||||
</BlogPostLayout>
|
||||
);
|
||||
res.send(renderToStaticMarkup(blogPostComp));
|
||||
res.send(renderToStaticMarkupWithDoctype(blogPostComp));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -365,7 +363,7 @@ function execute(port) {
|
|||
if (siteConfig.wrapPagesHTML) {
|
||||
removeModuleAndChildrenFromCache(join('..', 'core', 'Site.js'));
|
||||
const Site = require(join('..', 'core', 'Site.js'));
|
||||
const str = renderToStaticMarkup(
|
||||
const str = renderToStaticMarkupWithDoctype(
|
||||
<Site
|
||||
language="en"
|
||||
config={siteConfig}
|
||||
|
@ -436,7 +434,7 @@ function execute(port) {
|
|||
removeModuleAndChildrenFromCache(join('..', 'core', 'Site.js'));
|
||||
const Site = require(join('..', 'core', 'Site.js'));
|
||||
translate.setLanguage(language);
|
||||
const str = renderToStaticMarkup(
|
||||
const str = renderToStaticMarkupWithDoctype(
|
||||
<Site
|
||||
language={language}
|
||||
config={siteConfig}
|
||||
|
@ -507,6 +505,7 @@ function execute(port) {
|
|||
});
|
||||
}
|
||||
|
||||
res.header('Content-Type', 'text/css');
|
||||
res.send(cssContent);
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue