Tag: Code Snippet

  • Build a Dynamic React Component for a Simple Interactive Code Snippet Display

    In the world of web development, sharing code snippets is a common practice. Whether you’re teaching a concept, demonstrating a solution, or simply showcasing your work, the ability to display code effectively is crucial. However, simply pasting code into a blog post or website can be clunky and difficult to read. Wouldn’t it be great to have a dynamic component that not only displays code beautifully but also allows users to easily copy it, enhancing the overall user experience? In this tutorial, we’ll build a React component designed precisely for this purpose. We’ll explore the core concepts, step-by-step implementation, and best practices to create a reusable and user-friendly code snippet display.

    Why Build a Code Snippet Display Component?

    The need for a well-designed code snippet display extends beyond mere aesthetics. Consider these benefits:

    • Improved Readability: Syntax highlighting, line numbers, and proper indentation make code easier to understand.
    • Enhanced User Experience: A copy-to-clipboard feature simplifies the process of using the code.
    • Reusability: A component can be used across multiple projects or within a single project, promoting consistency.
    • SEO Benefits: Well-formatted code snippets are more likely to be indexed correctly by search engines.

    By building a custom component, we can tailor its functionality and appearance to meet specific needs, resulting in a more professional and user-friendly presentation of code.

    Prerequisites

    Before diving into the code, ensure you have the following:

    • A basic understanding of React and JavaScript.
    • Node.js and npm (or yarn) installed on your system.
    • A code editor (e.g., VS Code, Sublime Text).
    • Familiarity with functional components and JSX.

    Step-by-Step Implementation

    Let’s create a React component that displays code snippets with syntax highlighting and a copy-to-clipboard button. We’ll use the following technologies:

    • React: For building the component.
    • Prism.js: A lightweight library for syntax highlighting.
    • clipboard.js: A library for copying text to the clipboard.

    1. Project Setup

    First, create a new React project using Create React App:

    npx create-react-app code-snippet-display
    cd code-snippet-display
    

    Next, install the necessary dependencies:

    npm install prismjs clipboard --save
    

    2. Component Structure

    Create a new file named `CodeSnippet.js` inside the `src` folder. This will be our main component. We’ll start with a basic structure:

    import React, { useEffect, useRef } from 'react';
    import Prism from 'prismjs';
    import 'prismjs/themes/prism.css'; // Import a Prism theme
    import ClipboardJS from 'clipboard';
    
    function CodeSnippet(props) {
      const codeRef = useRef(null);
      const copyButtonRef = useRef(null);
    
      useEffect(() => {
        Prism.highlightAll();
    
        // Initialize clipboard.js
        new ClipboardJS(copyButtonRef.current, {
          text: () => {
            return codeRef.current.textContent;
          },
        });
      }, []);
    
      return (
        <div className="code-snippet-container">
          <pre className="code-snippet"><code ref={codeRef} className={`language-${props.language}`}>{props.code}</code></pre>
          <button ref={copyButtonRef} className="copy-button" data-clipboard-text="">Copy</button>
        </div>
      );
    }
    
    export default CodeSnippet;
    

    Let’s break down the code:

    • Imports: We import `React`, `useEffect`, and `useRef` from React, `Prism` for syntax highlighting, a Prism theme (e.g., `prism.css`), and `ClipboardJS` for the copy-to-clipboard functionality.
    • `CodeSnippet` Function: This is our functional component. It receives `props` as input.
    • `useRef` Hooks: `codeRef` is used to reference the `` element containing the code, and `copyButtonRef` is used to reference the copy button.</li>
      <li><b>`useEffect` Hook:</b> This hook runs after the component renders.</li>
      <ul>
      <li>`Prism.highlightAll()`: This line runs Prism's syntax highlighting on all elements with the `code` tag. It's crucial for applying the syntax highlighting styles.</li>
      <li>Clipboard Initialization: This initializes `clipboard.js`. We pass the copy button ref and a function to get the text to copy.</li>
      </ul>
      <li><b>JSX Structure:</b>
      <ul>
      <li>`<div className="code-snippet-container">`: This is the main container for the component.</li>
      <li>`<pre className="code-snippet">`: This is the preformatted text container.</li>
      <li>`<code ref={codeRef} className={`language-${props.language}`}>`: The `<code>` element, where the code will be displayed. It uses the `language` prop to specify the code's language (e.g., `javascript`, `python`).</li>
      <li>`<button ref={copyButtonRef} className="copy-button" data-clipboard-text="">Copy</button>`: The copy button.</li>
      </ul>
      </ul>

      <h3>3. Styling</h3>

      <p>Create a `CodeSnippet.css` file in the `src` folder and add the following styles:</p>

      <pre><code class="language-css">.code-snippet-container {
      position: relative;
      margin-bottom: 20px;
      border: 1px solid #ddd;
      border-radius: 4px;
      overflow: hidden;
      }

      .code-snippet {
      padding: 10px;
      margin: 0;
      overflow-x: auto; /* Adds a horizontal scrollbar if the code is too long */
      }

      .copy-button {
      position: absolute;
      top: 5px;
      right: 5px;
      padding: 5px 10px;
      background-color: #333;
      color: white;
      border: none;
      border-radius: 4px;
      cursor: pointer;
      font-size: 0.8em;
      }

      .copy-button:hover {
      background-color: #555;
      }

      Import the CSS file into `CodeSnippet.js`:

      import './CodeSnippet.css';
      

      4. Using the Component

      Now, let’s use the `CodeSnippet` component in your `App.js` file:

      import React from 'react';
      import CodeSnippet from './CodeSnippet';
      
      function App() {
        const codeExample = `function greet(name) {
        console.log(`Hello, ${name}!`);
      }
      
      greet("World");`;
      
        return (
          <div className="App">
            <h2>Code Snippet Example</h2>
            <CodeSnippet code={codeExample} language="javascript" />
          </div>
        );
      }
      
      export default App;
      

      In this example:

      • We import the `CodeSnippet` component.
      • We define a `codeExample` string containing the JavaScript code.
      • We render the `CodeSnippet` component, passing the `code` and `language` props.

      5. Running the Application

      Start your React application:

      npm start
      

      You should see the code snippet displayed with syntax highlighting and a copy button.

      Adding More Features

      Here are some ways to enhance your code snippet display component:

      • Line Numbers: Integrate a library like `prismjs-line-numbers` to display line numbers.
      • Expand/Collapse: Add a feature to expand or collapse the code snippet, especially useful for longer code blocks.
      • Themes: Allow users to select different Prism themes for customization.
      • Error Handling: Handle cases where the code prop is missing or invalid.
      • Loading State: Display a loading indicator while the code is being highlighted.

      Common Mistakes and How to Fix Them

      Here are some common pitfalls and how to avoid them:

      • Incorrect Prism Theme: Make sure you import a Prism theme correctly. Without a theme, the code won’t be styled.
      • Missing Language Class: The `` element needs the correct `language-*` class (e.g., `language-javascript`).
      • Prism Not Highlighting: Ensure you call `Prism.highlightAll()` after the component renders. If the code changes dynamically, you might need to call it again.
      • Clipboard.js Not Working: Double-check that you've correctly initialized `clipboard.js` and that the `data-clipboard-text` attribute is set correctly.
      • CSS Conflicts: Be mindful of CSS conflicts. Use CSS modules or a naming convention to avoid conflicts with other styles in your application.

      Key Takeaways

      • Component Reusability: Build components to avoid code duplication.
      • Syntax Highlighting: Use libraries like Prism.js to improve readability.
      • User Experience: Add features like a copy-to-clipboard button.
      • Error Handling: Consider potential issues and implement solutions.

      FAQ

      Q: How do I change the Prism theme?

      A: Simply import a different CSS theme from the `prismjs/themes/` directory (e.g., `prism-okaidia.css`, `prism-tomorrow.css`).

      Q: How do I support different programming languages?

      A: Make sure you include the necessary Prism plugins for the languages you want to support. Also, ensure the `language` prop passed to the `CodeSnippet` component matches the Prism language class (e.g., `javascript`, `python`, `java`).

      Q: How can I add line numbers?

      A: Install and import the `prismjs-line-numbers` plugin. You'll also need to add the appropriate CSS and modify your component's JSX to include the line numbers.

      Q: My copy button isn't working. What should I check?

      A: Verify that `clipboard.js` is correctly initialized, that the `data-clipboard-text` attribute on the copy button is populated with the correct code, and that you've included the `clipboard.js` library correctly.

      Q: Can I use this component in a production environment?

      A: Yes, this component is designed to be reusable and can be used in a production environment. Consider adding more features like theme selection, error handling, and more robust styling for a polished user experience. Ensure you optimize the component for performance, particularly if you'll be displaying many code snippets on a single page.

      Building a custom code snippet display component is a rewarding project that significantly improves the presentation and usability of code within your web applications. By following the steps outlined in this tutorial, you've created a functional component that provides syntax highlighting and a copy-to-clipboard feature. Remember that the code is just a starting point. Experiment with different Prism themes, add features like line numbers and expand/collapse functionality, and tailor the component to your specific needs. The ability to display code effectively is a valuable skill for any web developer, making this component a practical and beneficial addition to your toolkit. With a well-designed code snippet display, you can create a more engaging and informative experience for your users, whether you're building a blog, documentation site, or any other web application that involves sharing code. The key is to refine the component based on your project requirements and the specific needs of your audience, ensuring that the presentation of the code is both visually appealing and highly functional.

  • Build a Simple React Component for a Dynamic Code Snippet Display

    In the digital age, sharing and understanding code snippets is a fundamental skill for developers. Whether you’re collaborating with colleagues, teaching a coding class, or contributing to open-source projects, the ability to present code clearly and effectively is crucial. Imagine trying to explain a complex algorithm through a wall of text, or struggling to maintain code formatting across different platforms. The challenges are real: readability suffers, errors creep in, and the learning curve steepens. This is where a dynamic code snippet display component in React can become an invaluable tool.

    Why Build a Dynamic Code Snippet Display?

    A well-designed code snippet display solves several problems:

    • Improved Readability: Syntax highlighting, line numbers, and proper indentation make code easier to scan and understand.
    • Enhanced Learning: Code becomes more accessible, facilitating learning and comprehension, especially for beginners.
    • Simplified Sharing: Easily share code snippets across various platforms without losing formatting.
    • Reduced Errors: Clear formatting helps in identifying and preventing errors.

    Setting Up Your React Project

    Before diving into the code, make sure you have Node.js and npm (or yarn) installed on your system. If you don’t have these, you can download them from the official Node.js website. Then, create a new React app using Create React App:

    npx create-react-app code-snippet-display
    cd code-snippet-display

    This command sets up a basic React project with all the necessary dependencies. Now, let’s install a library for syntax highlighting. There are several options available; for this tutorial, we’ll use ‘prismjs’. Run the following command:

    npm install prismjs react-prism --save

    Or, if you prefer yarn:

    yarn add prismjs react-prism

    ‘prismjs’ is a lightweight library that provides syntax highlighting for a wide range of programming languages. ‘react-prism’ is a React component that simplifies the integration of prismjs into your React application.

    Creating the CodeSnippet Component

    Inside your ‘src’ directory, create a new file named ‘CodeSnippet.js’. This will be our component. Let’s start with the basic structure:

    import React from 'react';
    import Prism from 'react-prism';
    
    function CodeSnippet(props) {
      return (
        <div className="code-snippet-container">
          <pre className="language-javascript">
            <code>
              {props.code}
            </code>
          </pre>
        </div>
      );
    }
    
    export default CodeSnippet;

    In this basic structure, we import ‘react’ and ‘react-prism’. We create a functional component ‘CodeSnippet’ that receives a ‘code’ prop. This prop will hold the code snippet we want to display. We render this code inside a ‘pre’ tag with the class ‘language-javascript’ (you can change this to match the language of your code) and the ‘code’ tag to render the code. The ‘code-snippet-container’ div is used for styling purposes. Make sure you import Prism from ‘react-prism’.

    Adding Styling

    To make the code snippet look good, we need to add some CSS. Create a file named ‘CodeSnippet.css’ in the same directory and add the following styles:

    .code-snippet-container {
      background-color: #f8f8f8;
      border: 1px solid #ddd;
      border-radius: 4px;
      overflow: auto;
      margin-bottom: 1em;
    }
    
    .code-snippet-container pre {
      padding: 1em;
      margin: 0;
      font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
      font-size: 14px;
      line-height: 1.4;
    }
    
    .code-snippet-container code {
      display: block;
      padding: 0;
    }
    

    These styles provide a basic appearance for the code snippet container, including background color, border, padding, and a monospace font for better readability. Import this CSS file into your ‘CodeSnippet.js’ file:

    import React from 'react';
    import Prism from 'react-prism';
    import './CodeSnippet.css'; // Import the CSS file
    
    function CodeSnippet(props) {
      return (
        <div className="code-snippet-container">
          <pre className="language-javascript">
            <code>
              {props.code}
            </code>
          </pre>
        </div>
      );
    }
    
    export default CodeSnippet;

    Using the CodeSnippet Component

    Now, let’s use the ‘CodeSnippet’ component in your ‘App.js’ file. Replace the existing content with the following:

    import React from 'react';
    import CodeSnippet from './CodeSnippet';
    
    function App() {
      const code = `function greet(name) {
      console.log(`Hello, ${name}!`);
    }
    
    greet("World");`;
    
      return (
        <div className="App">
          <h2>Code Snippet Example</h2>
          <CodeSnippet code={code} />
        </div>
      );
    }
    
    export default App;

    Here, we import the ‘CodeSnippet’ component and define a ‘code’ variable containing a JavaScript code snippet. We pass this code as a prop to the ‘CodeSnippet’ component. When you run your application (npm start or yarn start), you should see the code snippet rendered with syntax highlighting.

    Advanced Features and Customization

    Syntax Highlighting

    The core of the component is the syntax highlighting. Prism.js automatically detects the language based on the class name of the ‘pre’ tag (e.g., ‘language-javascript’). You can easily support other languages by changing this class name. For example, for Python, you would use ‘language-python’.

    Line Numbers

    To add line numbers, you can use a Prism.js plugin. First, install the plugin:

    npm install prismjs --save

    Then, import the plugin in your ‘CodeSnippet.js’ file and apply it.

    import React from 'react';
    import Prism from 'react-prism';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
    import './CodeSnippet.css';
    
    function CodeSnippet(props) {
      return (
        <div className="code-snippet-container">
          <pre className="language-javascript line-numbers">
            <code>
              {props.code}
            </code>
          </pre>
        </div>
      );
    }
    
    export default CodeSnippet;

    Add the class ‘line-numbers’ to the ‘pre’ tag. This will enable line numbering. Also, import the CSS and JS files for the line numbers plugin. This will add line numbers to your code snippets.

    Dynamic Language Selection

    Instead of hardcoding the language, you can make it dynamic by accepting a ‘language’ prop. Modify your ‘CodeSnippet.js’ file:

    import React from 'react';
    import Prism from 'react-prism';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
    import './CodeSnippet.css';
    
    function CodeSnippet(props) {
      const { code, language } = props;
      return (
        <div className="code-snippet-container">
          <pre className={`language-${language} line-numbers`}>
            <code>
              {code}
            </code>
          </pre>
        </div>
      );
    }
    
    export default CodeSnippet;

    Update your ‘App.js’ file to use the ‘language’ prop:

    import React from 'react';
    import CodeSnippet from './CodeSnippet';
    
    function App() {
      const javascriptCode = `function greet(name) {
      console.log(`Hello, ${name}!`);
    }
    
    greet("World");`;
    
      const pythonCode = `def greet(name):
      print(f"Hello, {name}!")
    
    greet("World")`;
    
      return (
        <div className="App">
          <h2>JavaScript Example</h2>
          <CodeSnippet code={javascriptCode} language="javascript" />
          <h2>Python Example</h2>
          <CodeSnippet code={pythonCode} language="python" />
        </div>
      );
    }
    
    export default App;

    Now, you can specify the language for each code snippet. This makes the component more versatile.

    Collapsible Code Snippets

    To make the code snippets collapsible, you can add a button that toggles the visibility of the code. Modify your ‘CodeSnippet.js’ file:

    import React, { useState } from 'react';
    import Prism from 'react-prism';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
    import './CodeSnippet.css';
    
    function CodeSnippet(props) {
      const { code, language } = props;
      const [isCollapsed, setIsCollapsed] = useState(false);
    
      return (
        <div className="code-snippet-container">
          <button onClick={() => setIsCollapsed(!isCollapsed)}>
            <span>{isCollapsed ? 'Show' : 'Hide'} Code</span>
          </button>
          {!isCollapsed && (
            <pre className={`language-${language} line-numbers`}>
              <code>
                {code}
              </code>
            </pre>
          )}
        </div>
      );
    }
    
    export default CodeSnippet;

    In this updated version, we use the useState hook to manage the collapsed state. We add a button that toggles the isCollapsed state. The code snippet is only displayed if isCollapsed is false.

    Copy to Clipboard Functionality

    A common feature is the ability to copy the code snippet to the clipboard. This can be implemented using the navigator.clipboard.writeText() API. Modify your ‘CodeSnippet.js’ file:

    import React, { useState } from 'react';
    import Prism from 'react-prism';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
    import './CodeSnippet.css';
    
    function CodeSnippet(props) {
      const { code, language } = props;
      const [isCollapsed, setIsCollapsed] = useState(false);
      const [isCopied, setIsCopied] = useState(false);
    
      const copyToClipboard = () => {
        navigator.clipboard.writeText(code)
          .then(() => {
            setIsCopied(true);
            setTimeout(() => setIsCopied(false), 2000);
          })
          .catch(err => console.error('Could not copy text: ', err));
      };
    
      return (
        <div className="code-snippet-container">
          <button onClick={() => setIsCollapsed(!isCollapsed)}>
            <span>{isCollapsed ? 'Show' : 'Hide'} Code</span>
          </button>
          <button onClick={copyToClipboard} style={{ marginLeft: '10px' }}>
            <span>{isCopied ? 'Copied!' : 'Copy'}</span>
          </button>
          {!isCollapsed && (
            <pre className={`language-${language} line-numbers`}>
              <code>
                {code}
              </code>
            </pre>
          )}
        </div>
      );
    }
    
    export default CodeSnippet;

    We add a new state variable isCopied to indicate whether the code has been copied. The copyToClipboard function uses navigator.clipboard.writeText() to copy the code to the clipboard. We display a “Copied!” message briefly after copying the code.

    Error Handling

    While this component is relatively simple, you might want to add error handling. For example, if the code prop is missing or invalid, you could display an error message. You can add a check at the beginning of the component:

    import React, { useState } from 'react';
    import Prism from 'react-prism';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.css';
    import 'prismjs/plugins/line-numbers/prism-line-numbers.js';
    import './CodeSnippet.css';
    
    function CodeSnippet(props) {
      const { code, language } = props;
      const [isCollapsed, setIsCollapsed] = useState(false);
      const [isCopied, setIsCopied] = useState(false);
    
      const copyToClipboard = () => {
        navigator.clipboard.writeText(code)
          .then(() => {
            setIsCopied(true);
            setTimeout(() => setIsCopied(false), 2000);
          })
          .catch(err => console.error('Could not copy text: ', err));
      };
    
      if (!code) {
        return <div className="code-snippet-container">Error: No code provided</div>;
      }
    
      return (
        <div className="code-snippet-container">
          <button onClick={() => setIsCollapsed(!isCollapsed)}>
            <span>{isCollapsed ? 'Show' : 'Hide'} Code</span>
          </button>
          <button onClick={copyToClipboard} style={{ marginLeft: '10px' }}>
            <span>{isCopied ? 'Copied!' : 'Copy'}</span>
          </button>
          {!isCollapsed && (
            <pre className={`language-${language} line-numbers`}>
              <code>
                {code}
              </code>
            </pre>
          )}
        </div>
      );
    }
    
    export default CodeSnippet;

    Common Mistakes and How to Fix Them

    Incorrect Language Class

    One common mistake is using the wrong language class in the ‘pre’ tag. For example, if you’re displaying Python code but use ‘language-javascript’, the syntax highlighting won’t work correctly. Ensure the class matches the language of your code.

    Fix: Double-check the language class in the ‘pre’ tag (e.g., ‘language-python’, ‘language-javascript’, ‘language-java’) to match the code’s language.

    Missing Dependencies

    If syntax highlighting isn’t working, you might have forgotten to install and import the necessary dependencies, such as ‘prismjs’ and ‘react-prism’.

    Fix: Run npm install prismjs react-prism --save and make sure you have imported them correctly at the top of your ‘CodeSnippet.js’ file.

    CSS Conflicts

    Sometimes, CSS styles from other parts of your application can interfere with the appearance of the code snippet. This can lead to unexpected formatting issues.

    Fix: Use more specific CSS selectors to target the code snippet styles. You can also consider using CSS-in-JS solutions or scoping your CSS to the component to avoid conflicts.

    Incorrect Prop Usage

    Make sure you pass the code snippet as a prop correctly. If you’re using the ‘language’ prop, ensure it is passed correctly.

    Fix: Verify that the ‘code’ and ‘language’ props are correctly passed to the ‘CodeSnippet’ component in your ‘App.js’ or the parent component.

    SEO Best Practices

    To ensure your code snippet display component ranks well on search engines, follow these SEO best practices:

    • Use Descriptive Titles: The article title should accurately reflect the content.
    • Optimize Meta Descriptions: Write a concise meta description (around 150-160 characters) that summarizes the article.
    • Use Keywords Naturally: Integrate relevant keywords (e.g., “React code snippet,” “syntax highlighting,” “code display”) naturally throughout the content.
    • Use Headings (H2, H3, H4): Structure your content with headings and subheadings to improve readability and help search engines understand the topic.
    • Use Alt Text for Images: If you include images, use descriptive alt text.
    • Ensure Mobile-Friendliness: Make sure your code snippet display component is responsive and works well on mobile devices.
    • Improve Page Speed: Optimize your code and images to ensure fast loading times.

    Summary / Key Takeaways

    • We’ve built a dynamic code snippet display component in React using ‘prismjs’ for syntax highlighting.
    • The component can be customized with features like line numbers, collapsible sections, and copy-to-clipboard functionality.
    • We covered common mistakes and how to fix them, as well as SEO best practices.
    • This component significantly improves the readability and usability of code snippets in your web applications.

    FAQ

    1. Can I use this component with different programming languages?

    Yes, you can. The core of the component is the syntax highlighting provided by Prism.js. You can support different languages by changing the class name in the ‘pre’ tag (e.g., ‘language-python’, ‘language-java’). You may need to include Prism.js plugins for specific languages if they are not included by default.

    2. How can I customize the appearance of the code snippets?

    You can customize the appearance by modifying the CSS styles in the ‘CodeSnippet.css’ file. You can change the font, background color, border, padding, and other styling properties to match your design preferences.

    3. How do I add line numbers to the code snippets?

    To add line numbers, install the Prism.js line numbers plugin (npm install prismjs --save), import the necessary CSS and JavaScript files, and add the ‘line-numbers’ class to the ‘pre’ tag. This activates the line numbering feature.

    4. Can I make the code snippets collapsible?

    Yes, you can use the useState hook to manage a collapsed state. Add a button that toggles the visibility of the code based on this state. This provides a clean way to hide or show the code snippets.

    5. How can I copy the code to the clipboard?

    You can use the navigator.clipboard.writeText() API to copy the code to the clipboard. Implement a function that calls this API when a button is clicked. You can then provide visual feedback to the user (e.g., a “Copied!” message).

    The creation of a dynamic code snippet display component in React provides a powerful solution for presenting code effectively. By following the steps and incorporating the features we’ve discussed, you can significantly improve the clarity and usability of code snippets in your projects. From syntax highlighting to collapsible sections and copy-to-clipboard functionality, this component empowers developers, educators, and content creators to share and understand code with ease. The ability to customize the appearance and behavior further enhances its versatility, making it a valuable asset for any web application dealing with code. The ability to display code clearly is essential in modern development. Whether you’re building a tutorial, documenting an API, or simply sharing code with a colleague, a well-designed code snippet display can make all the difference in readability, comprehension, and overall user experience. This component is more than just a tool; it’s a gateway to clearer communication and more effective learning in the world of code.

    ” ,
    “aigenerated_tags”: “React, Code Snippet, Syntax Highlighting, PrismJS, Component, Tutorial, JavaScript, Web Development