# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           golang 1.0

go.setup            github.com/gohugoio/hugo 0.147.7 v
go.offline_build    no
revision            0

checksums           rmd160  ea6a708755b3e676bd99ada8502d760f38145b99 \
                    sha256  f9d2e4c85b2d7b1d9ca11e5606973b56717285bbedbb4008afccfd6378d23f52 \
                    size    14603510

categories          www
installs_libs       no
license             Apache-2
maintainers         {acm.org:cardi @cardi} \
                    {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

description         A Fast and Flexible Static Site Generator built with love in GoLang
long_description    {*}${description}


build.pre_args-append \
                    -ldflags \"-X ${go.package}/common/hugo.vendorInfo=macports\"

# build hugo extended with Sass/SCSS support by default
build.args-append   -tags extended

depends_run-append  path:etc/bash_completion:bash-completion

variant deploy description "Enables support to deploy site directly to Google Cloud Storage, AWS S3, or Azure Storage" {
    build.args-append \
                    {-tags extended} {-tags extended,withdeploy}
}

destroot {
    xinstall -d ${destroot}${prefix}/bin
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/${name}
}

post-destroot {
    # generate man pages then install them
    system -W ${worksrcpath} "${worksrcpath}/${name} gen man"
    xinstall -d -m 0755 ${destroot}${prefix}/share/man/man1
    xinstall -m 0644 {*}[glob ${worksrcpath}/man/*.1] ${destroot}${prefix}/share/man/man1/

    # generate bash completion then install them
    system -W ${worksrcpath} "${worksrcpath}/${name} completion bash > hugo.sh"
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions/
    xinstall -m 0644 ${worksrcpath}/hugo.sh ${destroot}${prefix}/share/bash-completion/completions/${name}

    # generation fish completion then install them
    system -W ${worksrcpath} "${worksrcpath}/${name} completion fish > hugo.fish"
    xinstall -d ${destroot}${prefix}/share/fish/vendor_completions.d/
    xinstall -m 644 ${worksrcpath}/hugo.fish ${destroot}${prefix}/share/fish/vendor_completions.d/

    # generation zsh completion then install them
    system -W ${worksrcpath} "${worksrcpath}/${name} completion zsh > _hugo"
    xinstall -d ${destroot}${prefix}/share/zsh/site-functions/
    xinstall -m 644 ${worksrcpath}/_hugo ${destroot}${prefix}/share/zsh/site-functions/
}
