@aravindc26/velu 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/build.ts +231 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aravindc26/velu",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/build.ts CHANGED
@@ -340,6 +340,7 @@ export default defineConfig({
340
340
  plugins: [ion()],
341
341
  components: {
342
342
  Sidebar: './src/components/Sidebar.astro',
343
+ PageTitle: './src/components/PageTitle.astro',
343
344
  },
344
345
  customCss: ['./src/styles/velu-theme.css', './src/styles/tabs.css'],${expressiveCodeConfig}
345
346
  sidebar: getSidebar(),
@@ -420,7 +421,103 @@ const filteredSidebar = sidebar.filter((entry: any) => {
420
421
  writeFileSync(join(outDir, "src", "components", "Sidebar.astro"), sidebarComponent, "utf-8");
421
422
  console.log("📋 Generated sidebar component");
422
423
 
423
- // ── 7. Generate tabs.css ──────────────────────────────────────────────────
424
+ // ── 7. Generate PageTitle.astro — title row with copy page button ────────
425
+ const pageTitleComponent = `---
426
+ const currentUrl = Astro.url.href;
427
+ const title = Astro.locals.starlightRoute.entry.data.title;
428
+ ---
429
+
430
+ <div class="velu-title-row">
431
+ <h1 id="_top">{title}</h1>
432
+ <div class="velu-copy-page-container">
433
+ <div class="velu-copy-split-btn">
434
+ <button class="velu-copy-main-btn" data-action="direct-copy">
435
+ <svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
436
+ <span class="velu-copy-label">Copy page</span>
437
+ </button>
438
+ <span class="velu-copy-sep"></span>
439
+ <button class="velu-copy-caret-btn" aria-expanded="false" aria-haspopup="true">
440
+ <svg class="velu-copy-chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"/></svg>
441
+ </button>
442
+ </div>
443
+ <div class="velu-copy-dropdown" hidden>
444
+ <button class="velu-copy-option" data-action="copy">
445
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
446
+ <div>
447
+ <div class="velu-copy-option-title">Copy page</div>
448
+ <div class="velu-copy-option-desc">Copy page as Markdown for LLMs</div>
449
+ </div>
450
+ </button>
451
+ <a class="velu-copy-option" href={\`https://chatgpt.com/?prompt=Read+from+\${encodeURIComponent(currentUrl)}+so+I+can+ask+questions+about+it.\`} target="_blank" rel="noopener noreferrer">
452
+ <svg width="18" height="18" viewBox="0 0 24 24" fill="currentColor"><path d="M22.282 9.821a5.985 5.985 0 0 0-.516-4.91 6.046 6.046 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a5.985 5.985 0 0 0-3.998 2.9 6.046 6.046 0 0 0 .743 7.097 5.98 5.98 0 0 0 .51 4.911 6.051 6.051 0 0 0 6.515 2.9A5.985 5.985 0 0 0 13.26 24a6.056 6.056 0 0 0 5.772-4.206 5.99 5.99 0 0 0 3.997-2.9 6.056 6.056 0 0 0-.747-7.073zM13.26 22.43a4.476 4.476 0 0 1-2.876-1.04l.141-.081 4.779-2.758a.795.795 0 0 0 .392-.681v-6.737l2.02 1.168a.071.071 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494zM3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085 4.783 2.759a.771.771 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646zM2.34 7.896a4.485 4.485 0 0 1 2.366-1.973V11.6a.766.766 0 0 0 .388.676l5.815 3.355-2.02 1.168a.076.076 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.076.076 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667zm2.01-3.023l-.141-.085-4.774-2.782a.776.776 0 0 0-.785 0L9.409 9.23V6.897a.066.066 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.795.795 0 0 0-.393.681zm1.097-2.365l2.602-1.5 2.607 1.5v2.999l-2.597 1.5-2.607-1.5z"/></svg>
453
+ <div>
454
+ <div class="velu-copy-option-title">Open in ChatGPT <span class="velu-external-arrow">&nearr;</span></div>
455
+ <div class="velu-copy-option-desc">Ask questions about this page</div>
456
+ </div>
457
+ </a>
458
+ <a class="velu-copy-option" href={\`https://claude.ai/new?q=Read+from+\${encodeURIComponent(currentUrl)}+so+I+can+ask+questions+about+it.\`} target="_blank" rel="noopener noreferrer">
459
+ <svg width="18" height="18" viewBox="0 0 200 200" style="overflow:visible" fill="currentColor"><path d="m50.228 170.321 50.357-28.257.843-2.463-.843-1.361h-2.462l-8.426-.518-28.775-.778-24.952-1.037-24.175-1.296-6.092-1.297L0 125.796l.583-3.759 5.12-3.434 7.324.648 16.202 1.101 24.304 1.685 17.629 1.037 26.118 2.722h4.148l.583-1.685-1.426-1.037-1.101-1.037-25.147-17.045-27.22-18.017-14.258-10.37-7.713-5.25-3.888-4.925-1.685-10.758 7-7.713 9.397.649 2.398.648 9.527 7.323 20.35 15.75L94.817 91.9l3.889 3.24 1.555-1.102.195-.777-1.75-2.917-14.453-26.118-15.425-26.572-6.87-11.018-1.814-6.61c-.648-2.723-1.102-4.991-1.102-7.778l7.972-10.823L71.42 0 82.05 1.426l4.472 3.888 6.61 15.101 10.694 23.786 16.591 32.34 4.861 9.592 2.592 8.879.973 2.722h1.685v-1.556l1.36-18.211 2.528-22.36 2.463-28.776.843-8.1 4.018-9.722 7.971-5.25 6.222 2.981 5.12 7.324-.713 4.73-3.046 19.768-5.962 30.98-3.889 20.739h2.268l2.593-2.593 10.499-13.934 17.628-22.036 7.778-8.749 9.073-9.657 5.833-4.601h11.018l8.1 12.055-3.628 12.443-11.342 14.388-9.398 12.184-13.48 18.147-8.426 14.518.778 1.166 2.01-.194 30.46-6.481 16.462-2.982 19.637-3.37 8.88 4.148.971 4.213-3.5 8.62-20.998 5.184-24.628 4.926-36.682 8.685-.454.324.519.648 16.526 1.555 7.065.389h17.304l32.21 2.398 8.426 5.574 5.055 6.805-.843 5.184-12.962 6.611-17.498-4.148-40.83-9.721-14-3.5h-1.944v1.167l11.666 11.406 21.387 19.314 26.767 24.887 1.36 6.157-3.434 4.86-3.63-.518-23.526-17.693-9.073-7.972-20.545-17.304h-1.36v1.814l4.73 6.935 25.017 37.59 1.296 11.536-1.814 3.76-6.481 2.268-7.13-1.297-14.647-20.544-15.1-23.138-12.185-20.739-1.49.843-7.194 77.448-3.37 3.953-7.778 2.981-6.48-4.925-3.436-7.972 3.435-15.749 4.148-20.544 3.37-16.333 3.046-20.285 1.815-6.74-.13-.454-1.49.194-15.295 20.999-23.267 31.433-18.406 19.702-4.407 1.75-7.648-3.954.713-7.064 4.277-6.286 25.47-32.405 15.36-20.092 9.917-11.6-.065-1.686h-.583L44.07 198.125l-12.055 1.555-5.185-4.86.648-7.972 2.463-2.593 20.35-13.999-.064.065Z"/></svg>
460
+ <div>
461
+ <div class="velu-copy-option-title">Open in Claude <span class="velu-external-arrow">&nearr;</span></div>
462
+ <div class="velu-copy-option-desc">Ask questions about this page</div>
463
+ </div>
464
+ </a>
465
+ </div>
466
+ </div>
467
+ </div>
468
+
469
+ <script is:inline>
470
+ (function init() {
471
+ var caretBtn = document.querySelector('.velu-copy-caret-btn');
472
+ var mainBtn = document.querySelector('.velu-copy-main-btn');
473
+ var dropdown = document.querySelector('.velu-copy-dropdown');
474
+ var label = document.querySelector('.velu-copy-label');
475
+ if (!caretBtn || !mainBtn || !dropdown) return;
476
+
477
+ function doCopy() {
478
+ if (label) label.textContent = 'Copying...';
479
+ var titleEl = document.querySelector('#_top');
480
+ var article = document.querySelector('.sl-markdown-content') || document.querySelector('.content-panel') || document.querySelector('main');
481
+ var text = '';
482
+ if (titleEl) text = '# ' + titleEl.textContent + '\\n\\n';
483
+ if (article) text += article.innerText;
484
+ if (text) {
485
+ navigator.clipboard.writeText(text).then(function() {
486
+ if (label) label.textContent = 'Copied!';
487
+ setTimeout(function() { if (label) label.textContent = 'Copy page'; }, 1500);
488
+ });
489
+ }
490
+ dropdown.hidden = true;
491
+ caretBtn.setAttribute('aria-expanded', 'false');
492
+ }
493
+
494
+ mainBtn.onclick = function(e) { e.stopPropagation(); doCopy(); };
495
+
496
+ caretBtn.onclick = function(e) {
497
+ e.stopPropagation();
498
+ var open = dropdown.hidden;
499
+ dropdown.hidden = !open;
500
+ caretBtn.setAttribute('aria-expanded', String(open));
501
+ };
502
+
503
+ document.addEventListener('click', function() {
504
+ dropdown.hidden = true;
505
+ caretBtn.setAttribute('aria-expanded', 'false');
506
+ });
507
+
508
+ dropdown.onclick = function(e) { e.stopPropagation(); };
509
+
510
+ var copyOpt = dropdown.querySelector('[data-action="copy"]');
511
+ if (copyOpt) {
512
+ copyOpt.onclick = function() { doCopy(); };
513
+ }
514
+ })();
515
+ </script>
516
+ `;
517
+ writeFileSync(join(outDir, "src", "components", "PageTitle.astro"), pageTitleComponent, "utf-8");
518
+ console.log("📋 Generated page title component");
519
+
520
+ // ── 8. Generate tabs.css ──────────────────────────────────────────────────
424
521
  const tabsCss = `/* ── Velu sidebar tabs ─────────────────────────────────────────────────── */
425
522
 
426
523
  :root {
@@ -471,6 +568,139 @@ const filteredSidebar = sidebar.filter((entry: any) => {
471
568
  flex-shrink: 0;
472
569
  margin-inline-start: auto;
473
570
  }
571
+
572
+ /* ── Copy page button ─────────────────────────────────────────────────── */
573
+
574
+ .velu-title-row {
575
+ display: flex;
576
+ align-items: flex-start;
577
+ justify-content: space-between;
578
+ gap: 1rem;
579
+ }
580
+
581
+ .velu-title-row h1 {
582
+ margin: 0;
583
+ }
584
+
585
+ .velu-copy-page-container {
586
+ position: relative;
587
+ flex-shrink: 0;
588
+ margin-top: 0.35rem;
589
+ }
590
+
591
+ .velu-copy-split-btn {
592
+ display: inline-flex;
593
+ align-items: center;
594
+ border: 1px solid var(--sl-color-gray-5);
595
+ border-radius: 999px;
596
+ background: var(--sl-color-bg-nav);
597
+ }
598
+
599
+ .velu-copy-main-btn {
600
+ display: inline-flex;
601
+ align-items: center;
602
+ gap: 0.4rem;
603
+ padding: 0.35rem 0.5rem 0.35rem 0.75rem;
604
+ font-size: var(--sl-text-xs);
605
+ font-weight: 500;
606
+ color: var(--sl-color-gray-3);
607
+ background: none;
608
+ border: none;
609
+ cursor: pointer;
610
+ transition: color 0.15s;
611
+ }
612
+
613
+ .velu-copy-main-btn:hover {
614
+ color: var(--sl-color-white);
615
+ }
616
+
617
+ .velu-copy-sep {
618
+ width: 1px;
619
+ height: 14px;
620
+ background-color: var(--sl-color-gray-5);
621
+ flex-shrink: 0;
622
+ }
623
+
624
+ .velu-copy-caret-btn {
625
+ display: inline-flex;
626
+ align-items: center;
627
+ padding: 0.35rem 0.5rem;
628
+ background: none;
629
+ border: none;
630
+ color: var(--sl-color-gray-3);
631
+ cursor: pointer;
632
+ transition: color 0.15s;
633
+ }
634
+
635
+ .velu-copy-caret-btn:hover {
636
+ color: var(--sl-color-white);
637
+ }
638
+
639
+ .velu-copy-chevron {
640
+ transition: transform 0.15s;
641
+ }
642
+
643
+ .velu-copy-caret-btn[aria-expanded='true'] .velu-copy-chevron {
644
+ transform: rotate(180deg);
645
+ }
646
+
647
+ .velu-copy-dropdown {
648
+ position: absolute;
649
+ right: 0;
650
+ top: calc(100% + 0.35rem);
651
+ z-index: 100;
652
+ min-width: 16rem;
653
+ padding: 0.35rem;
654
+ background: var(--sl-color-bg-nav);
655
+ border: 1px solid var(--sl-color-gray-5);
656
+ border-radius: 0.5rem;
657
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
658
+ }
659
+
660
+ .velu-copy-option {
661
+ display: flex;
662
+ align-items: flex-start;
663
+ gap: 0.5rem;
664
+ width: 100%;
665
+ padding: 0.5rem 0.6rem;
666
+ font: inherit;
667
+ font-size: var(--sl-text-sm);
668
+ color: var(--sl-color-gray-2);
669
+ text-align: left;
670
+ text-decoration: none;
671
+ background: none;
672
+ border: none;
673
+ border-radius: 0.35rem;
674
+ cursor: pointer;
675
+ transition: background-color 0.15s;
676
+ }
677
+
678
+ .velu-copy-option:hover {
679
+ background-color: var(--sl-color-gray-6);
680
+ }
681
+
682
+ .velu-copy-option svg {
683
+ flex-shrink: 0;
684
+ opacity: 0.7;
685
+ margin-top: 0.15rem;
686
+ overflow: visible;
687
+ }
688
+
689
+ .velu-copy-option-title {
690
+ font-weight: 500;
691
+ line-height: 1.3;
692
+ }
693
+
694
+ .velu-copy-option-desc {
695
+ font-size: var(--sl-text-xs);
696
+ color: var(--sl-color-gray-3);
697
+ line-height: 1.3;
698
+ }
699
+
700
+ .velu-external-arrow {
701
+ font-size: 0.75em;
702
+ opacity: 0.5;
703
+ }
474
704
  `;
475
705
  writeFileSync(join(outDir, "src", "styles", "tabs.css"), tabsCss, "utf-8");
476
706
  console.log("🎨 Generated tabs.css");