UNPKG

docusaurus-plugin-copy-page-button

Version:

A Docusaurus plugin that provides a copy page button for extracting content as markdown for LLMs

38 lines (32 loc) 824 B
const path = require("path"); module.exports = function copyPageButtonPlugin(context, options = {}) { const { customStyles = {}, ...otherOptions } = options; // Store options globally for client access if (typeof global !== 'undefined') { global.__COPY_PAGE_BUTTON_OPTIONS__ = { customStyles, ...otherOptions }; } return { name: "copy-page-button-plugin", getClientModules() { return [path.resolve(__dirname, "./client.js")]; }, injectHtmlTags() { return { headTags: [ { tagName: 'script', innerHTML: ` window.__COPY_PAGE_BUTTON_OPTIONS__ = ${JSON.stringify({ customStyles, ...otherOptions })}; ` } ] }; }, }; };