diff --git a/.github/workflows/pages.yaml b/.github/workflows/pages.yaml new file mode 100644 index 00000000..07840b41 --- /dev/null +++ b/.github/workflows/pages.yaml @@ -0,0 +1,58 @@ +name: Pages + +on: + push: + branches: + - main + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: false + +defaults: + run: + shell: bash + +jobs: + build: + runs-on: ubuntu-latest + env: + HUGO_VERSION: 0.163.3 + steps: + - name: Checkout + uses: actions/checkout@v6 + + - name: Configure Pages + uses: actions/configure-pages@v6 + + - name: Install Hugo + run: | + mkdir -p "${HOME}/.local/hugo" + curl -sfL --output-dir "${{ runner.temp }}" -O "https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz" + tar -C "${HOME}/.local/hugo" -xf "${{ runner.temp }}/hugo_${HUGO_VERSION}_linux-amd64.tar.gz" + echo "${HOME}/.local/hugo" >> "${GITHUB_PATH}" + + - name: Build + run: hugo --cleanDestinationDir --minify --cacheDir "${{ runner.temp }}/hugo_cache" + + - name: Upload Pages artifact + uses: actions/upload-pages-artifact@v5 + with: + path: ./public + + deploy: + runs-on: ubuntu-latest + needs: build + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v5 diff --git a/.gitignore b/.gitignore index 25688d33..da7b5ea5 100644 --- a/.gitignore +++ b/.gitignore @@ -64,6 +64,8 @@ acceptance/vendor # Go build and release artifacts /dist/ +/public/ +/.hugo_build.lock # Go binary build artifact in cmd cmd/facts/facts diff --git a/docs/SITE.md b/docs/SITE.md new file mode 100644 index 00000000..ef285d4a --- /dev/null +++ b/docs/SITE.md @@ -0,0 +1,12 @@ +# Documentation Site + +Facts publishes a Hugo documentation site at `https://facts.martinez.io/`. + +Build it from the repository root: + +```sh +hugo --cleanDestinationDir --minify +``` + +The site uses `docs/` as Hugo content, writes generated HTML to `public/`, and +publishes that directory through GitHub Pages. Do not commit `public/`. diff --git a/docs/adr/0013-facts-docs-dedicated-subdomain.md b/docs/adr/0013-facts-docs-dedicated-subdomain.md new file mode 100644 index 00000000..dd8ef001 --- /dev/null +++ b/docs/adr/0013-facts-docs-dedicated-subdomain.md @@ -0,0 +1,9 @@ +# Facts docs use a dedicated custom subdomain + +Facts will publish its documentation site at `https://facts.martinez.io/` from this repository, rather than under the existing `martinez.io` personal site or the default `ncode.github.io/facts` repository Pages URL. The site should stay independently deployable from the Facts repo, with GitHub Pages serving the generated site and a `CNAME` for `facts.martinez.io`. + +## Considered Options + +- **Use `facts.martinez.io`** - chosen: it gives Facts a stable public URL while keeping the project docs independent from the existing personal site. +- **Use `martinez.io/facts`** - rejected: it would couple Facts documentation deployment and routing to the personal website. +- **Use `ncode.github.io/facts`** - rejected: it works as a fallback, but the custom domain is cleaner for public documentation. diff --git a/hugo.toml b/hugo.toml new file mode 100644 index 00000000..7392e3a0 --- /dev/null +++ b/hugo.toml @@ -0,0 +1,14 @@ +baseURL = "https://facts.martinez.io/" +title = "Facts" +contentDir = "docs" +publishDir = "public" +disableKinds = ["rss", "taxonomy", "term"] + +[markup] + [markup.goldmark] + [markup.goldmark.renderer] + unsafe = false + +[caches] + [caches.images] + dir = ":cacheDir/images" diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html new file mode 100644 index 00000000..28134071 --- /dev/null +++ b/layouts/_default/_markup/render-link.html @@ -0,0 +1,29 @@ +{{- $href := .Destination -}} +{{- if not (or (hasPrefix $href "http://") (hasPrefix $href "https://") (hasPrefix $href "#") (hasPrefix $href "mailto:")) -}} + {{- $clean := replaceRE `^(\./|\.\./)+` "" $href -}} + {{- if eq $clean "adr/" -}} + {{- $href = "/adr/" -}} + {{- else if or (eq $clean "schema/facts.yaml") (eq $clean "docs/schema/facts.yaml") -}} + {{- $href = "https://github.com/ncode/facts/blob/main/docs/schema/facts.yaml" -}} + {{- else if or (eq $clean "supported-facts/") (eq $clean "docs/supported-facts/") -}} + {{- $href = "/supported-facts/" -}} + {{- else if hasSuffix $clean ".md" -}} + {{- $stem := replaceRE `\.md$` "" (path.Base $clean) | lower -}} + {{- if hasPrefix $clean "adr/" -}} + {{- $href = printf "/adr/%s/" $stem -}} + {{- else if eq $stem "history" -}} + {{- $href = "/history/" -}} + {{- else if eq $stem "custom_fact_migration" -}} + {{- $href = "/custom_fact_migration/" -}} + {{- else if eq $stem "facter_conf_compatibility" -}} + {{- $href = "/facter_conf_compatibility/" -}} + {{- else if and (or (eq .Page.Section "supported-facts") (hasPrefix $clean "supported-facts/") (hasPrefix $clean "docs/supported-facts/")) (ne $stem "readme") -}} + {{- $href = printf "/supported-facts/%s/" $stem -}} + {{- else -}} + {{- $href = printf "https://github.com/ncode/facts/blob/main/%s" $clean -}} + {{- end -}} + {{- else if hasPrefix $clean "docs/" -}} + {{- $href = printf "https://github.com/ncode/facts/blob/main/%s" $clean -}} + {{- end -}} +{{- end -}} +{{ .Text | safeHTML }} diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html new file mode 100644 index 00000000..c30028a6 --- /dev/null +++ b/layouts/_default/baseof.html @@ -0,0 +1,31 @@ + + +
+ + +Facts discovers hardware, networking, OS, cloud metadata, and operator-supplied facts as one canonical tree: embeddable as a Go library, scriptable as the facts CLI.
$ go get github.com/ncode/facts
+$ brew install ncode/tap/facts
+$ facts --json os.family kernel.version.full
+ An engine is an isolated, immutable unit of discovery configuration. It reads core facts only until you opt into config files, external facts, registered facts, or system defaults.
+Construct explicit discovery inputs with no package-global collector and no shared mutable state.
+Discover once, then query and decode an immutable canonical tree as often as needed.
+Decode subtrees into caller-owned Go types and fail loudly when the shape does not match.
+The facts binary keeps the Ruby Facter process-boundary contract for output formatting, exit status, stderr diagnostics, external facts, environment facts, and config semantics.
$ facts os.name
+Darwin
+
+$ facts --external-dir ./facts.d site_role
+web
+ The schema-backed supported fact pages are generated from docs/schema/facts.yaml and rendered here without becoming a second source of truth.