# -*- 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.151.0 v
go.offline_build    no
revision            0

checksums           rmd160  900721efea7b710d9cd23857e0f1962e2b07d41d \
                    sha256  b41d6e3da741c8d5637e016a1fa98f36e47dbfa9e213ff2d73ced66fb5b770ea \
                    size    14640319

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/
}
