okkur / syna

Highly customizable open source theme for Hugo based static websites
https://syna.okkur.org/demo/
Apache License 2.0
250 stars 134 forks source link

Refactor fragments to make development easier #783

Closed mpourismaiel closed 4 years ago

mpourismaiel commented 4 years ago

Refactor request

Currently fragments have a lot of functionality spread between their code that makes reading their code hard. Also some fragments have different variants which adds to the problem. We have helpers to reduce this problem but it's not helping by that much.

My proposal is to slice up fragments into smaller parts that don't change between variants and also separate different variants of each fragment.

This will allow us to change a part of the fragment much easier and faster and only care about how it impacts the fragment visually. Separating variants will also make the code for each fragment much smaller.

A nice side effect to this is that users can override a fragment and any slice that they haven't changed will still get updates, as opposed to before that a change to a fragment would mean opting out of all future updates to that fragment.

stp-ip commented 4 years ago

One thing to take into account are hugo modules as well. I still feel it doesn't map well, but we should at least consider it. Would make it possible to have our slices or slice bundles aka fragments maybe reusable in other themes as well... related question https://github.com/okkur/syna/issues/586

mpourismaiel commented 4 years ago

We discussed this in more detail and came to the conclusion that the idea we had (slicing fragments into smaller pieces, divided by logic and design) was way too time consuming and made the code more complex. We agreed that duplication is more in our favor.