|
|
@@ -1,26 +1,41 @@
|
|
|
import React from 'react';
|
|
|
|
|
|
+import fs from 'fs';
|
|
|
+
|
|
|
import Document, {
|
|
|
DocumentContext, DocumentInitialProps,
|
|
|
Html, Head, Main, NextScript,
|
|
|
} from 'next/document';
|
|
|
|
|
|
+import { resolveFromRoot } from '~/utils/project-dir-utils';
|
|
|
+
|
|
|
|
|
|
-// type GrowiDocumentProps = {};
|
|
|
-// declare type GrowiDocumentInitialProps = GrowiDocumentProps & DocumentInitialProps;
|
|
|
-declare type GrowiDocumentInitialProps = DocumentInitialProps;
|
|
|
+interface GrowiDocumentProps {
|
|
|
+ pluginsManifest: any;
|
|
|
+}
|
|
|
+declare type GrowiDocumentInitialProps = DocumentInitialProps & GrowiDocumentProps;
|
|
|
|
|
|
+async function importPluginsManifest(): Promise<any> {
|
|
|
+ const customManifestStr: string = await fs.readFileSync(resolveFromRoot('tmp/plugins/weseek/growi-plugin-jstest/dist/manifest.json'), 'utf-8');
|
|
|
+ return {
|
|
|
+ 'growi-plugin-jstest': JSON.parse(customManifestStr),
|
|
|
+ };
|
|
|
+}
|
|
|
|
|
|
-class GrowiDocument extends Document {
|
|
|
+class GrowiDocument extends Document<GrowiDocumentProps> {
|
|
|
|
|
|
static override async getInitialProps(ctx: DocumentContext): Promise<GrowiDocumentInitialProps> {
|
|
|
const initialProps: DocumentInitialProps = await Document.getInitialProps(ctx);
|
|
|
|
|
|
- return initialProps;
|
|
|
+ const pluginsManifest: any = await importPluginsManifest();
|
|
|
+
|
|
|
+ return { ...initialProps, pluginsManifest };
|
|
|
}
|
|
|
|
|
|
override render(): JSX.Element {
|
|
|
|
|
|
+ const { pluginsManifest } = this.props;
|
|
|
+
|
|
|
return (
|
|
|
<Html>
|
|
|
<Head>
|
|
|
@@ -28,6 +43,7 @@ class GrowiDocument extends Document {
|
|
|
{renderScriptTagsByGroup('basis')}
|
|
|
{renderStyleTagsByGroup('basis')}
|
|
|
*/}
|
|
|
+ <script type="module" src={`/plugins/weseek/growi-plugin-jstest/dist/${pluginsManifest['growi-plugin-jstest']['index.html'].file}`} />
|
|
|
</Head>
|
|
|
<body>
|
|
|
<Main />
|