paazca / wowchemy-rtl-module

A Hugo module which improves Wowchemy's support for right-to-left languages (such as Hebrew and Arabic) by converting the CSS using RTLCSS.
MIT License
0 stars 0 forks source link

Could not use this module with wowchemy sponsor version #1

Closed akaalharbi closed 2 years ago

akaalharbi commented 2 years ago

Thank you for making this module publicly available.

I tried using it with the repository personal website, where I added layouts/partials/site_head.html from site_head.html

However, I received number of errors (see below for the full message). I tried to address the error

Hugo Chroma themes github-light.css and dracula.css not found in css/libs/chroma/

by calling hugo gen chromastyles but it did not work.

Full message after running hugo server

Start building sites … hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended linux/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio ERROR 2022/06/19 10:46:38 Hugo Chroma themes github-light.css and dracula.css not found in css/libs/chroma/. See https://gohugo.io/commands/hugo_gen_chromastyles/ WARN 2022/06/19 10:46:38 Hugo cannot find a Widget Page at ar/home/index..md! WARN 2022/06/19 10:46:38 If the page exists, Hugo Server may need restarting due to file changes. WARN 2022/06/19 10:46:38 View the Widget Page documentation at https://wowchemy.com/docs/managing-content/#create-a-widget-page . WARN 2022/06/19 10:46:38 If the Hugo version is between 0.65 and 0.68, it may be a confirmed Hugo bug that is expected to be fixed in Hugo v0.69: https://github.com/wowchemy/wowchemy-hugo-themes/issues/1595#issuecomment-605514973 . ERROR 2022/06/19 10:46:38 js.Build failed: Could not resolve "./wowchemy-utils" ERROR 2022/06/19 10:46:38 js.Build failed: Could not resolve "./wowchemy-theming" ERROR 2022/06/19 10:46:38 Hugo Chroma themes github-light.css and dracula.css not found in css/libs/chroma/. See https://gohugo.io/commands/hugo_gen_chromastyles/ ERROR 2022/06/19 10:46:38 js.Build failed: Could not resolve "./wowchemy-utils" ERROR 2022/06/19 10:46:38 js.Build failed: Could not resolve "./wowchemy-theming" WARN 2022/06/19 10:46:38 Hugo cannot find a Widget Page at home/index..md! WARN 2022/06/19 10:46:38 If the page exists, Hugo Server may need restarting due to file changes. WARN 2022/06/19 10:46:38 View the Widget Page documentation at https://wowchemy.com/docs/managing-content/#create-a-widget-page . WARN 2022/06/19 10:46:38 If the Hugo version is between 0.65 and 0.68, it may be a confirmed Hugo bug that is expected to be fixed in Hugo v0.69: https://github.com/wowchemy/wowchemy-hugo-themes/issues/1595#issuecomment-605514973 . ERROR 2022/06/19 10:46:38 JSBUILD: failed to transform "en/js/wowchemy-bundle.js" (application/javascript): Could not resolve "./_vendor/medium-zoom.esm" ERROR 2022/06/19 10:46:38 JSBUILD: failed to transform "js/wowchemy.js" (application/javascript): "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5@v5.0.0-20220423181119-d13358e38fee/assets/js/wowchemy.js:9:25": No matching export in "ns-params:@params" for import "codeHighlighting" ERROR 2022/06/19 10:46:38 JSBUILD: failed to transform "ar/js/wowchemy-bundle.js" (application/javascript): Could not resolve "./_vendor/medium-zoom.esm" Error: Error building site: JSBUILD: failed to transform "js/wowchemy.js" (application/javascript): "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5@v5.0.0-20220423181119-d13358e38fee/assets/js/wowchemy.js:9:25": No matching export in "ns-params:@params" for import "codeHighlighting" Built in 262 ms

paazca commented 2 years ago

Hi, from looking through your repository it seems like you aren't using the latest version of Wowchemy. You can update Wowchemy (https://wowchemy.com/docs/hugo-tutorials/update/) and this module should work correctly.

Alternatively, use the site_head.html from the version you're using. (By looking at your go.mod file it seems to be https://github.com/wowchemy/wowchemy-hugo-themes/blob/d13358e38feed9179a05617493359f52388e160b/wowchemy/layouts/partials/site_head.html) add the following code right after the line {{ $style := slice $css_bundle_head $style | resources.Concat "css/wowchemy.css" }}:

{{- $language_code := site.LanguageCode | default "en-us" -}}
{{- if in site.Data.i18n.rtl.rtl $language_code -}}
  {{- $style = slice $style | resources.Concat "css/wowchemy-rtl.css" | resources.PostCSS (dict "use" "rtlcss" "noMap" true) -}}
{{- end -}}
akaalharbi commented 2 years ago

You are amazing, I updated the wowchemy and it worked!

Also, in my case the effect took a place after writing .Site.Language.Lang instead of site.LanguageCode in this line {{- $language_code := site.LanguageCode | default "en-us" -}}.

paazca commented 2 years ago

You are amazing, I updated the wowchemy and it worked!

That's great to hear!

Also, in my case the effect took a place after writing .Site.Language.Lang instead of site.LanguageCode in this line {{- $language_code := site.LanguageCode | default "en-us" -}}.

That's because in your config/_default/languages.yaml file you wrote languageCode: /ar instead of languageCode: ar

You should probably fix it, because in https://github.com/wowchemy/wowchemy-hugo-themes/blob/main/wowchemy/layouts/_default/baseof.html (and in other places) Wowchemy uses site.LanguageCode too.