markdown-renderer.blade.php 861 B

12345678910111213141516171819202122232425262728293031
  1. @props(['content' => '', 'class' => ''])
  2. <div
  3. class="markdown-content {{ $class }}"
  4. x-data="{
  5. init() {
  6. if (typeof window.renderMarkdown === 'function') {
  7. window.renderMarkdown(@js($content), this.$el);
  8. } else {
  9. // 如果渲染函数未加载,等待加载
  10. setTimeout(() => {
  11. if (typeof window.renderMarkdown === 'function') {
  12. window.renderMarkdown(@js($content), this.$el);
  13. }
  14. }, 100);
  15. }
  16. }
  17. }"
  18. x-init="init()"
  19. >
  20. <!-- Markdown 内容将在这里渲染 -->
  21. <div class="text-gray-500 italic">
  22. Loading markdown content...
  23. </div>
  24. </div>
  25. @once
  26. @push('scripts')
  27. <link rel="stylesheet" href="/css/katex/katex.min.css">
  28. @endpush
  29. @endonce