alshedivat / al-folio

A beautiful, simple, clean, and responsive Jekyll theme for academics
https://alshedivat.github.io/al-folio/
MIT License
11.34k stars 11.28k forks source link

Added gh-pages Formatter #2649

Closed KingHowler closed 3 months ago

KingHowler commented 3 months ago

Added prettier-hmtl.yml

GitHub Workflow

Purpose

The GitHub Workflow formats the html files on gh-pages. The html files generated are always on a single line. This makes scaling programs a lot more difficult. By formatting the HTML files, al-folio can now be used to generate code which can then be modified to allow for using back-end.

Errors found

I want to let you know that when I was using prettier for this, it kept crashing and after some debugging I found out that al-folio was generating an invalid tag </source>. <source> is a self-closing tag and doesn't have a separate closing tag. Error: <source src="URL" type="type"></source> Correct: <source src="URL" type="type">

Workflow Description

  1. The workflow starts by checking out the gh-pages branch.
  2. Then it finds all </source> tags in all html files and deletes them.
  3. It Installs NodeJS and then Prettier. To make sure the code was executed properly, the workflow checks if prettier is present.
  4. Then the workflow runs prettier on all html files present in gh-pages
  5. It ends by committing the changes and pushing them to the gh-pages directory

Example:

Before image

After image

george-gca commented 3 months ago

This action is useful when you want to modify your page further after your page was built. I believe that most of our users (me included) host their pages on GitHub pages or don't even add changes after the site was built. Therefore, if this action would be added, it should not run by default, but be enabled if the user is willing to do so instead.

george-gca commented 3 months ago

Can you pinpoint what creates these </source> html tags?

KingHowler commented 3 months ago

Can you pinpoint what creates these </source> html tags?

I can try but I I'm not exactly sure I will be able to find it. And yes that's what I was saying it for. In case someone wants to add a back-end for their al-folio website, they will need the code to be arranged in order to be able to work properly.

KingHowler commented 3 months ago

This action is useful when you want to modify your page further after your page was built. I believe that most of our users (me included) host their pages on GitHub pages or don't even add changes after the site was built. Therefore, if this action would be added, it should not run by default, but be enabled if the user is willing to do so instead.

That's reasonable, I have removed the following section:

#on:
  push: 
     branches: 
       - gh-pages

The code won't work automatically and will instead work when manually triggered from GitHub actions