index.html 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <%- header_tpl({site_title = site_title, title = "Index"}) %>
  5. <!-- JS client-side search. -->
  6. <script src="/js/fuse.min.js"></script>
  7. <script type="application/javascript">
  8. async function get_json(url) {
  9. try {
  10. const response = await fetch(url);
  11. if (!response.ok) {
  12. throw new Error(`Response status: ${response.status}`);
  13. }
  14. const json = await response.json();
  15. console.log(json);
  16. return json;
  17. } catch (error) {
  18. console.error(error.message);
  19. }
  20. }
  21. async function fuse_init() {
  22. let [idx_json, keys_json] = await Promise.all([
  23. get_json('/js/fuse_index.json'),
  24. get_json('/js/fuse_keys.json')
  25. ]);
  26. const fuseOptions = {
  27. // isCaseSensitive: false,
  28. // includeScore: false,
  29. // ignoreDiacritics: false,
  30. // shouldSort: true,
  31. // includeMatches: false,
  32. // findAllMatches: false,
  33. // minMatchCharLength: 1,
  34. // location: 0,
  35. // threshold: 0.6,
  36. // distance: 100,
  37. // useExtendedSearch: false,
  38. // ignoreLocation: false,
  39. // ignoreFieldNorm: false,
  40. // fieldNormWeight: 1,
  41. keys: keys_json,
  42. };
  43. return new Fuse(idx_json, fuseOptions);
  44. }
  45. let fuse;
  46. (async () => {fuse = await fuse_init()})();
  47. </script>
  48. </head>
  49. <body>
  50. <header>
  51. <h1><%= title %></h1>
  52. </header>
  53. <main>
  54. <section id="obj_list">
  55. <h2>Recent artifacts</h2>
  56. <ul>
  57. <% for _, obj in ipairs(obj_idx) do %>
  58. <li class="obj_link">
  59. <a href="<%= obj.href %>">
  60. <%if obj.tn then %>
  61. <img src="<%= obj.tn %>" alt="<%= obj.title.data %>" />
  62. <% end %>
  63. <%= obj.title.data %>
  64. <%if obj.title.lang then %>
  65. <span class="langtag"><%= obj.title.lang %></span>
  66. <% end %>
  67. </a>
  68. </li>
  69. <% end %>
  70. </ul>
  71. </section>
  72. </main>
  73. <footer></footer>
  74. </body>
  75. </html>