Commit graph

47 commits

Author SHA1 Message Date
Bjørn Erik Pedersen
245928a1ff content adapter: Add support for menus in AddPage
Fixes #12507
2024-05-30 11:29:21 +02:00
Bjørn Erik Pedersen
d02f0622b4 livereload: Improve the livereload script build and update to v4.0.2
This script has very infrequent updates, but just copy pasting the minified source creates some potential trust issues.

This JS will now be pulled from a Git version and both the unminified and minified version gets written to disk.

This way it should be easier to reason about changes in the future.

To upgrade, change the commit hash and run `mage generate`.

Closes #12451
Closes #6290
2024-05-10 22:33:08 +02:00
Bjørn Erik Pedersen
5b7cb258ec Create default link and image render hooks
Fixes #11933
2024-01-30 20:12:19 +01:00
abdullah-alaadine
37a2d5eb4e magefile: Update isGoLatest to check for Go 1.21 2023-10-04 16:07:40 +02:00
Bjørn Erik Pedersen
06faee5beb github: Fix Windows build
Also update some Actions to get rid of some warnings.

Fixes #11052
2023-06-01 09:54:40 +02:00
Bjørn Erik Pedersen
a669467d98 Misc ioutil deprecation adjustments
To make the tests pass.

* Replace io => os.ReadFile in magefile.go
* Adjust failing image test vs fs.DirEntry
* Adjust poller test

See #10732
2023-03-01 16:28:43 +01:00
Oleksandr Redko
d453c12742 Replace deprecated ioutil with io and os
https://pkg.go.dev/io/ioutil is deprecated since Go 1.16.
2023-03-01 16:28:43 +01:00
Bjørn Erik Pedersen
ad2059878a Also consider wrapped errors when checking for file IsNotExist errors
Fixes #10534
2022-12-14 13:51:06 +01:00
Bjørn Erik Pedersen
52edea0fec github: Set HUGO_BUILD_TAGS: extended when running tests
Also fix TestDecodeConfig/Basic which started to fail in the extended build in 0.99.1.

Closes #9935
2022-05-27 11:55:03 +02:00
Bjørn Erik Pedersen
9539069f5e commands: Improve server startup to make tests less flaky
Do this by announcing/listen on the local address before we start the server.
2022-03-21 09:32:35 +01:00
Bjørn Erik Pedersen
b80853de90
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
2022-03-17 22:03:27 +01:00
Bjørn Erik Pedersen
64afb7ca51 Use revision etc. from debug.BuildInfo
Fixes #9680
2022-03-17 17:14:38 +01:00
Bjørn Erik Pedersen
b0a9cf0a75 tpl: Use go:embed to load internal templates
Fixes #8297
2022-02-14 09:39:46 +01:00
Bjørn Erik Pedersen
d90e37e0c6 all: Format code with gofumpt
See https://github.com/mvdan/gofumpt
2020-12-03 13:12:58 +01:00
Eric Hagman
f465c5c307
build: Allow optional "nodeploy" tag to exclude deploy command from bin
Fixes #7826
2020-10-23 09:03:41 +02:00
Bjørn Erik Pedersen
e627449c0a Update to Go 1.15
Fixes #7554
2020-08-16 21:37:26 +02:00
Ricardo N Feliciano
21dbfa1f11 mage: Add uninstall target 2020-07-30 08:44:51 +02:00
Cameron Moore
889dc47ceb Add genDocsHelper mage target
Expose the functionality of the hidden `hugo gen docshelper` command as
a mage target.
2020-06-15 20:07:28 +02:00
Bjørn Erik Pedersen
33ae621083 Update to Go 1.14 and 1.13.8
Fixes #6958
2020-02-26 17:33:11 +01:00
Bjørn Erik Pedersen
167c01530b
Create lightweight forks of text/template and html/template
This commit also removes support for Ace and Amber templates.

Updates #6594
2019-12-12 09:59:34 +01:00
Bjørn Erik Pedersen
71597bd1ad mage: Restore -v behaviour 2019-11-25 18:59:06 +01:00
Chris Trimble
8beaa4c25e mage: Fix mage check on darwin and add debugging output
Darwin no longer supports 386 builds after Catalina. Also add
debugging output when running test suites from mage.
2019-11-25 09:48:26 +01:00
Anthony Fok
c6d69d0c95 mage: Skip Test386 on non-AMD64 architectures
This is to allow "mage check" to run on arm64 on Travis CI.
2019-11-01 11:03:06 -06:00
Bjørn Erik Pedersen
9e57182705
tests: Convert from testify to quicktest 2019-08-12 13:26:32 +02:00
Bjørn Erik Pedersen
9f5a92078a
Add Hugo Modules
This commit implements Hugo Modules.

This is a broad subject, but some keywords include:

* A new `module` configuration section where you can import almost anything. You can configure both your own file mounts nd the file mounts of the modules you import. This is the new recommended way of configuring what you earlier put in `configDir`, `staticDir` etc. And it also allows you to mount folders in non-Hugo-projects, e.g. the `SCSS` folder in the Bootstrap GitHub project.
* A module consists of a set of mounts to the standard 7 component types in Hugo: `static`, `content`, `layouts`, `data`, `assets`, `i18n`, and `archetypes`. Yes, Theme Components can now include content, which should be very useful, especially in bigger multilingual projects.
* Modules not in your local file cache will be downloaded automatically and even "hot replaced" while the server is running.
* Hugo Modules supports and encourages semver versioned modules, and uses the minimal version selection algorithm to resolve versions.
* A new set of CLI commands are provided to manage all of this: `hugo mod init`,  `hugo mod get`,  `hugo mod graph`,  `hugo mod tidy`, and  `hugo mod vendor`.

All of the above is backed by Go Modules.

Fixes #5973
Fixes #5996
Fixes #6010
Fixes #5911
Fixes #5940
Fixes #6074
Fixes #6082
Fixes #6092
2019-07-24 09:35:53 +02:00
Bjørn Erik Pedersen
4dae52af68 Avoid nilpointer on no File on Page
Fixes #5781
2019-03-26 10:20:40 +01:00
Bjørn Erik Pedersen
597e418cb0
Make Page an interface
The main motivation of this commit is to add a `page.Page` interface to replace the very file-oriented `hugolib.Page` struct.
This is all a preparation step for issue  #5074, "pages from other data sources".

But this also fixes a set of annoying limitations, especially related to custom output formats, and shortcodes.

Most notable changes:

* The inner content of shortcodes using the `{{%` as the outer-most delimiter will now be sent to the content renderer, e.g. Blackfriday.
  This means that any markdown will partake in the global ToC and footnote context etc.
* The Custom Output formats are now "fully virtualized". This removes many of the current limitations.
* The taxonomy list type now has a reference to the `Page` object.
  This improves the taxonomy template `.Title` situation and make common template constructs much simpler.

See #5074
Fixes #5763
Fixes #5758
Fixes #5090
Fixes #5204
Fixes #4695
Fixes #5607
Fixes #5707
Fixes #5719
Fixes #3113
Fixes #5706
Fixes #5767
Fixes #5723
Fixes #5769
Fixes #5770
Fixes #5771
Fixes #5759
Fixes #5776
Fixes #5777
Fixes #5778
2019-03-23 18:51:22 +01:00
Bjørn Erik Pedersen
7829474088
Add /config dir support
This commit adds support for a configuration directory (default `config`). The different pieces in this puzzle are:

* A new `--environment` (or `-e`) flag. This can also be set with the `HUGO_ENVIRONMENT` OS environment variable. The value for `environment` defaults to `production` when running `hugo` and `development` when running `hugo server`. You can set it to any value you want (e.g. `hugo server -e "Sensible Environment"`), but as it is used to load configuration from the file system, the letter case may be important. You can get this value in your templates with `{{ hugo.Environment }}`.
* A new `--configDir` flag (defaults to `config` below your project). This can also be set with `HUGO_CONFIGDIR` OS environment variable.

If the `configDir` exists, the configuration files will be read and merged on top of each other from left to right; the right-most value will win on duplicates.

Given the example tree below:

If `environment` is `production`, the left-most `config.toml` would be the one directly below the project (this can now be omitted if you want), and then `_default/config.toml` and finally `production/config.toml`. And since these will be merged, you can just provide the environment specific configuration setting in you production config, e.g. `enableGitInfo = true`. The order within the directories will be lexical (`config.toml` and then `params.toml`).

```bash
config
├── _default
│   ├── config.toml
│   ├── languages.toml
│   ├── menus
│   │   ├── menus.en.toml
│   │   └── menus.zh.toml
│   └── params.toml
├── development
│   └── params.toml
└── production
    ├── config.toml
    └── params.toml
```

Some configuration maps support the language code in the filename (e.g. `menus.en.toml`): `menus` (`menu` also works) and `params`.

Also note that the only folders with "a meaning" in the above listing is the top level directories below `config`. The `menus` sub folder is just added for better organization.

We use `TOML` in the example above, but Hugo also supports `JSON` and `YAML` as configuration formats. These can be mixed.

Fixes #5422
2018-12-11 13:08:36 +01:00
Bjørn Erik Pedersen
831d23cb4d Add tpl/site and tpl/hugo
This means that the current `.Site` and ´.Hugo` is available as a globals, so you can do `site.IsServer`, `hugo.Version` etc.

Fixes #5470
Fixes #5467
Fixes #5503
2018-12-06 14:37:25 +01:00
Michael Henderson
47d4edce60 Fix error message for go vet 2018-08-30 22:30:49 +02:00
Bjørn Erik Pedersen
ea8ef573c6 mage: Init packages once
`go list ./...` fails when run in parallel on Windows. This also applies to running `go test ./...` and `go list/...` so we serialize tests.
2018-08-30 13:36:33 +02:00
Bjørn Erik Pedersen
fdf3c3b823 build: Remove the remains of Go Dep
Appveyor is now Go 1.11 ready, so we can go all "Go Modules".

Closes #5115
2018-08-30 13:36:33 +02:00
Bjørn Erik Pedersen
45c9c45d1d Use Go 1.11 modules with Mage
See #5115
2018-08-25 20:50:58 +02:00
Bjørn Erik Pedersen
d32ff16fd6 Update Travis to Go 1.11 and Go 1.10.4
See #5115
2018-08-25 17:37:42 +02:00
Bjørn Erik Pedersen
dea71670c0
Add Hugo Piper with SCSS support and much more
Before this commit, you would have to use page bundles to do image processing etc. in Hugo.

This commit adds

* A new `/assets` top-level project or theme dir (configurable via `assetDir`)
* A new template func, `resources.Get` which can be used to "get a resource" that can be further processed.

This means that you can now do this in your templates (or shortcodes):

```bash
{{ $sunset := (resources.Get "images/sunset.jpg").Fill "300x200" }}
```

This also adds a new `extended` build tag that enables powerful SCSS/SASS support with source maps. To compile this from source, you will also need a C compiler installed:

```
HUGO_BUILD_TAGS=extended mage install
```

Note that you can use output of the SCSS processing later in a non-SCSSS-enabled Hugo.

The `SCSS` processor is a _Resource transformation step_ and it can be chained with the many others in a pipeline:

```bash
{{ $css := resources.Get "styles.scss" | resources.ToCSS | resources.PostCSS | resources.Minify | resources.Fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

The transformation funcs above have aliases, so it can be shortened to:

```bash
{{ $css := resources.Get "styles.scss" | toCSS | postCSS | minify | fingerprint }}
<link rel="stylesheet" href="{{ $styles.RelPermalink }}" integrity="{{ $styles.Data.Digest }}" media="screen">
```

A quick tip would be to avoid the fingerprinting part, and possibly also the not-superfast `postCSS` when you're doing development, as it allows Hugo to be smarter about the rebuilding.

Documentation will follow, but have a look at the demo repo in https://github.com/bep/hugo-sass-test

New functions to create `Resource` objects:

* `resources.Get` (see above)
* `resources.FromString`: Create a Resource from a string.

New `Resource` transformation funcs:

* `resources.ToCSS`: Compile `SCSS` or `SASS` into `CSS`.
* `resources.PostCSS`: Process your CSS with PostCSS. Config file support (project or theme or passed as an option).
* `resources.Minify`: Currently supports `css`, `js`, `json`, `html`, `svg`, `xml`.
* `resources.Fingerprint`: Creates a fingerprinted version of the given Resource with Subresource Integrity..
* `resources.Concat`: Concatenates a list of Resource objects. Think of this as a poor man's bundler.
* `resources.ExecuteAsTemplate`: Parses and executes the given Resource and data context (e.g. .Site) as a Go template.

Fixes #4381
Fixes #4903
Fixes #4858
2018-07-06 11:46:12 +02:00
Bjørn Erik Pedersen
34ad9a4f17
tpl/tplimpl: Extract internal templates
Having them in separate files should make maintainance easier.

When adding new or making changes to the templates:

```bash
mage generate
```

This will get the Go code in sync.

Fixes #4457
2018-05-04 23:12:10 +02:00
Bjørn Erik Pedersen
772128485a Run gofmt -s with Go 1.10
See #4434
2018-02-21 09:59:33 +01:00
Bjørn Erik Pedersen
3ced6f8d47
magefile: Disable Go 1.10 gofmt check for now 2018-02-17 01:24:07 +01:00
Bjørn Erik Pedersen
20c9b6ec81
resource: Add front matter metadata to Resource
This commit expands the Resource interface with 3 new methods:

* Name
* Title
* Params

All of these can be set in the Page front matter. `Name` will get its default value from the base filename, and is the value used in the ByPrefix and GetByPrefix lookup methods.

Fixes #4244
2018-01-17 16:22:33 +01:00
Vas Sudanagunta
d5803da1be Support offline builds 2018-01-11 17:22:12 +01:00
Bjørn Erik Pedersen
3153526161
mage: Do not run Go Fmt check on Go tip 2017-12-07 22:38:54 +01:00
Bjørn Erik Pedersen
133cfd1710 mage: Skip Check on Go 1.8
See #3988
2017-10-21 19:30:23 +02:00
Bjørn Erik Pedersen
f711b170e4 Update magefile to use Go Dep
See #3988
2017-10-21 19:30:23 +02:00
Nate Finch
c9c19d7945 Fix error handling in mage build
* print gofmt errors
* don't error on lint failures
* explanatory comments and fix an error text
2017-10-21 17:37:00 +02:00
Bjørn Erik Pedersen
ad5ef43838
Fix mage vs make issues
And remove Makefile ... for good.

Fixes #3969
2017-10-18 07:56:10 +02:00
Cameron Moore
66a169a249 Simplify HugoNoGitInfo in magefile 2017-10-07 14:42:54 +02:00
Nate Finch
384a6ac4bd Create magefile from Makefile
This commit makes a magefile.go that should be functionally equivalent to
the current Makefile.
2017-10-03 23:23:10 +02:00