diff --git a/docusaurus.config.js b/docusaurus.config.js index eb4d2a3a8..1070f69ff 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -5,16 +5,16 @@ // But unsafe-eval should NOT be in production builds // Also, put GTM first because sometimes the ';' in the escaped single quotes causes the browser to think it's the end const scriptSrc = process.env.NODE_ENV === 'development' ? - `https://*.googletagmanager.com 'self' 'unsafe-inline' 'unsafe-eval'` - : `https://*.googletagmanager.com 'self' 'unsafe-inline'`; + `https://*.googletagmanager.com https://cdn.jsdelivr.net 'self' 'unsafe-inline' 'unsafe-eval'` + : `https://*.googletagmanager.com https://cdn.jsdelivr.net 'self' 'unsafe-inline'`; const contentSecurityPolicy = ` default-src 'none'; base-uri 'self'; manifest-src 'self'; script-src ${scriptSrc}; -style-src 'self' 'unsafe-inline'; -font-src 'self'; +style-src https://cdn.jsdelivr.net 'self' 'unsafe-inline'; +font-src https://cdn.jsdelivr.net 'self'; img-src 'self' https://*.googletagmanager.com https://*.google-analytics.com data:; media-src 'self'; form-action 'self'; @@ -22,138 +22,149 @@ connect-src 'self' https://*.algolia.net https://*.algolianet.com https://*.goog frame-src https://tezosbot.vercel.app;`; /** @type {import('@docusaurus/types').Config} */ -const config = { - title: 'Tezos Developer Documentation', - tagline: 'Get started developing on Tezos by learning about its features, going through application development tutorials, and exploring the tools that are available to Tezos developers.', - favicon: 'img/favicon.ico', - url: 'https://docs.tezos.com', - baseUrl: '/', - organizationName: 'trilitech', - projectName: 'tezos-developer-docs', - onBrokenLinks: 'warn', - onBrokenMarkdownLinks: 'warn', - onBrokenAnchors: 'warn', - i18n: { - defaultLocale: 'en', - locales: ['en'], - }, - markdown: { - mermaid: true, - }, - noIndex: process.env.BUILD_ENV == 'staging' ? true : false, +module.exports = async function createConfigAsync() { + return { + title: 'Tezos Developer Documentation', + tagline: 'Get started developing on Tezos by learning about its features, going through application development tutorials, and exploring the tools that are available to Tezos developers.', + favicon: 'img/favicon.ico', + url: 'https://docs.tezos.com', + baseUrl: '/', + organizationName: 'trilitech', + projectName: 'tezos-developer-docs', + onBrokenLinks: 'warn', + onBrokenMarkdownLinks: 'warn', + onBrokenAnchors: 'warn', + i18n: { + defaultLocale: 'en', + locales: ['en'], + }, + markdown: { + mermaid: true, + }, + noIndex: process.env.BUILD_ENV == 'staging' ? true : false, - headTags: [ - { - tagName: 'meta', - attributes: { - 'http-equiv': 'Content-Security-Policy', - content: contentSecurityPolicy, + headTags: [ + { + tagName: 'meta', + attributes: { + 'http-equiv': 'Content-Security-Policy', + content: contentSecurityPolicy, + }, }, - }, - ], + ], - themes: ['@docusaurus/theme-mermaid'], + themes: ['@docusaurus/theme-mermaid'], - presets: [ - [ - 'classic', - /** @type {import('@docusaurus/preset-classic').Options} */ - ({ - docs: { - sidebarPath: require.resolve('./sidebars.js'), - routeBasePath: '/', // Serve the docs at the site's root - showLastUpdateTime: true, - }, - blog: false, - theme: { - customCss: require.resolve('./src/css/custom.css'), - }, - googleTagManager: { - containerId: 'GTM-56M3FZ8', - }, - }), + presets: [ + [ + 'classic', + /** @type {import('@docusaurus/preset-classic').Options} */ + ({ + docs: { + sidebarPath: require.resolve('./sidebars.js'), + routeBasePath: '/', // Serve the docs at the site's root + remarkPlugins: [(await import('remark-math')).default], + rehypePlugins: [(await import('rehype-katex')).default], + showLastUpdateTime: true, + }, + blog: false, + theme: { + customCss: require.resolve('./src/css/custom.css'), + }, + googleTagManager: { + containerId: 'GTM-56M3FZ8', + }, + }), + ], ], - ], - plugins: [ - 'plugin-image-zoom', - ], + plugins: [ + 'plugin-image-zoom', + ], - themeConfig: - /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ - ({ - colorMode: { - defaultMode: 'light', - disableSwitch: true, - respectPrefersColorScheme: false, - }, - // Replace with your project's social card - image: 'img/docusaurus-social-card.jpg', - navbar: { - style: 'primary', - title: 'Tezos Docs', - logo: { - alt: 'Developer Docs for Tezos', - src: 'img/logo-tezos.svg', + themeConfig: + /** @type {import('@docusaurus/preset-classic').ThemeConfig} */ + ({ + colorMode: { + defaultMode: 'light', + disableSwitch: true, + respectPrefersColorScheme: false, }, - items: [ - { - type: 'docSidebar', - sidebarId: 'documentationSidebar', - position: 'left', - label: 'Documentation' - }, - { - type: 'docSidebar', - sidebarId: 'tutorialsSidebar', - position: 'left', - label: 'Tutorials', + // Replace with your project's social card + image: 'img/docusaurus-social-card.jpg', + navbar: { + style: 'primary', + title: 'Tezos Docs', + logo: { + alt: 'Developer Docs for Tezos', + src: 'img/logo-tezos.svg', }, - { - href: 'https://github.com/trilitech/tezos-developer-docs', - label: 'GitHub', - position: 'right', + items: [ + { + type: 'docSidebar', + sidebarId: 'documentationSidebar', + position: 'left', + label: 'Documentation' + }, + { + type: 'docSidebar', + sidebarId: 'tutorialsSidebar', + position: 'left', + label: 'Tutorials', + }, + { + href: 'https://github.com/trilitech/tezos-developer-docs', + label: 'GitHub', + position: 'right', + }, + ], + }, + prism: { + theme: require('prism-react-renderer/themes/github'), + additionalLanguages: ['csharp', 'toml', 'ocaml'], + }, + // https://github.com/flexanalytics/plugin-image-zoom + // Enable click to zoom in to large images + imageZoom: { + // CSS selector to apply the plugin to, defaults to '.markdown img' + selector: '.markdown img', + // Optional medium-zoom options + // see: https://www.npmjs.com/package/medium-zoom#options + options: { + margin: 24, + scrollOffset: 0, }, - ], - }, - prism: { - theme: require('prism-react-renderer/themes/github'), - additionalLanguages: ['csharp', 'toml', 'ocaml'], - }, - // https://github.com/flexanalytics/plugin-image-zoom - // Enable click to zoom in to large images - imageZoom: { - // CSS selector to apply the plugin to, defaults to '.markdown img' - selector: '.markdown img', - // Optional medium-zoom options - // see: https://www.npmjs.com/package/medium-zoom#options - options: { - margin: 24, - scrollOffset: 0, }, + algolia: { + // The application ID provided by Algolia + appId: process.env.NEXT_PUBLIC_DOCSEARCH_APP_ID || "QRIAHGML9Q", + // Public API key: it is safe to commit it + apiKey: process.env.NEXT_PUBLIC_DOCSEARCH_API_KEY || "57d6a376a3528866784a143809cc7427", + indexName: process.env.NEXT_PUBLIC_DOCSEARCH_INDEX_NAME || "tezosdocs", + // Optional: see doc section below + contextualSearch: true, + // Optional: Specify domains where the navigation should occur through window.location instead on history.push. Useful when our Algolia config crawls multiple documentation sites and we want to navigate with window.location.href to them. + // externalUrlRegex: 'external\\.com|domain\\.com', + // Optional: Replace parts of the item URLs from Algolia. Useful when using the same search index for multiple deployments using a different baseUrl. You can use regexp or string in the `from` param. For example: localhost:3000 vs myCompany.com/docs + // replaceSearchResultPathname: { + // from: '/docs/', // or as RegExp: /\/docs\// + // to: '/', + // }, + // Optional: Algolia search parameters + // searchParameters: {}, + // Optional: path for search page that enabled by default (`false` to disable it) + searchPagePath: false, + //... other Algolia params + }, + }), + stylesheets: [ + { + href: 'https://cdn.jsdelivr.net/npm/katex@0.13.24/dist/katex.min.css', + type: 'text/css', + integrity: + 'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM', + crossorigin: 'anonymous', }, - algolia: { - // The application ID provided by Algolia - appId: process.env.NEXT_PUBLIC_DOCSEARCH_APP_ID || "QRIAHGML9Q", - // Public API key: it is safe to commit it - apiKey: process.env.NEXT_PUBLIC_DOCSEARCH_API_KEY || "57d6a376a3528866784a143809cc7427", - indexName: process.env.NEXT_PUBLIC_DOCSEARCH_INDEX_NAME || "tezosdocs", - // Optional: see doc section below - contextualSearch: true, - // Optional: Specify domains where the navigation should occur through window.location instead on history.push. Useful when our Algolia config crawls multiple documentation sites and we want to navigate with window.location.href to them. - // externalUrlRegex: 'external\\.com|domain\\.com', - // Optional: Replace parts of the item URLs from Algolia. Useful when using the same search index for multiple deployments using a different baseUrl. You can use regexp or string in the `from` param. For example: localhost:3000 vs myCompany.com/docs - // replaceSearchResultPathname: { - // from: '/docs/', // or as RegExp: /\/docs\// - // to: '/', - // }, - // Optional: Algolia search parameters - // searchParameters: {}, - // Optional: path for search page that enabled by default (`false` to disable it) - searchPagePath: false, - //... other Algolia params - }, - }), + ], + }; }; - -module.exports = config; diff --git a/package-lock.json b/package-lock.json index fd7750e0a..d09ff378b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,8 @@ "prism-react-renderer": "1.3.5", "react": "18.2", "react-dom": "18.2", + "rehype-katex": "^7.0.1", + "remark-math": "^6.0.0", "slick-carousel": "1.8.1" }, "devDependencies": { @@ -4109,6 +4111,11 @@ "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.14.tgz", "integrity": "sha512-U3PUjAudAdJBeC2pgN8uTIKgxrb4nlDF3SF0++EldXQvQBGkpFZMSnwQiIoDU77tv45VgNkl/L4ouD+rEomujw==" }, + "node_modules/@types/katex": { + "version": "0.16.7", + "resolved": "https://registry.npmjs.org/@types/katex/-/katex-0.16.7.tgz", + "integrity": "sha512-HMwFiRujE5PjrgwHQ25+bsLJgowjGjm5Z8FVSf0N6PwgJrwxH0QxzHYDcKsTfV3wva0vzrpqMTJS2jXPr5BMEQ==" + }, "node_modules/@types/mdast": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.2.tgz", @@ -8390,6 +8397,68 @@ "node": ">= 0.4" } }, + "node_modules/hast-util-from-dom": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/hast-util-from-dom/-/hast-util-from-dom-5.0.1.tgz", + "integrity": "sha512-N+LqofjR2zuzTjCPzyDUdSshy4Ma6li7p/c3pA78uTwzFgENbgbUrm2ugwsOdcjI1muO+o6Dgzp9p8WHtn/39Q==", + "dependencies": { + "@types/hast": "^3.0.0", + "hastscript": "^9.0.0", + "web-namespaces": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-from-dom/node_modules/hastscript": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/hastscript/-/hastscript-9.0.0.tgz", + "integrity": "sha512-jzaLBGavEDKHrc5EfFImKN7nZKKBdSLIdGvCwDZ9TfzbF2ffXiov8CKE445L2Z1Ek2t/m4SKQ2j6Ipv7NyUolw==", + "dependencies": { + "@types/hast": "^3.0.0", + "comma-separated-tokens": "^2.0.0", + "hast-util-parse-selector": "^4.0.0", + "property-information": "^6.0.0", + "space-separated-tokens": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-from-html": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/hast-util-from-html/-/hast-util-from-html-2.0.3.tgz", + "integrity": "sha512-CUSRHXyKjzHov8yKsQjGOElXy/3EKpyX56ELnkHH34vDVw1N1XSQ1ZcAvTyAPtGqLTuKP/uxM+aLkSPqF/EtMw==", + "dependencies": { + "@types/hast": "^3.0.0", + "devlop": "^1.1.0", + "hast-util-from-parse5": "^8.0.0", + "parse5": "^7.0.0", + "vfile": "^6.0.0", + "vfile-message": "^4.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/hast-util-from-html-isomorphic": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/hast-util-from-html-isomorphic/-/hast-util-from-html-isomorphic-2.0.0.tgz", + "integrity": "sha512-zJfpXq44yff2hmE0XmwEOzdWin5xwH+QIhMLOScpX91e/NSGPsAzNCvLQDIEPyO2TXi+lBmU6hjLIhV8MwP2kw==", + "dependencies": { + "@types/hast": "^3.0.0", + "hast-util-from-dom": "^5.0.0", + "hast-util-from-html": "^2.0.0", + "unist-util-remove-position": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/hast-util-from-parse5": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/hast-util-from-parse5/-/hast-util-from-parse5-8.0.1.tgz", @@ -8409,6 +8478,18 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/hast-util-is-element": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/hast-util-is-element/-/hast-util-is-element-3.0.0.tgz", + "integrity": "sha512-Val9mnv2IWpLbNPqc/pUem+a7Ipj2aHacCwgNfTiK0vJKl0LF+4Ba4+v1oPHFpf3bLYmreq0/l3Gud9S5OH42g==", + "dependencies": { + "@types/hast": "^3.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/hast-util-parse-selector": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/hast-util-parse-selector/-/hast-util-parse-selector-4.0.0.tgz", @@ -8553,6 +8634,21 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/hast-util-to-text": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/hast-util-to-text/-/hast-util-to-text-4.0.2.tgz", + "integrity": "sha512-KK6y/BN8lbaq654j7JgBydev7wuNMcID54lkRav1P0CaE1e47P72AWWPiGKXTJU271ooYzcvTAn/Zt0REnvc7A==", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/unist": "^3.0.0", + "hast-util-is-element": "^3.0.0", + "unist-util-find-after": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/hast-util-whitespace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/hast-util-whitespace/-/hast-util-whitespace-3.0.0.tgz", @@ -10108,6 +10204,24 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/mdast-util-math": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mdast-util-math/-/mdast-util-math-3.0.0.tgz", + "integrity": "sha512-Tl9GBNeG/AhJnQM221bJR2HPvLOSnLE/T9cJI9tlc6zwQk2nPk/4f0cHkOdEixQPC/j8UtKDdITswvLAy1OZ1w==", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/mdast": "^4.0.0", + "devlop": "^1.0.0", + "longest-streak": "^3.0.0", + "mdast-util-from-markdown": "^2.0.0", + "mdast-util-to-markdown": "^2.1.0", + "unist-util-remove-position": "^5.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/mdast-util-mdx": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/mdast-util-mdx/-/mdast-util-mdx-3.0.0.tgz", @@ -11332,6 +11446,77 @@ } ] }, + "node_modules/micromark-extension-math": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/micromark-extension-math/-/micromark-extension-math-3.1.0.tgz", + "integrity": "sha512-lvEqd+fHjATVs+2v/8kg9i5Q0AP2k85H0WUOwpIVvUML8BapsMvh1XAogmQjOCsLpoKRCVQqEkQBB3NhVBcsOg==", + "dependencies": { + "@types/katex": "^0.16.0", + "devlop": "^1.0.0", + "katex": "^0.16.0", + "micromark-factory-space": "^2.0.0", + "micromark-util-character": "^2.0.0", + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, + "node_modules/micromark-extension-math/node_modules/micromark-factory-space": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.1.tgz", + "integrity": "sha512-zRkxjtBxxLd2Sc0d+fbnEunsTj46SWXgXciZmHq0kDYGnck/ZSGj9/wULTV95uoeYiK5hRXP2mJ98Uo4cq/LQg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-extension-math/node_modules/micromark-util-character": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.1.tgz", + "integrity": "sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "dependencies": { + "micromark-util-symbol": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, + "node_modules/micromark-extension-math/node_modules/micromark-util-symbol": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/micromark-util-symbol/-/micromark-util-symbol-2.0.1.tgz", + "integrity": "sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ] + }, "node_modules/micromark-extension-mdx-expression": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/micromark-extension-mdx-expression/-/micromark-extension-mdx-expression-3.0.0.tgz", @@ -14681,6 +14866,24 @@ "jsesc": "bin/jsesc" } }, + "node_modules/rehype-katex": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/rehype-katex/-/rehype-katex-7.0.1.tgz", + "integrity": "sha512-OiM2wrZ/wuhKkigASodFoo8wimG3H12LWQaH8qSPVJn9apWKFSH3YOCtbKpBorTVw/eI7cuT21XBbvwEswbIOA==", + "dependencies": { + "@types/hast": "^3.0.0", + "@types/katex": "^0.16.0", + "hast-util-from-html-isomorphic": "^2.0.0", + "hast-util-to-text": "^4.0.0", + "katex": "^0.16.0", + "unist-util-visit-parents": "^6.0.0", + "vfile": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/rehype-raw": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/rehype-raw/-/rehype-raw-7.0.0.tgz", @@ -14796,6 +14999,21 @@ "url": "https://opencollective.com/unified" } }, + "node_modules/remark-math": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/remark-math/-/remark-math-6.0.0.tgz", + "integrity": "sha512-MMqgnP74Igy+S3WwnhQ7kqGlEerTETXMvJhrUzDikVZ2/uogJCb+WHUg97hK9/jcfc0dkD73s3LN8zU49cTEtA==", + "dependencies": { + "@types/mdast": "^4.0.0", + "mdast-util-math": "^3.0.0", + "micromark-extension-math": "^3.0.0", + "unified": "^11.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/remark-mdx": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/remark-mdx/-/remark-mdx-3.0.1.tgz", @@ -16448,6 +16666,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/unist-util-find-after": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/unist-util-find-after/-/unist-util-find-after-5.0.0.tgz", + "integrity": "sha512-amQa0Ep2m6hE2g72AugUItjbuM8X8cGQnFoHk0pGfrFeT9GZhzN5SW8nRsiGKK7Aif4CrACPENkA6P/Lw6fHGQ==", + "dependencies": { + "@types/unist": "^3.0.0", + "unist-util-is": "^6.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/unified" + } + }, "node_modules/unist-util-is": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-6.0.0.tgz", diff --git a/package.json b/package.json index 86591c507..728051cef 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,8 @@ "prism-react-renderer": "1.3.5", "react": "18.2", "react-dom": "18.2", + "rehype-katex": "7.0.1", + "remark-math": "6.0.0", "slick-carousel": "1.8.1" }, "devDependencies": {