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

Move plugins and theme to src #1549

Closed
wants to merge 8 commits into from
Closed
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 docs/learn/glossary.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ title: Glossary
description: Glossary of all specialized names and phrases used in the IOTA and Shimmer networks. If you dont understand a wording you will find answers here.
---

import Glossary from '/theme/src/theme/Glossary';
import Glossary from '@theme/Glossary';

<Glossary />
10 changes: 0 additions & 10 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -432,19 +432,9 @@ module.exports = async () => {
],
'plugin-image-zoom',
],
stylesheets: [
{
href: 'https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.css',
type: 'text/css',
integrity:
'sha384-odtC+0UGzzFL/6PNoE8rX/SPcQDXBJ+uRepguP4QkPCm2LBxH3FA3y+fKSiJ+AmM',
crossorigin: 'anonymous',
},
],
themes: [
'docusaurus-theme-openapi-docs',
'@saucelabs/theme-github-codeblock',
'@iota-wiki/theme',
],
staticDirectories: [path.resolve(__dirname, 'static')],
},
Expand Down
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"version": "1.1.0",
"scripts": {
"build:cli": "yarn ./cli build",
"build:plugins": "yarn ./plugins/tutorial build && yarn ./plugins/docs build",
"build:theme": "yarn ./theme build",
"checkout": "git submodule update --init",
"checkout:remote": "yarn checkout --remote",
"generate:api": "docusaurus gen-api-docs all && ./scripts/get_sdk_references.sh && ./scripts/get_wasp_references.sh",
Expand All @@ -16,7 +14,7 @@
"format": "prettier --cache --write .",
"format:check": "prettier --cache --check .",
"format:svg": "svgo ./src/**/*.svg",
"prepare": "yarn build:plugins && yarn build:theme && yarn checkout",
"prepare": "yarn checkout",
"docusaurus": "docusaurus",
"start": "NODE_OPTIONS='--max-old-space-size=4096' docusaurus start",
"start:section:build": "SELECTED_SECTION='build' yarn start",
Expand All @@ -33,14 +31,12 @@
},
"dependencies": {
"@algolia/client-search": "^4.22.1",
"@artsy/to-title-case": "^1.1.0",
"@docusaurus/core": "2.4.3",
"@docusaurus/plugin-client-redirects": "2.4.3",
"@docusaurus/preset-classic": "2.4.3",
"@docusaurus/remark-plugin-npm2yarn": "^2.4.3",
"@docusaurus/theme-common": "2.4.3",
"@iota-wiki/plugin-docs": "workspace:^",
"@iota-wiki/plugin-tutorial": "workspace:^",
"@iota-wiki/theme": "workspace:^",
"@mdx-js/react": "^1.6.21",
"@popperjs/core": "^2.11.5",
"@saucelabs/theme-github-codeblock": "^0.2.3",
Expand All @@ -54,6 +50,7 @@
"flickity-fade": "^2.0.0",
"globby": "^13.1.4",
"hast-util-is-element": "1.1.0",
"html-react-parser": "^5.1.10",
"humanize-duration": "^3.30.0",
"infima": "^0.2.0-alpha.43",
"plugin-image-zoom": "flexanalytics/plugin-image-zoom",
Expand All @@ -75,6 +72,7 @@
"remark-remove-comments": "^0.2.0",
"url-loader": "^4.1.1",
"utf-8-validate": "^6.0.3",
"web3": "^4.8.0",
"webpack": "^5.89.0",
"webpack-node-externals": "^3.0.0",
"ws": "^8.16.0"
Expand Down
10 changes: 0 additions & 10 deletions plugins/docs/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion plugins/docs/.yarnrc.yml

This file was deleted.

24 changes: 0 additions & 24 deletions plugins/docs/package.json

This file was deleted.

12 changes: 0 additions & 12 deletions plugins/docs/tsconfig.json

This file was deleted.

10 changes: 0 additions & 10 deletions plugins/tutorial/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion plugins/tutorial/.yarnrc.yml

This file was deleted.

20 changes: 0 additions & 20 deletions plugins/tutorial/package.json

This file was deleted.

32 changes: 0 additions & 32 deletions plugins/tutorial/src/index.ts

This file was deleted.

12 changes: 0 additions & 12 deletions plugins/tutorial/tsconfig.json

This file was deleted.

File renamed without changes.
File renamed without changes.
21 changes: 6 additions & 15 deletions plugins/docs/src/index.ts → src/plugins/docs/index.mjs
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
import type { LoadContext, Plugin } from '@docusaurus/types';
import { LoadedContent, OptionValidationContext, PluginOptions } from './types';
import docsPlugin, {
validateOptions as docsValidateOptions,
PropVersionMetadata,
} from '@docusaurus/plugin-content-docs';
import fs from 'fs/promises';
import path from 'path';

export default async function pluginDocs(
context: LoadContext,
options: PluginOptions,
): Promise<Plugin<LoadedContent>> {
export default async function pluginDocs(context, options) {
// Destructure to separate the Docusaurus docs plugin options
// and initialize the Docusaurus docs plugin to wrap.
const { bannerPath, globalSidebars, ...docsOptions } = options;
const plugin = await docsPlugin(context, docsOptions);
const plugin = await docsPlugin.default(context, docsOptions);

return {
...plugin,
Expand Down Expand Up @@ -56,9 +50,9 @@ export default async function pluginDocs(
const { bannerContent, ...docsContent } = content;
const globalSidebarEntries = [];

const createData = async (name: string, data: string) => {
const createData = async (name, data) => {
// Hook into the `createData` call to extract the sidebars we need.
const versionMetadata = JSON.parse(data) as PropVersionMetadata;
const versionMetadata = JSON.parse(data);
if (versionMetadata.docsSidebars) {
// We can do this, because all `createData` calls are assured
// to resolve before `setGlobalData` is called.
Expand All @@ -81,7 +75,7 @@ export default async function pluginDocs(
);
};

const setGlobalData = (data: object) => {
const setGlobalData = (data) => {
actions.setGlobalData({
...data,
globalSidebars: Object.fromEntries(globalSidebarEntries),
Expand All @@ -101,10 +95,7 @@ export default async function pluginDocs(
};
}

export function validateOptions({
validate,
options,
}: OptionValidationContext): PluginOptions {
export function validateOptions({ validate, options }) {
const { bannerPath, globalSidebars = [], ...docsOptions } = options;
return {
...docsValidateOptions({ validate, options: docsOptions }),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 19 additions & 0 deletions src/plugins/tutorial/index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default function pluginTutorial(options) {
return {
name: '@iota-wiki/plugin-tutorial',
async contentLoaded({ actions }) {
actions.setGlobalData(options);
},
};
}

export function validateOptions({ options: userOptions }) {
const id = userOptions.title.normalize().toLowerCase().replace(/\W/, '-');

const defaultOptions = {
id,
route: id,
};

return Object.assign(defaultOptions, userOptions);
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { useDoc } from '@docusaurus/theme-common/internal';
import { DocMetadata } from '@iota-wiki/plugin-docs';
import ReactMarkdown from 'react-markdown';
import type { DocMetadata } from '../../plugins/docs/types.d.ts';
import './styles.css';

export default function DocBanner() {
const ReactMarkdown = require('react-markdown');

const { bannerContent } = useDoc().metadata as DocMetadata;

if (!bannerContent) return null;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import Heading from '@theme/Heading';
import { toTitleCase } from '@artsy/to-title-case';
import { clsx } from 'clsx';
import parse from 'html-react-parser';

export default function Glossary() {
const glossary = require('@site/common/jargon.js');
const parse = require('html-react-parser');

const sortedGlossary = Object.keys(glossary)
.sort(function (a, b) {
Expand Down
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ async function globStatic(pattern, cwd = __dirname) {
* @param {import('@docusaurus/plugin-content-docs').Options} options
*/
async function create_doc_plugin({ ...options }) {
const pluginDocs = (await import('../plugins/docs/index.mjs')).default;
const setting = await defaultSettings();

// Check if options has a rehypePlugin array
Expand All @@ -129,8 +130,8 @@ async function create_doc_plugin({ ...options }) {
}

return [
'@iota-wiki/plugin-docs',
/** @type {import('@iota-wiki/plugin-docs').Options} */
pluginDocs,
/** @type {import('@site/src/plugins/docs/types').Options} */
({
...setting,
...options,
Expand Down
1 change: 0 additions & 1 deletion theme/.gitignore

This file was deleted.

Loading
Loading