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

Update Docusaurus to 3.2.0 #303

Merged
merged 11 commits into from
Apr 4, 2024
Merged

Conversation

homotechsual
Copy link
Contributor

No description provided.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 2, 2024
Copy link

netlify bot commented Apr 2, 2024

Deploy Preview for infima ready!

Name Link
🔨 Latest commit
🔍 Latest deploy log https://app.netlify.com/sites/infima/deploys/660eaa561d33fd1e622a36e7
😎 Deploy Preview https://deploy-preview-303--infima.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@homotechsual homotechsual changed the title Update Docusaurus to 3.2.0 [WIP] Update Docusaurus to 3.2.0 Apr 2, 2024
@homotechsual
Copy link
Contributor Author

My major stumbling block on this now is getting playground.js working with MDXv3/Docusaurus v3. Hit a bit of a road block on it.

@slorber
Copy link
Collaborator

slorber commented Apr 4, 2024

I'll take a look but can you please add me as admin or member to the docusaurus community org? I can't push on your branch otherwise because it's an org I guess.

@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

const visit = require('unist-util-visit');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works:

/**
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

import {visit} from 'unist-util-visit';

const codeBlockTitleRegex =
  /containerClassName=(?<quote>["'])(?<containerClassName>.*?)\1/;

module.exports = function plugin() {
  const transformer = (root) => {
    visit(root, 'code', (node, index, parent) => {
      if (node.lang === 'html') {
        const containerClassName =
          node.meta?.match(codeBlockTitleRegex)?.groups.containerClassName;

        const html = node.value;

        const playgroundElement = {
          type: 'mdxJsxFlowElement',
          name: 'div',
          attributes: [
            {
              type: 'mdxJsxAttribute',
              name: 'className',
              value: containerClassName,
            },
            {
              type: 'mdxJsxAttribute',
              name: 'dangerouslySetInnerHTML',
              value: {
                type: 'mdxJsxAttributeValueExpression',
                data: {
                  estree: {
                    type: 'Program',
                    body: [
                      {
                        type: 'ExpressionStatement',
                        expression: {
                          type: 'ObjectExpression',
                          properties: [
                            {
                              type: 'Property',
                              kind: 'init',
                              key: {
                                type: 'Identifier',
                                name: '__html',
                              },
                              value: {
                                type: 'Literal',
                                value: `\`${html}\``,
                              },
                            },
                          ],
                        },
                      },
                    ],
                  },
                },
              },
            },
          ],
        };

        const lineBreakElement = {
          type: 'mdxJsxFlowElement',
          name: 'br',
        };

        const elementsToInsert = [playgroundElement, lineBreakElement];

        parent.children.splice(
          parent.children.indexOf(node),
          0,
          ...elementsToInsert,
        );

        return index + elementsToInsert.length + 1;
      }
    });
  };
  return transformer;
};

@homotechsual
Copy link
Contributor Author

I'll take a look but can you please add me as admin or member to the docusaurus community org? I can't push on your branch otherwise because it's an org I guess.

Done - gave you owner permissions so you can add other Docusaurus contributors I'll be moving over a few plugins and the Docusaurus.community website source shortly.

@slorber slorber changed the title [WIP] Update Docusaurus to 3.2.0 Update Docusaurus to 3.2.0 Apr 4, 2024
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks 👍

@slorber slorber merged commit 5d91576 into facebookincubator:main Apr 4, 2024
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants