summaryrefslogtreecommitdiffstats
path: root/hugolib/menu_test.go
AgeCommit message (Collapse)Author
2021-05-23navigation: Cache and copy Menu for sortingsatotake
.Site.Menus is mutated when it is sorted for now and this causes concurrency problem (#7594) In this patch, each related sort function copies Menu before sorting to prevent race condition. Pages already have such a sort and cache logic and this patch is identical to it. Closes #7594
2020-12-03all: Format code with gofumptBjørn Erik Pedersen
See https://github.com/mvdan/gofumpt
2020-11-22Add menu paramsDavid Jones
Fixes #7951
2019-08-12tests: Convert from testify to quicktestBjørn Erik Pedersen
2019-08-01Merge pull request #6149 from bep/sort-caseinsensitiveBjørn Erik Pedersen
Implement lexicographically string sorting
2019-07-24Add Hugo ModulesBjørn Erik Pedersen
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-06-09tpl/collections: Unwrap any interface value in sort and whereBjørn Erik Pedersen
Hugo `0.55.0` introduced some new interface types for `Page` etc. This worked great in general, but there were cases where this would fail in `where` and `sort`. One such example would be sorting by `MenuItem.Page.Date` where `Page` on `MenuItem` was a small subset of the bigger `page.Page` interface. This commit fixes that by unwrapping such interface values. Fixes #5989
2019-04-19Fix menu URL when multiple permalinkable output formatsBjørn Erik Pedersen
In Hugo `0.55` we introduced the `permalinkable` config attribute on Output Format, default enabled for `AMP` and `HTML`. This meant that a Page could have different `RelPermalink` and `Permalink` depending on the rendering format. The menu `URL` did not reflect that fact. Fixes #5849
2019-04-12hugolib: Fix simple menu configBjørn Erik Pedersen
This stopped working in Hugo 0.55: ```bash --- menu: "main" --- ``` This was also the case for using a slice of menu entries. This still worked: --- menu: main: weight: 30 ---
2019-03-23Make Page an interfaceBjørn Erik Pedersen
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
2018-04-02Add support for a content dir set per languageBjørn Erik Pedersen
A sample config: ```toml defaultContentLanguage = "en" defaultContentLanguageInSubdir = true [Languages] [Languages.en] weight = 10 title = "In English" languageName = "English" contentDir = "content/english" [Languages.nn] weight = 20 title = "På Norsk" languageName = "Norsk" contentDir = "content/norwegian" ``` The value of `contentDir` can be any valid path, even absolute path references. The only restriction is that the content dirs cannot overlap. The content files will be assigned a language by 1. The placement: `content/norwegian/post/my-post.md` will be read as Norwegian content. 2. The filename: `content/english/post/my-post.nn.md` will be read as Norwegian even if it lives in the English content folder. The content directories will be merged into a big virtual filesystem with one simple rule: The most specific language file will win. This means that if both `content/norwegian/post/my-post.md` and `content/english/post/my-post.nn.md` exists, they will be considered duplicates and the version inside `content/norwegian` will win. Note that translations will be automatically assigned by Hugo by the content file's relative placement, so `content/norwegian/post/my-post.md` will be a translation of `content/english/post/my-post.md`. If this does not work for you, you can connect the translations together by setting a `translationKey` in the content files' front matter. Fixes #4523 Fixes #4552 Fixes #4553
2017-12-15Add .Title and .Page to MenuEntryRichard Metzler
It uses `title` if configured on the menu entry. If not, it uses the `Page.Title` when possible. Fixes #2784
2017-04-02tpl: Rework to handle both text and HTML templatesBjørn Erik Pedersen
Before this commit, Hugo used `html/template` for all Go templates. While this is a fine choice for HTML and maybe also RSS feeds, it is painful for plain text formats such as CSV, JSON etc. This commit fixes that by using the `IsPlainText` attribute on the output format to decide what to use. A couple of notes: * The above requires a nonambiguous template name to type mapping. I.e. `/layouts/_default/list.json` will only work if there is only one JSON output format, `/layouts/_default/list.mytype.json` will always work. * Ambiguous types will fall back to HTML. * Partials inherits the text vs HTML identificator of the container template. This also means that plain text templates can only include plain text partials. * Shortcode templates are, by definition, currently HTML templates only. Fixes #3221
2017-02-20hugolib: Finish menu vs section content pagesBjørn Erik Pedersen
This commit also fixes the default menu sort when the weight is 0. Closes #2974
2017-02-17all: Refactor to nonglobal Viper, i18n etc.Bjørn Erik Pedersen
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
2017-02-04all: Refactor to nonglobal file systemsBjørn Erik Pedersen
Updates #2701 Fixes #2951
2017-01-07all: Refactor to non-global loggerBjørn Erik Pedersen
Note that this looks like overkill for just the logger, and that is correct, but this will make sense once we start with the template handling etc. Updates #2701
2016-11-27hugolib: Fix regressions with uglyURLsBjørn Erik Pedersen
Fixes #2734
2016-11-22node to page: Handle URLsBjørn Erik Pedersen
This includes removing the error return value from Permalink and RelPermalink. We ignore that error all over the place, so we might as well remove it. Updates #2297
2016-11-22node to page: Remove NodeBjørn Erik Pedersen
And misc. TODO-fixes Updates #2297
2016-11-22node to page: Rename PageType to KindBjørn Erik Pedersen
And embed that on Page. Updates #2297
2016-11-22node to page: Add Pages to PageBjørn Erik Pedersen
As an alias to .Data.Pages for home page etc. Also renamte NodeType to PageType and make it a string so it can be used in `where`. Updates #2297
2016-11-22node to page: Make Nodes into PagesBjørn Erik Pedersen
* `.Site.Pages` now contains all page types, including sections etc. * `.Data.Pages` will also contain "node type" pages where relevant. Updates #2297
2016-11-22node to page: Remove unused codeBjørn Erik Pedersen
Updates #2297
2016-11-22node to page: Handle aliases, 404, robots.txt, sitemapBjørn Erik Pedersen
Updates #2297
2016-11-22node to page: Handle translationsBjørn Erik Pedersen
Updates #2297
2016-11-06hugolib: Fix page sorting when weight is zeroBjørn Erik Pedersen
Fixes #2673
2016-10-24all: Unify case of config variable namesAlbert Nigmatzianov
All config variables starts with low-case and uses camelCase. If there is abbreviation at the beginning of the name, the whole abbreviation will be written in low-case. If there is abbreviation at the end of the name, the whole abbreviation will be written in upper-case. For example, rssURI.
2016-09-06Create a Node map to get proper node translationsBjørn Erik Pedersen
In a multi-language setup, before this commit the Node's Translations() method would return some "dummy nodes" that would point to the correct page (Permalink), but would not be the same as the node it points to -- it would not have the translated title etc. The node creation is, however, so mingled with rendering, whihc is too early to have any global state, so the nodes has to be split in a prepare and a render phase. This commits does that with as small a change as possible. This implementation is a temp solution until we fix #2297. Updates #2309
2016-09-06Improve language handling in URLsBjørn Erik Pedersen
The current "rendering language" is needed outside of Site. This commit moves the Language type to the helpers package, and then used to get correct correct language configuration in the markdownify template func. This commit also adds two new template funcs: relLangURL and absLangURL. See #2309
2016-09-06Optimize the multilanguage build processBjørn Erik Pedersen
Work In Progress! This commit makes a rework of the build and rebuild process to better suit a multi-site setup. This also includes a complete overhaul of the site tests. Previous these were a messy mix that were testing just small parts of the build chain, some of it testing code-paths not even used in "real life". Now all tests that depends on a built site follows the same and real production code path. See #2309 Closes #2211 Closes #477 Closes #1744
2016-09-06Add Translations and AllTranslations to NodeBjørn Erik Pedersen
This commit also consolidates URLs on Node vs Page, so now .Permalink should be interoperable. Note that this implementations should be fairly short-livded, waiting for #2297, but the API should be stable.
2016-09-06Introduce HugoSites typeBjørn Erik Pedersen
And a Hugo global variable which contains the site under build. This is really needed to get some level of control of the "multiple languages" in play. There are still work related to this scattered around, but that will come. With this commit, the multilingual feature is starting to work.
2016-09-06Add multilingual support in HugoAlexandre Bourget
Implements: * support to render: * content/post/whatever.en.md to /en/2015/12/22/whatever/index.html * content/post/whatever.fr.md to /fr/2015/12/22/whatever/index.html * gets enabled when `Multilingual:` is specified in config. * support having language switchers in templates, that know where the translated page is (with .Page.Translations) (when you're on /en/about/, you can have a "Francais" link pointing to /fr/a-propos/) * all translations are in the `.Page.Translations` map, including the current one. * easily tweak themes to support Multilingual mode * renders in a single swift, no need for two config files. Adds a couple of variables useful for multilingual sites Adds documentation (content/multilingual.md) Added language prefixing for all URL generation/permalinking see in the code base. Implements i18n. Leverages the great github.com/nicksnyder/go-i18n lib.. thanks Nick. * Adds "i18n" and "T" template functions..
2016-08-20Switch to a more up to date TOML libraryBjørn Erik Pedersen
Fixes #2089
2016-08-19hugolib: Use named keys in composite literalsCameron Moore
Make `go vet` great again
2016-05-08Remove kr/pretty dependencyBjørn Erik Pedersen
Fixes #2124 See https://github.com/kr/text/issues/6
2016-04-10Fix section menus for lazy bloggerBjørn Erik Pedersen
IsMenuCurrent was always returning false for the top level entries. Fixes #2065
2016-04-08hugolib: Un-export internal Site-methodsBjørn Erik Pedersen
These are obviously internal and for the most part undocumented, creating lots of GoLint warnings. See #1160 See #2014
2016-03-31Add readFile template funcBjørn Erik Pedersen
This also includes a refactor of the hugofs package and its usage. The motivation for that is: The Afero filesystems are brilliant. Hugo's way of adding a dozen of global variables for the different filesystems was a mistake. In readFile (and also in some other places in Hugo today) we need a way to restrict the access inside the working dir. We could use ioutil.ReadFile and implement the path checking, checking the base path and the dots ("..") etc. But it is obviously better to use an Afero BasePathFs combined witha ReadOnlyFs. We could create a use-once-filesystem and handle the initialization ourselves, but since this is also useful to others and the initialization depends on some other global state (which would mean to create a new file system on every invocation), we might as well do it properly and encapsulate the predefined set of filesystems. This change also leads the way, if needed, to encapsulate the file systems in a struct, making it possible to have several file system sets in action at once (parallel multilanguage site building? With Moore's law and all...) Fixes #1551
2016-03-23Spring cleaning of the menu codeBjørn Erik Pedersen
2016-03-22hugolib: Fix Java-styled all-caps constsBjørn Erik Pedersen
2016-03-14hugolib: Remove unused codeBjørn Erik Pedersen
2016-03-10Fix for page in multiple menusBjørn Erik Pedersen
Fixes #1934
2016-02-07Add missing menu testsBjørn Erik Pedersen
2016-02-07Add menu sort testsBjørn Erik Pedersen
2016-02-06Fix buggy Menu.Limit()Bjørn Erik Pedersen
2016-01-14Add one more menu testBjørn Erik Pedersen
See #1774
2016-01-14Add menu test for external URLBjørn Erik Pedersen
See #1774
2015-12-10Add copyright header to that source files that don’t have one.Anthony Fok
See #1646