Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Configurable Column Ratios #422

Open
michaeltlombardi opened this issue Feb 17, 2022 · 3 comments
Open

Feature Request: Configurable Column Ratios #422

michaeltlombardi opened this issue Feb 17, 2022 · 3 comments

Comments

@michaeltlombardi
Copy link
Contributor

\o Hello! I've been working on Platen, a an open source toolkit for helping indie game writers and publishers put together digital editions of their games which are accessible, interactive, and multi-device friendly via hugo. I've based it on top of hugo-book because this theme/module is incredible and I believe in re-using excellent tools wherever possible.

One of my contributors, @binarystargames, recently submitted a Pull Request to Platen which extends the functionality of the columns shortcode to include variable column ratios if specified (default is current behavior, even columns). Rather than patch/maintain a fork of this shortcode in Platen, I think this would be a useful feature for general users of hugo-book.

The updated implementation:

<div class="book-columns flex flex-wrap">
{{ if .Get "ratio" }}
    {{ $ratioSplit := split (.Get "ratio") ":"}}
    {{ range $i, $val := split .Inner "<--->" }}
        {{ if gt (len $ratioSplit) $i}}
            <div style="flex-grow:{{ index $ratioSplit $i }};" class="flex-even markdown-inner">
                {{ $val | $.Page.RenderString }}
            </div>
        {{ end }}
    {{ end }}
{{ else }}
{{ range split .Inner "<--->" }}
  <div class="flex-even markdown-inner">
    {{ . | $.Page.RenderString }}
  </div>
{{ end }}
{{ end }}
</div>

If this feature request is out of scope for hugo-book, that's okay! I just wanted to make sure we're good community members and contributing potentially useful stuff back upstream wherever possible and I'd be happy to put up a PR for this if the feature is accepted (and @binarystargames prefers I put it up).

@alex-shpak
Copy link
Owner

alex-shpak commented Feb 18, 2022

Hi!
Thanks for detailed issue! also nice to see that theme is used :)

It looks alright, I have a bit of mixed feeling on how obvious it is to configure. I like to keep configuration simple, so that is no need to consult docs or source code,

I will sit on this idea for some time and will come back to you.

@michaeltlombardi
Copy link
Contributor Author

Open to implementation update ideas too of course! switching to either positional or flexible parameter declarations wouldn't be a problem. Would writing up a draft PR with the docs included (to mirror extant docs) be useful?

Otherwise, no worries and no rush of course! 😊

@binarystargames
Copy link

Happy to address any specific usage concerns you might have as well! I tried to make it resilient to things like implemented column/ratio mismatch, putting non-numeric characters in, etc - barring egregious cases it should generally do something that makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants