summaryrefslogtreecommitdiffstats
path: root/hugolib/site_sections.go
AgeCommit message (Collapse)Author
2022-02-24Add Markdown diagrams and render hooks for code blocksBjørn Erik Pedersen
You can now create custom hook templates for code blocks, either one for all (`render-codeblock.html`) or for a given code language (e.g. `render-codeblock-go.html`). We also used this new hook to add support for diagrams in Hugo: * Goat (Go ASCII Tool) is built-in and enabled by default; just create a fenced code block with the language `goat` and start draw your Ascii diagrams. * Another popular alternative for diagrams in Markdown, Mermaid (supported by GitHub), can also be implemented with a simple template. See the Hugo documentation for more information. Updates #7765 Closes #9538 Fixes #9553 Fixes #8520 Fixes #6702 Fixes #9558
2019-08-08Simplify page tree logicBjørn Erik Pedersen
This is preparation for #6041. For historic reasons, the code for bulding the section tree and the taxonomies were very much separate. This works, but makes it hard to extend, maintain, and possibly not so fast as it could be. This simplification also introduces 3 slightly breaking changes, which I suspect most people will be pleased about. See referenced issues: This commit also switches the radix tree dependency to a mutable implementation: github.com/armon/go-radix. Fixes #6154 Fixes #6153 Fixes #6152
2019-04-13hugolib: Fix dates for sections with dates in front matterBjørn Erik Pedersen
Fixes #5854
2019-04-05hugolib: Fix default date assignment for sectionsBjørn Erik Pedersen
See #5784
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-11-28hugolib: Improve nil handling in IsDescendant and IsAncestorBjørn Erik Pedersen
Fixes #5461
2018-10-03hugolib: Allow nil to be unwrapped as *PageCameron Moore
Previously, calls to *Page.Eq(nil) would always return false because the unwrapPage func didn't support the nil case. Add support for unwrapping nil to a *Page. Fixes #5043
2018-09-21hugolib: Deprecate Pages.SortBjørn Erik Pedersen
In favour of ByWeight.
2018-08-14hugolib: Fix Related when called from shortcodeBjørn Erik Pedersen
Fixes #5071
2018-07-23Add Page.FirstSectionBjørn Erik Pedersen
It was added and then removed by accident some time ago. Let us add it again, as it is useful.
2018-07-09Revert "Consider root and current section's content type if set in front matter"Bjørn Erik Pedersen
This reverts commit c790029e1dbb0b66af18d05764bd6045deb2e180.
2018-07-06Add Hugo Piper with SCSS support and much moreBjørn Erik Pedersen
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-06-30Consider root and current section's content type if set in front matterBjørn Erik Pedersen
This should allow for less duplication of templates. Before this commit it was possible to override the content page of a given page/section, but only one page at a time. Full "template sets" can now be inherited by setting `type: blog` etc. in the section content page's front matter, and that type will be considered when looking for layouts for all pages in that section. For nested sections, it will use consider both `type` set in the current section first, then `type` set in the first section below home, e.g. `/docs`. This commit also adds a new Page method: `FirstSection`. This navigates up to the first section below home (e.g. `/docs`). For the home page it will return itself. Fixes #4891
2018-02-25hugolib: Avoid scanning entire site to find the homeBjørn Erik Pedersen
See #4447
2018-02-25Fix bug in Site.assembleSections methodVas Sudanagunta
Site.assembleSections logic assumes that the the home page would always be the first in the Site's list of pages. This is not in fact guaranteed to be true. When it is not, the method can fail to set the parent for some or all root-level pages. 
 Fixes #4447
2017-08-17hugolib: Simplify Page.EqBjørn Erik Pedersen
2017-08-17hugolib: Do not return error in Eq on type mismatchBjørn Erik Pedersen
2017-08-16hugolib: Rename Page.Equals to Page.EqBjørn Erik Pedersen
To get the name in line with the template func `eq`.
2017-08-16hugolib: Add Page.EqualsBjørn Erik Pedersen
2017-07-04hugolib: Extend the sections APIBjørn Erik Pedersen
This commit adds some section related methods that have been asked for: * .CurrentSection * .IsDescendant * .IsAncestor Fixes #3591
2017-07-04hugolib: Make .Site.Sections return the top level sectionsBjørn Erik Pedersen
See #3591
2017-06-13Run gofmt to get imports in line vs gohugoio/hugoBjørn Erik Pedersen
2017-06-13all: Update import paths to gohugoio/hugoBjørn Erik Pedersen
2017-06-13hugolib: Fix section logic for root folders with subfoldersBjørn Erik Pedersen
This commit fixes an issue introduced in the recently released Hugo 0.22. This logic did not handle the case with root sections with non-section subfolders very well. Fixes #3586
2017-06-08hugolib: Enable nested sectionsBjørn Erik Pedersen
Fixes #465