Skip to content
Merged
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
37 changes: 0 additions & 37 deletions src/components/YoastSchemaExample.js

This file was deleted.

40 changes: 40 additions & 0 deletions src/components/YoastSchemaExample/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import React from "react";
import CodeBlock from "@theme/CodeBlock";
import styles from "./styles.module.css";
import classnames from "classnames";

/**
* Outputs a properly formed JSON-LD tag to be used in the output.
*
* @param string jsonScript
*
* @returns {string} The HTML output.
*/
const toHTMLOutput = ( jsonScript ) => {
return `<script type="application/ld+json">${ jsonScript }</script>`;
};

/**
* The Yoast Schema Example component.
*
* @param {Object} props The props.
*
* @returns {JSX} The schema example component.
* @constructor
*/
const YoastSchemaExample = ( props ) => {
const cleaned = toHTMLOutput( props.children );

return (
<div className={ styles.schemaExample }>
<form action="https://search.google.com/structured-data/testing-tool" method="post" target="_blank">
<input className={ classnames( "button", "button--secondary", styles.modifyButton ) } type="submit"
value="Test &amp; modify in the Google Structured Data Testing Tool"/>
<textarea name="code" className={ styles.codeArea } value={ cleaned } readOnly></textarea>
</form>
<CodeBlock className="json">{ props.children }</CodeBlock>
</div>
);
}

export default YoastSchemaExample;
13 changes: 13 additions & 0 deletions src/components/YoastSchemaExample/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.schemaExample {
overflow: hidden;
}

.codeArea {
display: none;
}

.modifyButton {
white-space: normal;
border-radius: var(--ifm-button-border-radius) var(--ifm-button-border-radius) 0 0;
}

1 change: 1 addition & 0 deletions src/theme/DocPage/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
max-height: 100vh;
top: 0;
overflow-y: auto;
z-index: 999;
}

.docMainContainer {
Expand Down