Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

site: add gohugo configuration and CI #1984

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'site'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My VScode is interpreting a file name site.yml to be an Ansible playbook and its trying to parse it as such.
There is surely a way for me to fix this, but I was wondering if it wouldn't be better for other contributors to rename this file so this "problem" doesn't happen?


on:
push:
pull_request:

jobs:
doc:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about giving it a more descriptive name? Maybe build website:?

runs-on: ubuntu-latest
steps:

- uses: actions/checkout@v3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@v4


- name: Get Hugo and Theme
run: |
curl -fsSL https://github.com/gohugoio/hugo/releases/download/v0.114.0/hugo_extended_0.114.0_Linux-64bit.tar.gz | sudo tar xzf - -C /usr/local/bin hugo
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using a github action?
This seems to be the most popular: https://github.com/marketplace/actions/hugo-setup
This example should suit our needs I think: https://github.com/peaceiris/actions-hugo?tab=readme-ov-file#%EF%B8%8F-workflow-for-autoprefixer-and-postcss-cli

sudo chmod +x /usr/local/bin/hugo
mkdir -p site/themes
cd site/themes
git clone https://github.com/bep/docuapi
cd docuapi
npm install --only=dev
mv node_modules ../..
- name: Build site
run: |
cd site
hugo version
hugo
- uses: actions/upload-artifact@v3
with:
name: site
path: site/public

- name: Publish site to gh-pages
if: github.event_name != 'pull_request'
run: |
cd site/public/
touch .nojekyll
git init
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to discuss this approach with you, but I'll wait to see what you think about the GH Action, which may change this approach.

cp ../../.git/config ./.git/config
git add .
git config --local user.email "push@gha"
git config --local user.name "GHA"
git commit -a -m "update ${{ github.sha }}"
git push -u origin +HEAD:gh-pages
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![cobra logo](assets/CobraMain.png)
![cobra logo](site/static/images/logo.png)

Cobra is a library for creating powerful modern CLI applications.

Expand Down
Binary file removed assets/CobraMain.png
Binary file not shown.
1 change: 1 addition & 0 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/public
42 changes: 42 additions & 0 deletions site/assets/scss/slate/docuapi_overrides.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2013-2023 The Cobra Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// BACKGROUND COLORS

$nav-bg:#254E70 !default;
$examples-bg: #002642 !default;

// FONTS

@import url("https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700&display=swap");

$font-default-family: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

// FLEX SIDEBAR

.toc-wrapper {
display: flex;
flex-direction: column;
}

#toc {
flex-grow: 1;
}

.toc-wrapper .toc-footer {
margin-top: .5em;
li {
text-align: center;
}
}
45 changes: 45 additions & 0 deletions site/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
theme = "docuapi"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

config.toml is the old naming scheme (https://gohugo.io/getting-started/configuration/).
Let's rename to hugo.toml.
Actually, would you ming using yaml instead? Since that is what we use for our other configurations?
Here is the converted content using an online converter (including the suggested changes in my comments):
hugo.yml:

# Seems not work with modules: theme: docuapi
languageCode: en-us
baseurl: 'https://spf13.github.io/cobra/'
title: Cobra

disableKinds: [taxonomy]

# Code higlighting settings
pygmentsCodefences: true
pygmentsCodeFencesGuessSyntax: false
pygmentsOptions: ''
pygmentsStyle: monokai
pygmentsUseClasses: false

defaultContentLanguage: en

module:
  hugoVersion: {}
  imports:
    - path: github.com/bep/docuapi/v2

params:
  search: true

markup:
  goldmark:
    parser:
      autoHeadingIDType: github-ascii
    renderer:
      unsafe: true

languages:
  en:
    languageName: English
    weight: 2
    title: Cobra documentation
    params:
      toc_footers:
        - >-
          [![github.com/spf13/cobra](https://img.shields.io/badge/-spf13/cobra-323131.svg?logo=github&style=flat-square&longCache=true)](https://github.com/spf13/cobra)
        - >-
          Built with [Hugo](https://gohugo.io/) theme
          [DocuAPI](https://github.com/bep/docuapi) by
          [bep](https://github.com/bep)
      blackfriday:
        angledQuotes: false
        hrefTargetBlank: true

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been playing around with this and having the theme line is not working for me unless I git clone the docuapi repo. But I find it simpler to add docuapi as a module dependency, but then the theme line give me an error. If I remove the theme line is seems to work.

languageCode = "en-us"
baseurl = "https://spf13.github.io/cobra/"
title = "Cobra"

disableKinds = ["taxonomyTerm"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting this warning: WARN DEPRECATED: Kind "taxonomyterm" used in disableKinds is deprecated, use "taxonomy" instead.


# Code higlighting settings
pygmentsCodefences = true
pygmentsCodeFencesGuesSsyntax = false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pygmentsCodeFencesGuesSsyntax -> pygmentsCodeFencesGuessSyntax

pygmentsOptions = ""
pygmentsStyle = "monokai"
pygmentsUseClasses = false

defaultContentLanguage = "en"

[module]
[module.hugoVersion]
[[module.imports]]
# We need one module import for Hugo to detect us as a Hugo Module.
path="github.com/bep/empty-hugo-module"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about importing the theme we use (and removing the comment)? github.com/bep/docuapi/v2
Then I don't seem to need to git clone the docuapi repo.


[params]
search = true

[markup]
[markup.goldmark]
[markup.goldmark.parser]
autoHeadingIDType = "github-ascii"
[markup.goldmark.renderer]
unsafe= true

[languages]
[languages.en]
languageName = "English"
weight = 2
title = "Cobra documentation"
[languages.en.params]
toc_footers = [
"[![github.com/spf13/cobra](https://img.shields.io/badge/-spf13/cobra-323131.svg?logo=github&style=flat-square&longCache=true)](https://github.com/spf13/cobra)",
"Built with [Hugo](https://gohugo.io/) theme [DocuAPI](https://github.com/bep/docuapi) by [bep](https://github.com/bep)"
]
[languages.en.params.blackfriday]
angledQuotes = false
hrefTargetBlank = true
2 changes: 1 addition & 1 deletion site/content/projects_using_cobra.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Projects using Cobra
# Projects using Cobra

- [Allero](https://github.com/allero-io/allero)
- [Arewefastyet](https://benchmark.vitess.io)
Expand Down
10 changes: 10 additions & 0 deletions site/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/bep/docuapi
Copy link
Collaborator

@marckhouzam marckhouzam Dec 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's name it github.com/spf13/cobra/site

If you could remove this file and do a hugo mod init github.com/spf13/cobra/site && hugo mod tidy we'd get something more up-to-date


go 1.12

require (
github.com/bep/empty-hugo-module v1.0.0 // indirect
github.com/jquery/jquery-dist v0.0.0-20190501211928-15bc73803f76 // indirect
github.com/olivernn/lunr.js v2.3.8+incompatible // indirect
github.com/slatedocs/slate v2.3.1+incompatible // indirect
)
Binary file added site/static/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading