summaryrefslogtreecommitdiffstats
path: root/hugolib/pageSort.go
AgeCommit message (Collapse)Author
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
2019-01-20Support numeric sort in ByParamAnton Harniakou
With this commit ByParam takes into account a type of a value under a key. If both values are numeric then they're coerced into float64 and then get compared. If any value isn't numeric, for example it's nil or string, then both values coerced into string and get compared as strings (lexicographicaly) Nil values are always sent to the end. Numeric values confirm to any type listed below: uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64 Closes #5305
2018-11-28hugolib: Fall back to title in ByLinkTitle sortBjørn Erik Pedersen
Fixes #4953
2018-11-01hugolib: Bump to ERROR for the deprecated Pages.SortBjørn Erik Pedersen
2018-09-21hugolib: Deprecate Pages.SortBjørn Erik Pedersen
In favour of ByWeight.
2018-09-21hugolib: Minor cleaning in the sorting codeBjørn Erik Pedersen
2018-04-21Make .Content (almost) always available in shortcodesBjørn Erik Pedersen
This resolves some surprising behaviour when reading other pages' content from shortcodes. Before this commit, that behaviour was undefined. Note that this has never been an issue from regular templates. It will still not be possible to get **the current shortcode's page's rendered content**. That would have impressed Einstein. The new and well defined rules are: * `.Page.Content` from a shortcode will be empty. The related `.Page.Truncated` `.Page.Summary`, `.Page.WordCount`, `.Page.ReadingTime`, `.Page.Plain` and `.Page.PlainWords` will also have empty values. * For _other pages_ (retrieved via `.Page.Site.GetPage`, `.Site.Pages` etc.) the `.Content` is there to use as you please as long as you don't have infinite content recursion in your shortcode/content setup. See below. * `.Page.TableOfContents` is good to go (but does not support shortcodes in headlines; this is unchanged) If you get into a situation of infinite recursion, the `.Content` will be empty. Run `hugo -v` for more information. Fixes #4632 Fixes #4653 Fixes #4655
2018-04-15Make Page.Content a method that returns interface{}Bjørn Erik Pedersen
To prepare for a `Resource.Content` method. See #4622
2018-03-16Add a way to merge pages by languageBjørn Erik Pedersen
As an example: ```html {{ $pages := .Site.RegularPages | lang.Merge $frSite.RegularPages | lang.Merge $enSite.RegularPages }} ``` Will "fill in the gaps" in the current site with, from left to right, content from the French site, and lastly the English. Fixes #4463
2018-01-17resource: Add front matter metadata to ResourceBjørn Erik Pedersen
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
2017-02-19hugolib: Enhance `.Param` to permit arbitrarily nested parameter referencesJohn Feminella
The Param method currently assumes that its argument is a single, distinct, top-level key to look up in the Params map. This enhances the Param method; it will now also attempt to see if the key can be interpreted as a nested chain of keys to look up in Params. Fixes #2598
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-10hugolib: Add ability to sort by frontmatter parametersJohn Feminella
2017-02-09hugolib: Correct repeated spelling errors in documentationJohn Feminella
2016-11-06hugolib: Fix page sorting when weight is zeroBjørn Erik Pedersen
Fixes #2673
2016-09-06Add Translations and AllTranslations methods to PageBjørn Erik Pedersen
Will revisit Node later.
2016-06-14hugolib: Add sort ByExpiryDate functionHanchen Wang
2016-04-22Add ByLastmod page sortBjørn Erik Pedersen
2016-03-25hugolib: Some more unexportsBjørn Erik Pedersen
2016-03-23hugolib: Fix spelling mistakeBjørn Erik Pedersen
2016-03-23hugolib: Add Godoc to pageSortBjørn Erik Pedersen
2016-02-06Fix buggy Pages.LimitBjørn Erik Pedersen
Also add missing page sort related tests.
2015-12-07Fix copyright headers in source filesBjørn Erik Pedersen
Still need to add some missing headers and an AUTHORS file. See #1646
2015-11-23Change the license to Apache 2.0Steve Francia
2015-09-30Use filepath as the last default sort key for pagesBjørn Erik Pedersen
2015-07-25Replace strings.CompareBjørn Erik Pedersen
Which is a Go 1.5 func. See #1299
2015-07-25Fix sort test and title sortBjørn Erik Pedersen
See #1299
2015-07-25Fall back to link title for default page sortBjørn Erik Pedersen
Fixes #1299
2015-07-23Fix data races in sorting and ReverseBjørn Erik Pedersen
The custom sort functions used from the templates had some subtle data race- and related issues, especially when used in the single page template. This commit fixes this by making copies and protect the read and writes with a RWMutex. The results are cached (it will typically be invoked *number of pages* times with exactly the same data). This is, not surprisingly, also faster: ``` benchmark old ns/op new ns/op delta BenchmarkSortByWeightAndReverse 14228 491 -96.55% benchmark old allocs new allocs delta BenchmarkSortByWeightAndReverse 1 0 -100.00% benchmark old bytes new bytes delta BenchmarkSortByWeightAndReverse 32 0 -100.00% ``` Fixes #1293
2015-03-07hugolib: apply some more Golint rulesbep
2014-11-01Add sort and grouping functions for publish date and param of PageTatsushi Demachi
`GroupBy` is modified to allow it to receive a method name argument for example `Type` as its first argument. It is only allowed to call with a method which takes no arguments and returns a result or a pair of a result and an error. The functions discussed at #443 are also added - `ByPublishDate`: Order contents by `PublishDate` front matter variable - `GroupByPublishDate(format, order)`: Group contents by `PublishDate` front matter variable formatted in string like `GroupByDate` - `GroupByParam(key, order)`: Group contents by `Param` front matter variable specified by `key` argument - `GroupByParamDate(key, format, order)`: Group contents by `Param` front matter variable specified by `key` argument and formatted in string like `GroupByDate`. It's effective against `time.Time` type front matter variable
2014-09-09Change all uses of sort.Sort to sort.Stable.Using sort.Stable ensures that ↵Nate Finch
even if the sort keys are the same, the order of the sort will not randomly change. Using the old sort.Sort, if you had pages with no date, the lists of those pages would randomly reorder every time you regenerate the list, causing spurious changes to the output. Now they'll always get ordered in the same way.
2014-03-13Add sort pages by Title and by LinkTitleRuben
Sorting can now be done on Title and on LinkTitle
2014-01-29gofmt all go codeTibor Vass
2014-01-27Big refactor of pages code. Changed TOC code to only parse when actually usedspf13