diff --git a/assets/css/main.css b/assets/css/main.css index 24f564c..eb85dcf 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -888,49 +888,4 @@ ul.footer-menu>li { .post-pagination .pagination-item { max-width: 10em; } -} - - { - { - range site.Params.customCSS - } -} - - { - { - $custom : =resources.Get . - } -} - - { - { - $custom.Content - } -} - - { - { - end - } -} - - { - { - if site.Params.isso.enabled - } -} - -#isso-thread .textarea { - color: #000; -} - -#isso-thread .isso-feedlink { - position: relative; - z-index: 1; -} - - { - { - end - } } \ No newline at end of file diff --git a/exampleSiteMultilingual/assets/css/custom1.scss b/exampleSiteMultilingual/assets/css/custom1.scss new file mode 100644 index 0000000..aa327f5 --- /dev/null +++ b/exampleSiteMultilingual/assets/css/custom1.scss @@ -0,0 +1,17 @@ +@import 'foundation/code'; + +$font-stack: Helvetica, sans-serif; +$primary-color: yellow; +$background-color: pink; + +junyi { + font: 100% $font-stack; + color: $primary-color; + background-color: $background-color; +} + +body .container { + max-width: none; + padding-left: 5em; + padding-right: 5em; +} \ No newline at end of file diff --git a/exampleSiteMultilingual/assets/css/custom2.css b/exampleSiteMultilingual/assets/css/custom2.css new file mode 100644 index 0000000..63633d5 --- /dev/null +++ b/exampleSiteMultilingual/assets/css/custom2.css @@ -0,0 +1,7 @@ +.anubis-custom-style { + background-color: pink; + color: black; + padding: 1em; + border-radius: 0.3em; + border: 1px solid black; +} \ No newline at end of file diff --git a/exampleSiteMultilingual/assets/css/foundation/_code.scss b/exampleSiteMultilingual/assets/css/foundation/_code.scss new file mode 100644 index 0000000..5a98919 --- /dev/null +++ b/exampleSiteMultilingual/assets/css/foundation/_code.scss @@ -0,0 +1,5 @@ +code { + padding: .25em; + line-height: 2; + background-color: rgb(189, 204, 255); +} \ No newline at end of file diff --git a/exampleSiteMultilingual/content/posts/advanced-style.md b/exampleSiteMultilingual/content/posts/advanced-style.md new file mode 100644 index 0000000..e09b87f --- /dev/null +++ b/exampleSiteMultilingual/content/posts/advanced-style.md @@ -0,0 +1,42 @@ ++++ +author = "Hugo Authors" +title = "Advanced Style" +date = "2024-04-09" +description = "Guide to advanced usage of Anubis2" +tags = [ + "emoji", +] ++++ + +
+The custom .css .scss .sass file should be placed in assets/ folder. (instead of static/) +
+ +This page is affected by `assets/css/custom1.scss` and `assets/css/custom2.css` + +## How to use PoseCSS + +First, make sure your Hugo version supports Hugo Pipes. Hugo Pipes is available in Hugo `0.46` and later versions. + +Then, add the following content to your Hugo configuration file (such as config.toml) to enable PostCSS: + +```toml +[build] + writeStats = true + +[params] + usePostCSS = true +``` + +In addition, you need to create a postcss.config.js file in the root directory of your project, with the following content: + +```js +module.exports = { + plugins: [ + require('postcss-import')(), + require('postcss-url')(), + require('autoprefixer')(), + // Add more PostCSS plugins here if needed + ] +}; +``` diff --git a/exampleSiteMultilingual/hugo.toml b/exampleSiteMultilingual/hugo.toml index a70f16d..3d1041c 100644 --- a/exampleSiteMultilingual/hugo.toml +++ b/exampleSiteMultilingual/hugo.toml @@ -38,6 +38,8 @@ GiscusCategoryId = "DIC_kwDOLEp76c4CcbPS" GiscusLazyLoad = false GiscusDataMapping = "pathname" +customCSS = ["css/custom1.scss", "css/custom2.css"] + [[params.social]] id = "docs" url = "https://gohugo.io/documentation/" diff --git a/layouts/partials/head.html b/layouts/partials/head.html index a902d73..b5f4bf5 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -54,6 +54,29 @@ {{ partial "resource.html" (dict "context" . "type" "css" "filename" "css/light.css") }} {{ partial "resource.html" (dict "context" . "type" "css" "filename" "css/dark.css") }} + +{{ $opts := dict "transpiler" "libsass" "targetPath" "css/style.css" }} + + +{{ range site.Params.customCSS }} + {{ with resources.Get . | toCSS $opts | minify | fingerprint }} + + {{ end }} +{{ end }} + +{{ if site.Params.isso.enabled }} {{/* TODO: maybe we can remove it */}} + +{{ end }} + + {{ if .Site.Params.copyCodeButton | default true }} {{ partial "resource.html" (dict "context" . "type" "js" "filename" "js/copy-code.js") }} {{ end }}