Skip to content

feat: add OneTag AI "ask this page" plugin - #2861

Closed
fengyiqicoder wants to merge 1 commit into
docsifyjs:developfrom
fengyiqicoder:onetag-plugin
Closed

fengyiqicoder wants to merge 1 commit into
docsifyjs:developfrom
fengyiqicoder:onetag-plugin

Conversation

@fengyiqicoder

Copy link
Copy Markdown

Summary

Adds an optional onetag plugin next to disqus, gitalk and gtag. It puts an "ask this page" button on the site: a visitor types a question and gets an answer drawn from the page they are reading. I am the author of OneTag AI.

<script>
  window.$docsify = {
    onetag: 'your-onetag-key',
  };
</script>
<script src="//cdn.jsdelivr.net/npm/docsify@5/dist/plugins/onetag.min.js"></script>
  • Opt-in. It is a separate file in dist/plugins/; core is untouched, and nothing is loaded unless a site adds the plugin and sets a key.
  • The key is a public site key issued by the service, not a model provider key. Usage is hard-capped (1,000,000 tokens on the free tier, then it stops) and there is no pay-as-you-go billing, so a key copied from the page source cannot run up a cost.
  • The plugin is 36 lines. It appends one async script (7 KB gzipped) that renders in a Shadow DOM, so docsify's styles and the widget's do not touch each other.
  • When a visitor asks, the request carries the question, the text of .markdown-section (not the sidebar or navbar) and ref=docsify (which integration loaded the widget). Nothing is sent before that, and the widget sets no cookies.
  • Works with the hash router: the conversation resets when the route changes, not on an in-page anchor.

$docsify.onetag takes the key as a string, or an object with the widget options (title, theme, color and so on).

Core theme Core theme with core-dark
light dark

Tested on a docsify site built from this branch: questions across a sidebar navigation and an in-page anchor, the dark add-on, phone width (the button does not cover the sidebar toggle), the plugin without a key (one console error, nothing loaded). npm run lint, npm run typecheck, Jest and the Chromium e2e suite pass locally, except search.test.js:285, which is flaky here with and without this change.

Related issue, if any:

None.

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

For any code change,

  • Related documentation has been updated, if needed
  • Related tests have been added or updated, if needed

Does this PR introduce a breaking change?

  • Yes
  • No

Tested in the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Edge

🤖 Generated with Claude Code

https://claude.ai/code/session_017g16kS8U6SzeKsAZguBPEn

Adds an optional plugin that loads the OneTag AI widget: visitors type a
question and get an answer drawn from the page they are reading. Nothing
is loaded unless a key is set in `$docsify.onetag`.

Co-Authored-By: Claude <[email protected]>
Claude-Session: https://claude.ai/code/session_017g16kS8U6SzeKsAZguBPEn
@vercel

vercel Bot commented Nov 10, 2026

Copy link
Copy Markdown

@fengyiqicoder is attempting to deploy a commit to the Docsify Team on Vercel.

A member of the Team first needs to authorize it.

@sy-records sy-records left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for your contribution.

However, this isn't suitable for commit to this repository; you can publish it yourself and add it to the showcase.

@sy-records sy-records closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants