avatarDavid Fekke

Summary

The web content provides a tutorial on integrating Reveal.js slides exported from slides.com into a Gatsby site, allowing for static hosting of slide presentations.

Abstract

The article guides readers through the process of adding slides created with slides.com, which are based on the Reveal.js framework, to a Gatsby-powered website. It explains that Gatsby can serve static HTML files, and outlines the steps to configure a Gatsby site to host these slides. The process includes installing the gatsby-source-filesystem plugin, configuring it to recognize a static/slides directory, and using GraphQL to query the slides. It also details creating a slides.js page in Gatsby to list and link to the static slide files, emphasizing the use of anchor tags over Gatsby's Link component for external content. The author concludes by praising Gatsby's versatility in serving both dynamic and static content.

Opinions

  • The author believes that web applications like slides.com, which is based on Reveal.js, provide a powerful alternative to traditional presentation software like Powerpoint.
  • The author has a positive view of Gatsby's capabilities, highlighting its ease of use for serving static content alongside dynamic React and Gatsby content.
  • There is an endorsement of using static HTML for slides, suggesting a preference for web-based solutions over traditional desktop applications for presentations.
  • The author mentions a cost consideration, implying that moving slides to a Gatsby site can be a cost-effective alternative to using a service like slides.com, which has a limit on free slides.
  • The author plans to explore further Gatsby plugins for creating slides from markdown, indicating an interest in continued exploration and optimization of the Gatsby ecosystem.
  • A recommendation is made for an AI service, ZAI.chat, as a cost-effective alternative to ChatGPT Plus (GPT-4), suggesting the author's approval of this service for similar performance and functions.

How to add slides.com Reveal Slides to your Gatsby site

Gatsby makes it easy to serve static HTML files with your gatsby site

Photo Illustration by David Fekke

Originally published at https://fek.io.

I was getting ready to create a set of slides for my next presentation. I usually use slides.com to create and host my slides. If you have not looked at slide.com before, it is a great example of the power of web applications. Slides.com has a presentation editor that is based on Reveal.js, a JavaScript library for making animated slide shows. I am a firm believer that you do not need Powerpoint to make slide shows. This can be done as a web app.

Moving to Gatsby

As I was getting ready to start my next set of slides I found out I had exceeded my limit of free slides. So I have decided to move my slides over to my Gatsby site.

The first thing I had to do was export all of my slides. Slides.com gives you the ability to import and export slides into and out of their application. It will allow you to export your slides as a self-contained HTML application in a single HTML file.

Gatsby allows you to host static content in your site so that if you need to serve static CSS or images, this can be easily configured. You will need to install the ‘gatsby-source-filesystem’ plugin in order to serve these files.

> npm i gatsby-source-filesystem --save

The above command will install the plugin into your Gatsby site. After it has been installed, you will need to configure the plugin in your ‘gatsby-config.json’ file. Add the following configuration into the plugin export.

plugins: [
      {
        resolve: `gatsby-source-filesystem`,
        options: {
          name: `static`,
          path: `${__dirname}/static`
        },
      }
];

This will look into a ‘static’ folder for any static files you need to serve. I added another folder underneath my static folder called ‘slides’, and placed my HTML files in that folder.

To retrieve a list of slides from our static folder, we will need to write a graphql query to get that list of files. You can test this by using the Graph iql editor hosted in the development server. You can access this by going to http://localhost:8000/___graphql.

The next need you will need to do is create a Gatsby page to list the slides in your ‘slides’ folder. I created one underneath the root of my ‘/src/pages’ called ‘slides.js’. Here is what my react code looked like in my ‘slides.js’ file.

If you look at the section on line 22 that has a map on the edges of the result data.myslides.edges.map, I am returning an anchor tag instead of a Link tag for displaying the link. This is because the Link tag is only used for gatsby pages. Since this is static HTML content we want to use a normal anchor tag.

Conclusion

Gatsby is great at doing many different things. On top of rendering react content and Gatsby content, you can also use it to serve up static content as well as long as you configure your site correctly.

There are also a number of plugins you can use for creating slides from markdown that I plan on looking at as well.

You can view my slides page at here.

Originally published at https://fek.io.

Gatsbyjs
Revealjs
JavaScript
GraphQL
Recommended from ReadMedium