summaryrefslogtreecommitdiffstats
path: root/resources/resource_transformers
AgeCommit message (Collapse)Author
2024-04-08babel: Run go fmtBjørn Erik Pedersen
2024-04-08babel: Close file before removingguangwu
2024-03-15all: Typo fixesChristian Oliff
2024-03-01Fix and add integration test for the Bootstrap SCSS module for both Dart ↵Bjørn Erik Pedersen
Sass and Libsass This fixes the reverse filesystem lookup (absolute filename to path relative to the composite filesystem). The old logic had some assumptions about the locality of the actual files that didn't work in more complex scenarios. This commit now also adds the popular Bootstrap SCSS Hugo module to the CI build (both for libsass and dartsass transpiler), so we can hopefully avoid similar future breakage. Fixes #12178
2024-02-24tocss: Fix the import resolving from absolute to relative assets pathsBjørn Erik Pedersen
Fixes #12137
2024-02-23js: Support JSX and JSXImportSourceOptionsBenjamin Altpeter
Fixes #12118
2024-02-20Fix dart sass import regressionBjørn Erik Pedersen
Fixes #12072
2024-01-28all: Run gofumpt -l -w .Bjørn Erik Pedersen
2024-01-28testing: Simplify some integration testsBjørn Erik Pedersen
2024-01-28testing: Rename integration_test.go to PACKAGE_integration_test.goBjørn Erik Pedersen
Primary motivation making them easier to find in the code editor.
2024-01-27all: Rework page store, add a dynacache, improve partial rebuilds, and some ↵develop2024Bjørn Erik Pedersen
general spring cleaning There are some breaking changes in this commit, see #11455. Closes #11455 Closes #11549 This fixes a set of bugs (see issue list) and it is also paying some technical debt accumulated over the years. We now build with Staticcheck enabled in the CI build. The performance should be about the same as before for regular sized Hugo sites, but it should perform and scale much better to larger data sets, as objects that uses lots of memory (e.g. rendered Markdown, big JSON files read into maps with transform.Unmarshal etc.) will now get automatically garbage collected if needed. Performance on partial rebuilds when running the server in fast render mode should be the same, but the change detection should be much more accurate. A list of the notable new features: * A new dependency tracker that covers (almost) all of Hugo's API and is used to do fine grained partial rebuilds when running the server. * A new and simpler tree document store which allows fast lookups and prefix-walking in all dimensions (e.g. language) concurrently. * You can now configure an upper memory limit allowing for much larger data sets and/or running on lower specced PCs. We have lifted the "no resources in sub folders" restriction for branch bundles (e.g. sections). Memory Limit * Hugos will, by default, set aside a quarter of the total system memory, but you can set this via the OS environment variable HUGO_MEMORYLIMIT (in gigabytes). This is backed by a partitioned LRU cache used throughout Hugo. A cache that gets dynamically resized in low memory situations, allowing Go's Garbage Collector to free the memory. New Dependency Tracker: Hugo has had a rule based coarse grained approach to server rebuilds that has worked mostly pretty well, but there have been some surprises (e.g. stale content). This is now revamped with a new dependency tracker that can quickly calculate the delta given a changed resource (e.g. a content file, template, JS file etc.). This handles transitive relations, e.g. $page -> js.Build -> JS import, or $page1.Content -> render hook -> site.GetPage -> $page2.Title, or $page1.Content -> shortcode -> partial -> site.RegularPages -> $page2.Content -> shortcode ..., and should also handle changes to aggregated values (e.g. site.Lastmod) effectively. This covers all of Hugo's API with 2 known exceptions (a list that may not be fully exhaustive): Changes to files loaded with template func os.ReadFile may not be handled correctly. We recommend loading resources with resources.Get Changes to Hugo objects (e.g. Page) passed in the template context to lang.Translate may not be detected correctly. We recommend having simple i18n templates without too much data context passed in other than simple types such as strings and numbers. Note that the cachebuster configuration (when A changes then rebuild B) works well with the above, but we recommend that you revise that configuration, as it in most situations should not be needed. One example where it is still needed is with TailwindCSS and using changes to hugo_stats.json to trigger new CSS rebuilds. Document Store: Previously, a little simplified, we split the document store (where we store pages and resources) in a tree per language. This worked pretty well, but the structure made some operations harder than they needed to be. We have now restructured it into one Radix tree for all languages. Internally the language is considered to be a dimension of that tree, and the tree can be viewed in all dimensions concurrently. This makes some operations re. language simpler (e.g. finding translations is just a slice range), but the idea is that it should also be relatively inexpensive to add more dimensions if needed (e.g. role). Fixes #10169 Fixes #10364 Fixes #10482 Fixes #10630 Fixes #10656 Fixes #10694 Fixes #10918 Fixes #11262 Fixes #11439 Fixes #11453 Fixes #11457 Fixes #11466 Fixes #11540 Fixes #11551 Fixes #11556 Fixes #11654 Fixes #11661 Fixes #11663 Fixes #11664 Fixes #11669 Fixes #11671 Fixes #11807 Fixes #11808 Fixes #11809 Fixes #11815 Fixes #11840 Fixes #11853 Fixes #11860 Fixes #11883 Fixes #11904 Fixes #7388 Fixes #7425 Fixes #7436 Fixes #7544 Fixes #7882 Fixes #7960 Fixes #8255 Fixes #8307 Fixes #8863 Fixes #8927 Fixes #9192 Fixes #9324
2023-10-02resources/integrity: Return string instead of template.HTMLAttrJoe Mooring
Closes #11513
2023-07-17Improve error messages for PostCSS etc.Bjørn Erik Pedersen
Fixes #9730
2023-07-13js: Pass tsconfig.json to esBuildJoe Mooring
Note that esBuild only inspects/honors certain fields. See https://esbuild.github.io/content-types/#tsconfig-json. Fixes #11232
2023-06-19tocss/dartsas: Avoid using Logf for the internal Dart Sass loggingBjørn Erik Pedersen
As that does not work when percentages are used in the log messages.
2023-06-19all: Fix typos in function names and commentsOleksandr Redko
2023-06-18Replace the old log setup, with structured logging etc.Bjørn Erik Pedersen
Fixes #11124
2023-06-12Upgrade to v2 of the Dart Sass Embedded ProtocolBjørn Erik Pedersen
Fixes #11059
2023-06-12Fix indented SASS imports for Dart SassBjørn Erik Pedersen
Fixes #11074
2023-05-28Fix Processed images count regression for multiple languagesBjørn Erik Pedersen
Fixes #11002
2023-05-22Revert "postcss: Improve validation of option 'config'"Bjørn Erik Pedersen
This reverts commit 9a0370e8eb71fed3ac04984020b6aa95c43f22ab. Closes #10990
2023-05-22postcss: Improve validation of option 'config'Andreas Deininger
2023-05-18all: Fix comments for exported functions and packagesOleksandr Redko
2023-05-16Create a struct with all of Hugo's config optionsBjørn Erik Pedersen
Primary motivation is documentation, but it will also hopefully simplify the code. Also, * Lower case the default output format names; this is in line with the custom ones (map keys) and how it's treated all the places. This avoids doing `stringds.EqualFold` everywhere. Closes #10896 Closes #10620
2023-03-20resources.functions: improve validationAndreas Deininger
2023-03-20resources: Fix typos in error message and variablesOleksandr Redko
2023-03-02Correct typos in Go commentsOleksandr Redko
2023-03-01Replace deprecated ioutil with io and osOleksandr Redko
https://pkg.go.dev/io/ioutil is deprecated since Go 1.16.
2023-02-25Add a page template funcBjørn Erik Pedersen
Fixes #9339
2023-02-24dartsass: Import CSS without extension at compile timeJoe Mooring
Applicable to Dart Sass only: - Sass imports with the .css extension indicate a plain CSS @import. - Sass imports without the .css extension are imported at compile time. Fixes #10592
2023-02-23sass: Remove some unused leftover codeBjørn Erik Pedersen
2023-02-23resources/sass: Remove debug statementsJoe Mooring
Closes #10470
2023-02-22tocss: Simplify the hugo:vars type handlingBjørn Erik Pedersen
Instead of maintaing a list of all CSS units and functions this commit: * Uses 3 regexps to detect typed CSS values (e.g. `24px`) + properly handle numeric Go types. * These regexps may have some false positives -- e.g. strings that needs to be quoted. * For that rare case, you can mark the string with e.g. `"32xxx" | css.Quoted` * For the opposite case: `"32" | css.Unquoted` Updates #10632
2023-02-22resource_transformers/tocss: Fixed hugo:vars castingAcClassic
Variables passed via the hugo:vars function where passed as type string. This caused problems when using the variables in sass functions because these expect a specific type. Now we check if the passed variables have to be quoted and therefore are of type string or if they should not be quoted and let the type interpretation up to the sass compiler. Fixes #10632
2023-02-21Add page fragments support to RelatedBjørn Erik Pedersen
The main topic of this commit is that you can now index fragments (content heading identifiers) when calling `.Related`. You can do this by: * Configure one or more indices with type `fragments` * The name of those index configurations maps to an (optional) front matter slice with fragment references. This allows you to link page<->fragment and page<->page. * This also will index all the fragments (heading identifiers) of the pages. It's also possible to use type `fragments` indices in shortcode, e.g.: ``` {{ $related := site.RegularPages.Related .Page }} ``` But, and this is important, you need to include the shortcode using the `{{<` delimiter. Not doing so will create infinite loops and timeouts. This commit also: * Adds two new methods to Page: Fragments (can also be used to build ToC) and HeadingsFiltered (this is only used in Related Content with index type `fragments` and `enableFilter` set to true. * Consolidates all `.Related*` methods into one, which takes either a `Page` or an options map as its only argument. * Add `context.Context` to all of the content related Page API. Turns out it wasn't strictly needed for this particular feature, but it will soon become usefil, e.g. in #9339. Closes #10711 Updates #9339 Updates #10725
2023-01-16deps: Upgrade github.com/evanw/esbuild v0.15.18 => v0.17.0Bjørn Erik Pedersen
Also add a test to make sure legal comments are preserved in JS bundles. Closes #10536
2022-12-22Add HUGO_PUBLISHDIR to the Node environmentBjørn Erik Pedersen
So you can do `process.env.HUGO_PUBLISHDIR` in your `postcss.config.js` to figure out where Hugo publishes its files. Note that the value will always be an absolute file path and will point to a directory on disk even when running `hugo server` in memory mode. If you write to this folder from PostCSS when running the server, you could run the server with one of these flags: ``` hugo server --renderToDisk hugo server --renderStaticToDisk ``` Fixes #10554
2022-12-21tocss: Add some more test casesBjørn Erik Pedersen
See #10555
2022-12-21tocss: Fix unquote case with double quotesSepts
See #10555
2022-12-20tocss: Add vars optionBjørn Erik Pedersen
This commit adds a new `vars` option to both the Sass transpilers (Dart Sass and Libsass). This means that you can pass a map with key/value pairs to the transpiler: ```handlebars {{ $vars := dict "$color1" "blue" "$color2" "green" "$font_size" "24px" }} {{ $cssOpts := (dict "transpiler" "dartsass" "outputStyle" "compressed" "vars" $vars ) }} {{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts }} ``` And the the variables will be available in the `hugo:vars` namespace. Example usage for Dart Sass: ```scss @use "hugo:vars" as v; p { color: v.$color1; font-size: v.$font_size; } ``` Note that Libsass does not support the `use` keyword, so you need to `import` them as global variables: ```scss @import "hugo:vars"; p { color: $color1; font-size: $font_size; } ``` Hugo will: * Add a missing leading `$` for the variable names if needed. * Wrap the values in `unquote('VALUE')` (Sass built-in) to get proper handling of identifiers vs other strings. This means that you can pull variables directly from e.g. the site config: ```toml [params] [params.sassvars] color1 = "blue" color2 = "green" font_size = "24px" image = "images/hero.jpg" ``` ```handlebars {{ $vars := site.Params.sassvars}} {{ $cssOpts := (dict "transpiler" "dartsass" "outputStyle" "compressed" "vars" $vars ) }} {{ $r := resources.Get "scss/main.scss" | toCSS $cssOpts }} ``` Fixes #10555
2022-12-13resources/js: Fix some import discrepancies between Hugo and ESBuildBjørn Erik Pedersen
This fixes the cases where ```js import 'imp2/index.js'; import 'imp3/foo.js'; ``` And these files lives in `assets` as: ``` imp2/index.ts imp3/foo.ts ``` Fixes #10527
2022-12-05dartsass: Add sourceMapIncludeSources optionBjørn Erik Pedersen
2022-09-06scss: Handle single-file sourcemaps correctlyJenny Rakoczy
Simple sites may only have one css file. Update the replace directive to correctly match single-file sourcemaps and multi-file sourcemaps. Verified locally with and without SASS and CSS imports. Fixes #8174
2022-06-12js: Resolve index.esm.jsBjørn Erik Pedersen
Same logic as for `index.{js,ts...}` files applies; if both `index.esm.js` and `index.js` exists (unlikely), you need to use the name with extension when importing, else the `index.js` will win. Fixes #8631
2022-05-27Don't use the baseURL /path as part of the resource cache keyBjørn Erik Pedersen
As that prevents Hugo projects with sub paths in their `baseURL` to use themes with cached resources. Fixes #9787
2022-05-27postcss: Make the resource cache key more stableBjørn Erik Pedersen
By using the input map as the basis, which means the hash will not change if we add/rename/remove options. This happened in Hugo 0.99, as we added a new options. This is unortunate. Unfortunately this means that the cache keys for PostCSS will change one more time in 0.100, but will be stable going forward. Note that we have implemented this pattern in all the other resource transformers. Updates #9787
2022-05-27github: Set HUGO_BUILD_TAGS: extended when running testsBjørn Erik Pedersen
Also fix TestDecodeConfig/Basic which started to fail in the extended build in 0.99.1. Closes #9935
2022-05-25Fix error message when PostCSS config file is not foundBjørn Erik Pedersen
Fixes #9927
2022-05-15Improve SASS errorsBjørn Erik Pedersen
Fixes #9897
2022-05-15postcss: Fix import error handlingBjørn Erik Pedersen
Note that we will now fail if `inlineImports` is enabled and we cannot resolve an import. You can work around this by either: * Use url imports or imports with media queries. * Set `skipInlineImportsNotFound=true` in the options Also get the argument order in the different NewFileError* funcs in line. Fixes #9895