mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
Merge pull request #275 from rickyvetter/wrapPagesHTML
add wrapPagesHTML which renders html snippets in pages inside of a header + footer
This commit is contained in:
commit
ce338fff64
2 changed files with 23 additions and 1 deletions
|
@ -447,6 +447,16 @@ function execute() {
|
|||
writeFileAndCreateFolder(targetFile.replace('/en/', '/'), str);
|
||||
}
|
||||
fs.removeSync(tempFile);
|
||||
} else if (siteConfig.wrapPagesHTML && file.match(/\.html$/)) {
|
||||
const parts = file.split('pages');
|
||||
const targetFile = join(buildDir, parts[1]);
|
||||
const str = renderToStaticMarkup(
|
||||
<Site language="en" config={siteConfig}>
|
||||
<div dangerouslySetInnerHTML={{__html: fs.readFileSync(file, { encoding: "utf8" })}} />
|
||||
</Site>
|
||||
);
|
||||
|
||||
writeFileAndCreateFolder(targetFile, str);
|
||||
} else if (!fs.lstatSync(file).isDirectory()) {
|
||||
// copy other non .js files
|
||||
let parts = file.split('pages');
|
||||
|
|
|
@ -371,7 +371,19 @@ function execute(port) {
|
|||
))
|
||||
)
|
||||
) {
|
||||
res.send(fs.readFileSync(htmlFile, {encoding: 'utf8'}));
|
||||
if (siteConfig.wrapPagesHTML) {
|
||||
removeModuleAndChildrenFromCache("../core/Site.js");
|
||||
const Site = require("../core/Site.js");
|
||||
const str = renderToStaticMarkup(
|
||||
<Site language="en" config={siteConfig}>
|
||||
<div dangerouslySetInnerHTML={{__html: fs.readFileSync(htmlFile, { encoding: "utf8" })}} />
|
||||
</Site>
|
||||
);
|
||||
|
||||
res.send(str);
|
||||
} else {
|
||||
res.send(fs.readFileSync(htmlFile, { encoding: "utf8" }));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue