Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/docusaurus/src/client/serverEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(), {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus/src/deps.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion packages/docusaurus/src/webpack/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -78,6 +82,7 @@ export default async function createServerConfig({
onHeadTagsCollected,
ssrTemplate: ssrTemplate ?? ssrDefaultTemplate,
noIndex,
DOCUSAURUS_VERSION,
},
paths: ssgPaths,
preferFoldersOutput: trailingSlash,
Expand Down