rtt-library
v1.0.4
Published
A front-end tool to test robots.txt rules against specific URLs.
Readme
Robots.txt Tester Library
A reusable JavaScript library for testing robots.txt rules against specific URLs.
Features
- Test URLs against robots.txt rules
- Highlight syntax for robots.txt content
- Validate robots.txt syntax
- Check for errors and potential issues
- Check specific user-agents & paths
Installation
npm installDevelopment
The project uses Webpack for JavaScript bundling and Gulp for additional build tasks:
npm run dev- Start development mode with watchnpm run build- Create production build with bundling and minificationnpm run styles- Build SCSS filesnpm run watch:styles- Watch SCSS files for changes
Build Output
The build process generates the following in dist:
rtt-library.js- UMD module exporting the default component (includes bundled highlight.js core + plugins).main.css- Compiled and minified styles scoped to#rtt-tool.
import RttTool from 'rtt-library';
import { createRoot } from '@wordpress/element';
import 'rtt-library/dist/main.css';
// or
// import 'rtt-library/main.css';
const root = createRoot(document.getElementById('rank-math-admin-rtt'));
root.render(
<RttTool
ajaxUrl={window.rankMath.robotsTxtData.ajaxUrl}
ajaxNonce={window.rankMath.robotsTxtData.nonce}
siteUrl={window.rankMath.robotsTxtData.siteUrl}
/>
);Notes
- CSS import: you can use either
rtt-library/dist/main.cssorrtt-library/main.css. - Peer deps/externals: jQuery and the WordPress element package are expected to be provided by the host app.
- In the browser they should exist as globals:
window.jQueryandwindow.wp.element. - In a bundler, ensure
jqueryand@wordpress/elementare installed and resolved normally.
- In the browser they should exist as globals:
Configuration
You can configure the library by passing options to the RttTool component. The following options are available:
ajaxUrl: The URL for AJAX requestsajaxNonce: The nonce for securitysiteUrl: The initial site URLrobotsTxtContent: The initial content of the robots.txt fileeditorDisabled: Whether the editor is disabled (for read-only mode)isLocal: Local mode disables AJAX requests & prevents changing the site URL (default isfalse)
