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

giscus: add custom theming #44

Open
davidsneighbour opened this issue Mar 19, 2022 · 2 comments
Open

giscus: add custom theming #44

davidsneighbour opened this issue Mar 19, 2022 · 2 comments
Assignees
Labels
module:giscus state:confirmed This issue is confirmed. type:enhancement New enhancements and features.

Comments

@davidsneighbour
Copy link
Owner

davidsneighbour commented Mar 19, 2022

As described in Advanced Usage a custom theme can be added. Let's implement it here too.

The setup would be as follows:

config

[outputs]
home = ["GISCUS_THEME"]
[params.dnb.giscus]
theme = "dark"
[params.dnb.giscus.theme]
stylesheet = "scss/giscus/theme.scss"
colorPrettylightsSyntaxComment = "#768390"
colorPrettylightsSyntaxConstant = "#6cb6ff"
...

stylesheet is a path to a stylesheet (looks by default for assets/scss/giscus/theme.scss). This stylesheet will import the original theme selected under giscus (loading via getRemote), then subsequent properties under theme are added as overrides and exports the finished stylesheet.

The camelcased syntax of the theme variables are corresponding to the CSS variables in the sample theme.

The pain point here is how to map this without having to add all items to the template. I think there should be a way to transform camelcase to title-case in Hugo.

Currently I think it's a sequence like this:

  • Do a replaceRE over the key (see this regexp test)
  • lower case it
  • trim extra dashes - no idea why the last item in the sample adds a dash in the end

If GISCUS_THEME is set in the outputs, then a custom stylesheet will be linked, so a custom theme without any settings in the theme config section still can add custom styles via theme.scss.

@davidsneighbour
Copy link
Owner Author

See https://discourse.gohugo.io/t/camel-case-to-dashed-case/37757/5

It's easier than that:

{{ $v := "someCamelCase" }}
{{ add "--" ($v | humanize | lower | replaceRE " " "-") }}

@davidsneighbour
Copy link
Owner Author

stylesheet is a path to a stylesheet (looks by default for assets/scss/giscus/theme.scss). This stylesheet will import the original theme selected under giscus (loading via getRemote), then subsequent properties under theme are added as overrides and exports the finished stylesheet.

Let's rephrase this: The file in stylesheet will be used in connection with a pipeline, that will do the following steps:

  • import the original theme selected under giscus
  • override properties with specific properties set up below giscus>theme
  • then the file in stylesheet will be imported and the stylesheet will be created.

@davidsneighbour davidsneighbour changed the title Add custom theming hugo-giscus: add custom theming Apr 3, 2023
@davidsneighbour davidsneighbour transferred this issue from davidsneighbour/hugo-giscus Apr 3, 2023
@davidsneighbour davidsneighbour added state:unconfirmed This issue needs to be reproduced. module:giscus state:confirmed This issue is confirmed. type:enhancement New enhancements and features. and removed enhancement state:unconfirmed This issue needs to be reproduced. labels Aug 4, 2024
@davidsneighbour davidsneighbour changed the title hugo-giscus: add custom theming giscus: add custom theming Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:giscus state:confirmed This issue is confirmed. type:enhancement New enhancements and features.
Projects
None yet
Development

No branches or pull requests

1 participant