apollo-elements/apollo-elements

View on GitHub
patches/rocket-preset-slide-decks+0.1.3.patch

Summary

Maintainability
Test Coverage
diff --git a/node_modules/rocket-preset-slide-decks/_includes/_joiningBlocks/_layoutDeck/content/10-content.njk b/node_modules/rocket-preset-slide-decks/_includes/_joiningBlocks/_layoutDeck/content/10-content.njk
index 350b5cd..f8ed737 100644
--- a/node_modules/rocket-preset-slide-decks/_includes/_joiningBlocks/_layoutDeck/content/10-content.njk
+++ b/node_modules/rocket-preset-slide-decks/_includes/_joiningBlocks/_layoutDeck/content/10-content.njk
@@ -1,12 +1 @@
 {{ content | safe }}
-
-<script async defer>
-  addEventListener('keyup', event => {
-    if (event.key !== 'f')
-      return;
-    else if (document.fullscreen)
-      document.exitFullscreen();
-    else
-      document.body.requestFullscreen();
-  });
-</script>
diff --git a/node_modules/rocket-preset-slide-decks/_includes/layout-deck.njk b/node_modules/rocket-preset-slide-decks/_includes/layout-deck.njk
index 3a74498..243776a 100644
--- a/node_modules/rocket-preset-slide-decks/_includes/layout-deck.njk
+++ b/node_modules/rocket-preset-slide-decks/_includes/layout-deck.njk
@@ -1,20 +1,20 @@
 <!doctype html>
-{% block htmlTag %}
+{%- block htmlTag -%}
 <html lang="{{ site.lang }}" dir="{{ site.dir }}">
-{% endblock htmlTag %}
+{%- endblock htmlTag -%}
 
-  {% block head %}
-    {% include 'partials/head.njk' %}
+  {%- block head -%}
+    {%- include 'partials/head.njk' -%}
 
-    {% for blockName, blockPath in _joiningBlocks._layoutDeck.head %}
-      {% include blockPath %}
-    {% endfor %}
+    {%- for blockName, blockPath in _joiningBlocks._layoutDeck.head -%}
+      {%- include blockPath -%}
+    {%- endfor -%}
 
-  {% endblock head %}
+  {%- endblock head -%}
 
-  {% block bodyTag %}
+  {%- block bodyTag -%}
   <body layout="{{ layout }}">
-  {% endblock bodyTag %}
+  {%- endblock bodyTag -%}
 
     <noscript>
       <h1>{{ title }}</h1>
@@ -23,38 +23,55 @@
       <p>This presentation relies on JavaScript. Please consider enabling JavaScript for this site.</p>
     </noscript>
 
-  {% block main %}
+  {%- block main -%}
     <slidem-deck id="deck"
                  transition="{{ transition or 'slide-in slide-out' }}"
                  itemscope
                  itemtype="http://schema.org/PresentationDigitalDocument"
+                 {{ 'unbind' if unbind }}
                  loading>
+      {%- for blockName, blockPath in _joiningBlocks._layoutDeck.content -%}
+        {%- include blockPath -%}
+      {%- endfor -%}
+      {%- if not unbind -%}
       <gluon-keybinding key="Backspace" slot="backward"></gluon-keybinding>
       <gluon-keybinding key=" " slot="forward"></gluon-keybinding>
       <gluon-keybinding key="h" slot="backward"></gluon-keybinding>
       <gluon-keybinding key="j" slot="forward"></gluon-keybinding>
       <gluon-keybinding key="k" slot="backward"></gluon-keybinding>
       <gluon-keybinding key="l" slot="forward"></gluon-keybinding>
+      {%- endif -%}
 
-      {% for slide in collections.slides %}
-        {% set isPageSlide =
+      {%- for slide in collections.slides -%}
+        {%- set isPageSlide =
                (slide.template.inputPath | dirname | joinPath('..'))
-            == (page.inputPath | dirname | joinPath('.')) %}
-        {% if isPageSlide %}
+            == (page.inputPath | dirname | joinPath('.')) -%}
+        {%- if isPageSlide -%}
           <slidem-slide name="{{ slide.data.name }}"
                     {{ ('background='+slide.data.background) if slide.data.background }}
+                    {{ ('class='+slide.data.class) if slide.data.class }}
                     {{ slide.data.attrs }}>
             {{- slide.templateContent | safe -}}
           </slidem-slide>
-        {% endif %}
-      {% endfor %}
+        {%- endif -%}
+      {%- endfor -%}
 
     </slidem-deck>
-    {% for blockName, blockPath in _joiningBlocks._layoutDeck.content %}
-      {% include blockPath %}
-    {% endfor %}
-  {% endblock main %}
+  {%- endblock main -%}
 
-  {% include 'partials/bottom.njk' %}
+  {%- include 'partials/bottom.njk' -%}
   </body>
 </html>
+
+{%- if not unbind -%}
+<script async defer>
+  addEventListener('keyup', event => {
+    if (event.defaultPrevented || event.key !== 'f')
+      return;
+    else if (document.fullscreen)
+      document.exitFullscreen();
+    else
+      document.body.requestFullscreen();
+  });
+</script>
+{%- endif -%}
diff --git a/node_modules/rocket-preset-slide-decks/lib/mdast-directive-to-hast.js b/node_modules/rocket-preset-slide-decks/lib/mdast-directive-to-hast.js
new file mode 100644
index 0000000..b43c104
--- /dev/null
+++ b/node_modules/rocket-preset-slide-decks/lib/mdast-directive-to-hast.js
@@ -0,0 +1,30 @@
+import visit from 'unist-util-visit';
+import { h } from 'hastscript';
+
+/**
+ * @param {import("./lib/types").Directive} node
+ */
+function visitor(node) {
+  switch (node.type) {
+    case 'textDirective':
+    case 'leafDirective':
+    case 'containerDirective': {
+      try {
+        const data = node.data || (node.data = {});
+        const hast = h(node.name, node.attributes)
+        data.hName = hast.tagName;
+        data.hProperties = hast.properties;
+      } catch(e) { console.error(e) }
+    }
+  }
+}
+
+/** @return {import('hast').Plugin} */
+export function mdastDirectiveToHast() {
+  return {
+    plugin() {
+      /** @param {import('mdast').Root} tree */
+      return tree => visit(tree, visitor);
+    },
+  }
+}
diff --git a/node_modules/rocket-preset-slide-decks/lib/types.ts b/node_modules/rocket-preset-slide-decks/lib/types.ts
new file mode 100644
index 0000000..f407d74
--- /dev/null
+++ b/node_modules/rocket-preset-slide-decks/lib/types.ts
@@ -0,0 +1,11 @@
+import type {
+  ContainerDirective,
+  LeafDirective,
+  TextDirective,
+} from 'mdast-util-directive'
+
+export type Directive = (
+  | ContainerDirective
+  | LeafDirective
+  | TextDirective
+);
diff --git a/node_modules/rocket-preset-slide-decks/rocket-preset-slide-decks.js b/node_modules/rocket-preset-slide-decks/rocket-preset-slide-decks.js
index 70b81ff..01f640a 100644
--- a/node_modules/rocket-preset-slide-decks/rocket-preset-slide-decks.js
+++ b/node_modules/rocket-preset-slide-decks/rocket-preset-slide-decks.js
@@ -6,6 +6,11 @@ import { dirname, join, resolve } from 'path';
 import { fileURLToPath } from 'url';
 import { addPlugin, adjustPluginOptions } from 'plugins-manager';
 import { slideDecksPlugin } from './eleventy/slide-decks.js';
+import { markdownDirectives } from 'rocket-preset-markdown-directives';
+import remarkDirective from 'remark-directive';
+import { rollupPluginHTML } from '@web/rollup-plugin-html';
+import { terser as rollupPluginTerser } from 'rollup-plugin-terser';
+import { mdastDirectiveToHast } from './lib/mdast-directive-to-hast.js';
 
 const path = resolve(dirname(fileURLToPath(import.meta.url)));
 
@@ -30,29 +35,46 @@ export function slideDecks() {
         entryPoints: {
           'slidem': join(path, 'entrypoints', 'slidem.js'),
         },
+        plugins: [
+          {
+            name: 'fake it for gluon',
+            setup(build) {
+              build.onResolve({ filter: /lit-html\/lib\/shady-render.js$/ }, async ({ resolveDir }) => {
+                return { path: join(resolveDir, '../../lit-html/lit-html.js') };
+              });
+            },
+          },
+        ]
       }).catch(() => process.exit(1));
 
       console.log(chalk.yellow`[slide-decks] ${chalk.green`Done in ${time.seconds()}s`}`);
     },
 
     setupEleventyPlugins: [
-      addPlugin({
-        name: 'slide-decks',
-        plugin: slideDecksPlugin,
-      }),
+      addPlugin(slideDecksPlugin),
     ],
 
     setupBuildPlugins: [
-      adjustPluginOptions('html', ({ exclude, ...options }) => ({ ...options, exclude: [
+      adjustPluginOptions(rollupPluginHTML, ({ exclude, ...options }) => ({ ...options, exclude: [
         ...Array.isArray(exclude) ? exclude : [exclude].filter(Boolean),
         '**/slide-decks/**/*',
         '**/slide-decks/*',
       ] })),
 
-      adjustPluginOptions('terser', {
+      adjustPluginOptions(rollupPluginTerser, {
         mangle: false,
       }),
     ],
 
+    setupUnifiedPlugins: [
+      addPlugin(markdownDirectives, {}, { location: 'top', }),
+      addPlugin(remarkDirective, undefined, { location: 'top' }),
+      addPlugin(mdastDirectiveToHast, undefined, { location: remarkDirective, how: 'after' }),
+      adjustPluginOptions(markdownDirectives, options => ({
+          ...options,
+          reveal: () => ({ tagName: 'section', attributes: { reveal: true } }),
+        }),
+      ),
+    ],
   };
 }