fix(core): inject docusaurus version into SSR as local (#7329)

* Revert "fix(core): handle case where package.json is not available at CWD (#7187)"

This reverts commit 3b32a41f22.

* properly fix

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
Reece Dunham 2022-05-04 21:10:47 -04:00 committed by GitHub
parent 78400541cb
commit d3f526fd8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -26,7 +26,6 @@ import logger from '@docusaurus/logger';
// eslint-disable-next-line no-restricted-imports
import _ from 'lodash';
import type {Locals} from '@slorber/static-site-generator-webpack-plugin';
import {DOCUSAURUS_VERSION} from '@docusaurus/utils';
const getCompiledSSRTemplate = _.memoize((template: string) =>
eta.compile(template.trim(), {
@ -72,6 +71,7 @@ async function doRender(locals: Locals & {path: string}) {
baseUrl,
ssrTemplate,
noIndex,
DOCUSAURUS_VERSION,
} = locals;
const location = routesLocation[locals.path]!;
await preload(location);

View file

@ -52,6 +52,7 @@ declare module '@slorber/static-site-generator-webpack-plugin' {
baseUrl: string;
ssrTemplate: string;
noIndex: boolean;
DOCUSAURUS_VERSION: string;
};
export default class StaticSiteGeneratorPlugin

View file

@ -13,7 +13,11 @@ import type {Props} from '@docusaurus/types';
import {createBaseConfig} from './base';
import WaitPlugin from './plugins/WaitPlugin';
import LogPlugin from './plugins/LogPlugin';
import {NODE_MAJOR_VERSION, NODE_MINOR_VERSION} from '@docusaurus/utils';
import {
NODE_MAJOR_VERSION,
NODE_MINOR_VERSION,
DOCUSAURUS_VERSION,
} from '@docusaurus/utils';
import ssrDefaultTemplate from './templates/ssr.html.template';
// Forked for Docusaurus: https://github.com/slorber/static-site-generator-webpack-plugin
@ -78,6 +82,7 @@ export default async function createServerConfig({
onHeadTagsCollected,
ssrTemplate: ssrTemplate ?? ssrDefaultTemplate,
noIndex,
DOCUSAURUS_VERSION,
},
paths: ssgPaths,
preferFoldersOutput: trailingSlash,