index.blade.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. @php
  2. use Knuckles\Scribe\Tools\WritingUtils as u;
  3. @endphp
  4. <!doctype html>
  5. <html lang="en">
  6. <head>
  7. <meta charset="utf-8">
  8. <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
  9. <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  10. <title>{!! $metadata['title'] !!}</title>
  11. <link href="https://fonts.googleapis.com/css?family=PT+Sans&display=swap" rel="stylesheet">
  12. <link rel="stylesheet" href="{!! $assetPathPrefix !!}css/theme-elements.style.css" media="screen">
  13. <script src="https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js"></script>
  14. <link rel="stylesheet"
  15. href="https://unpkg.com/@highlightjs/cdn-assets@11.6.0/styles/docco.min.css">
  16. <script src="https://unpkg.com/@highlightjs/cdn-assets@10.7.2/highlight.min.js"></script>
  17. <script>hljs.highlightAll();</script>
  18. <style>
  19. .hljs {
  20. /* Remove highlightjs background color */
  21. background-color: transparent;
  22. !important;
  23. }
  24. </style>
  25. @if($tryItOut['enabled'] ?? true)
  26. <script>
  27. var baseUrl = "{{ $tryItOut['base_url'] ?? config('app.url') }}";
  28. var useCsrf = Boolean({{ $tryItOut['use_csrf'] ?? null }});
  29. var csrfUrl = "{{ $tryItOut['csrf_url'] ?? null }}";
  30. </script>
  31. <script src="{{ u::getVersionedAsset($assetPathPrefix.'js/tryitout.js') }}"></script>
  32. @endif
  33. <script src="{{ u::getVersionedAsset($assetPathPrefix.'js/theme-elements.js') }}"></script>
  34. </head>
  35. <body>
  36. @if($metadata['example_languages'])
  37. <script>
  38. function switchExampleLanguage(lang) {
  39. document.querySelectorAll(`.example-request`).forEach(el => el.style.display = 'none');
  40. document.querySelectorAll(`.example-request-${lang}`).forEach(el => el.style.display = 'initial');
  41. document.querySelectorAll(`.example-request-lang-toggle`).forEach(el => el.value = lang);
  42. }
  43. </script>
  44. @endif
  45. <script>
  46. function switchExampleResponse(endpointId, index) {
  47. document.querySelectorAll(`.example-response-${endpointId}`).forEach(el => el.style.display = 'none');
  48. document.querySelectorAll(`.example-response-${endpointId}-${index}`).forEach(el => el.style.display = 'initial');
  49. document.querySelectorAll(`.example-response-${endpointId}-toggle`).forEach(el => el.value = index);
  50. }
  51. function toggleExpansionChevrons(evt) {
  52. let elem = evt.currentTarget;
  53. const newState = elem.querySelector('.expand-chevron').style.display === 'none' ? 'expand' : 'expanded';
  54. if (newState === 'expanded') {
  55. elem.querySelector('.expand-chevron').style.display = 'none';
  56. elem.querySelector('.expanded-chevron').style.removeProperty('display');
  57. } else {
  58. elem.querySelector('.expand-chevron').style.removeProperty('display')
  59. elem.querySelector('.expanded-chevron').style.display = 'none'
  60. }
  61. }
  62. function toggleElementChildren(evt) {
  63. let elem = evt.currentTarget;
  64. let children = elem.querySelector(`.children`);
  65. if (!children) return;
  66. if (children.contains(event.target)) return;
  67. let oldState = children.style.display
  68. if (oldState === 'none') {
  69. children.style.removeProperty('display');
  70. toggleExpansionChevrons(evt);
  71. } else {
  72. children.style.display = 'none';
  73. toggleExpansionChevrons(evt);
  74. }
  75. evt.stopPropagation();
  76. }
  77. function highlightSidebarItem(evt = null) {
  78. if (evt && evt.oldURL) {
  79. let oldHash = new URL(evt.oldURL).hash.slice(1);
  80. if (oldHash) {
  81. let previousItem = window['sidebar'].querySelector(`#toc-item-${oldHash}`);
  82. previousItem.classList.remove('sl-bg-primary-tint');
  83. previousItem.classList.add('sl-bg-canvas-100');
  84. }
  85. }
  86. let newHash = location.hash.slice(1);
  87. if (newHash) {
  88. let item = window['sidebar'].querySelector(`#toc-item-${newHash}`);
  89. item.classList.remove('sl-bg-canvas-100');
  90. item.classList.add('sl-bg-primary-tint');
  91. }
  92. }
  93. addEventListener('DOMContentLoaded', () => {
  94. highlightSidebarItem();
  95. document.querySelectorAll('.expandable').forEach(el => {
  96. el.addEventListener('click', toggleElementChildren);
  97. });
  98. document.querySelectorAll('details').forEach(el => {
  99. el.addEventListener('toggle', toggleExpansionChevrons);
  100. });
  101. });
  102. addEventListener('hashchange', highlightSidebarItem);
  103. </script>
  104. <div class="sl-elements sl-antialiased sl-h-full sl-text-base sl-font-ui sl-text-body sl-flex sl-inset-0">
  105. @include("scribe::themes.elements.sidebar")
  106. <div class="sl-overflow-y-auto sl-flex-1 sl-w-full sl-px-16 sl-bg-canvas sl-py-16" style="max-width: 1500px;">
  107. <div class="sl-mb-10">
  108. <div class="sl-mb-4">
  109. <h1 class="sl-text-5xl sl-leading-tight sl-font-prose sl-font-semibold sl-text-heading">
  110. {!! $metadata['title'] !!}
  111. </h1>
  112. @if($metadata['postman_collection_url'])
  113. <a title="Download Postman collection" class="sl-mx-1"
  114. href="{!! $metadata['postman_collection_url'] !!}" target="_blank">
  115. <small>Postman collection →</small>
  116. </a>
  117. @endif
  118. @if($metadata['openapi_spec_url'])
  119. <a title="Download OpenAPI spec" class="sl-mx-1"
  120. href="{!! $metadata['openapi_spec_url'] !!}" target="_blank">
  121. <small>OpenAPI spec →</small>
  122. </a>
  123. @endif
  124. </div>
  125. <div class="sl-prose sl-markdown-viewer sl-my-4">
  126. {!! $intro !!}
  127. {!! $auth !!}
  128. </div>
  129. </div>
  130. @include("scribe::themes.elements.groups")
  131. <div class="sl-prose sl-markdown-viewer sl-my-5">
  132. {!! $append !!}
  133. </div>
  134. </div>
  135. </div>
  136. </body>
  137. </html>