From d2c7f345ab598f25412b0fe60385d28187a3d1e8 Mon Sep 17 00:00:00 2001 From: unclecode Date: Tue, 7 Oct 2025 11:59:25 +0800 Subject: [PATCH] feat(docs): add chatgpt quick link to page actions --- docs/md_v2/assets/page_actions.css | 12 ------------ docs/md_v2/assets/page_actions.js | 28 +++++++++++++++++++--------- mkdocs.yml | 2 +- 3 files changed, 20 insertions(+), 22 deletions(-) diff --git a/docs/md_v2/assets/page_actions.css b/docs/md_v2/assets/page_actions.css index 13fbffad..0d406445 100644 --- a/docs/md_v2/assets/page_actions.css +++ b/docs/md_v2/assets/page_actions.css @@ -201,18 +201,6 @@ ul>li.page-action-item::after{ } /* Badge */ -.page-action-badge { - display: inline-block; - background: #f59e0b; - color: #070708; - padding: 0.125rem 0.5rem; - border-radius: 12px; - font-size: 0.65rem; - font-weight: 600; - text-transform: uppercase; - letter-spacing: 0.05em; -} - /* External link indicator */ .page-action-external::after { content: '→'; diff --git a/docs/md_v2/assets/page_actions.js b/docs/md_v2/assets/page_actions.js index 984a2c09..bb143840 100644 --- a/docs/md_v2/assets/page_actions.js +++ b/docs/md_v2/assets/page_actions.js @@ -176,13 +176,11 @@ document.addEventListener('DOMContentLoaded', () => {
  • - + - Ask AI about page - - Coming Soon - + Open in ChatGPT + Ask questions about this page
  • @@ -277,6 +275,18 @@ document.addEventListener('DOMContentLoaded', () => { window.open(githubUrl, '_blank', 'noopener,noreferrer'); } + function getCurrentPageUrl() { + const { href } = window.location; + return href.split('#')[0]; + } + + function openChatGPT() { + const pageUrl = getCurrentPageUrl(); + const prompt = encodeURIComponent(`Read ${pageUrl} so I can ask questions about it.`); + const chatUrl = `https://chatgpt.com/?hint=search&prompt=${prompt}`; + window.open(chatUrl, '_blank', 'noopener,noreferrer'); + } + (async () => { if (!shouldShowButton()) { return; @@ -319,12 +329,12 @@ document.addEventListener('DOMContentLoaded', () => { closeDropdown(button, dropdown, overlay); }); - // Ask AI action (disabled for now) - document.getElementById('action-ask-ai').addEventListener('click', (e) => { + // Open in ChatGPT action + document.getElementById('action-open-chatgpt').addEventListener('click', (e) => { e.preventDefault(); e.stopPropagation(); - // Future: Integrate with Ask AI feature - // For now, do nothing (disabled state) + openChatGPT(); + closeDropdown(button, dropdown, overlay); }); // Close on ESC key diff --git a/mkdocs.yml b/mkdocs.yml index 6406b028..efc948c3 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -115,4 +115,4 @@ extra_javascript: - assets/copy_code.js - assets/floating_ask_ai_button.js - assets/mobile_menu.js - - assets/page_actions.js \ No newline at end of file + - assets/page_actions.js?v=20251006 \ No newline at end of file