From 48fe0b0eca04132c5f2964d905acb781e0038259 Mon Sep 17 00:00:00 2001 From: Justin Garrison Date: Fri, 19 Sep 2025 16:58:23 -0700 Subject: [PATCH] chore: update docs-gen to support google analytics Add analytics to common.yaml. It will be added when new docs are generated Signed-off-by: Justin Garrison --- .github/workflows/build-docs-gen.yaml | 13 ++--- .github/workflows/build-docs-mint.yaml | 14 ++--- common.yaml | 4 ++ docs-gen/main.go | 81 +++++++++++++++----------- 4 files changed, 59 insertions(+), 53 deletions(-) diff --git a/.github/workflows/build-docs-gen.yaml b/.github/workflows/build-docs-gen.yaml index 85debcd..9c256cd 100644 --- a/.github/workflows/build-docs-gen.yaml +++ b/.github/workflows/build-docs-gen.yaml @@ -5,12 +5,8 @@ on: branches: - main paths: - - 'docs-gen/**' - - '.github/workflows/build-docs-gen.yaml' - pull_request: - paths: - - 'docs-gen/**' - - '.github/workflows/build-docs-gen.yaml' + - "docs-gen/**" + - ".github/workflows/build-docs-gen.yaml" env: REGISTRY: ghcr.io @@ -41,9 +37,8 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch - type=ref,event=pr - type=sha,prefix={{branch}}- type=raw,value=latest,enable={{is_default_branch}} + type=sha - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -57,4 +52,4 @@ jobs: labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max diff --git a/.github/workflows/build-docs-mint.yaml b/.github/workflows/build-docs-mint.yaml index 7ab3527..bb884ff 100644 --- a/.github/workflows/build-docs-mint.yaml +++ b/.github/workflows/build-docs-mint.yaml @@ -5,12 +5,8 @@ on: branches: - main paths: - - 'mintlify/**' - - '.github/workflows/build-docs-mint.yaml' - pull_request: - paths: - - 'mintlify/**' - - '.github/workflows/build-docs-mint.yaml' + - "mintlify/**" + - ".github/workflows/build-docs-mint.yaml" env: REGISTRY: ghcr.io @@ -41,9 +37,8 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch - type=ref,event=pr - type=sha,prefix={{branch}}- type=raw,value=latest,enable={{is_default_branch}} + type=sha - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -57,4 +52,5 @@ jobs: labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64 cache-from: type=gha - cache-to: type=gha,mode=max \ No newline at end of file + cache-to: type=gha,mode=max + diff --git a/common.yaml b/common.yaml index 2c976ef..5dcfa88 100644 --- a/common.yaml +++ b/common.yaml @@ -42,3 +42,7 @@ footer: - anchor: "Community" href: "https://slack.dev.talos-systems.io/" icon: "slack" + +integrations: + ga4: + measurementId: "G-PT2W5NT93B" diff --git a/docs-gen/main.go b/docs-gen/main.go index 3cbd311..24606f3 100644 --- a/docs-gen/main.go +++ b/docs-gen/main.go @@ -16,18 +16,19 @@ import ( // Config represents the YAML configuration file structure type Config struct { - Schema string `yaml:"schema"` - Theme string `yaml:"theme"` - Name string `yaml:"name"` - Colors Colors `yaml:"colors"` - Favicon string `yaml:"favicon"` - Banner *Banner `yaml:"banner,omitempty"` - Contextual *Contextual `yaml:"contextual,omitempty"` - Logo *Logo `yaml:"logo,omitempty"` - Navbar *Navbar `yaml:"navbar,omitempty"` - Footer *Footer `yaml:"footer,omitempty"` - Redirects []Redirect `yaml:"redirects,omitempty"` - Navigation NavigationConfig `yaml:"navigation"` + Schema string `yaml:"schema"` + Theme string `yaml:"theme"` + Name string `yaml:"name"` + Colors Colors `yaml:"colors"` + Favicon string `yaml:"favicon"` + Banner *Banner `yaml:"banner,omitempty"` + Contextual *Contextual `yaml:"contextual,omitempty"` + Logo *Logo `yaml:"logo,omitempty"` + Navbar *Navbar `yaml:"navbar,omitempty"` + Footer *Footer `yaml:"footer,omitempty"` + Integrations *Integrations `yaml:"integrations,omitempty"` + Redirects []Redirect `yaml:"redirects,omitempty"` + Navigation NavigationConfig `yaml:"navigation"` } type Colors struct { @@ -63,6 +64,14 @@ type Footer struct { Socials map[string]string `yaml:"socials" json:"socials"` } +type Integrations struct { + GA4 *GA4Integration `yaml:"ga4,omitempty" json:"ga4,omitempty"` +} + +type GA4Integration struct { + MeasurementId string `yaml:"measurementId" json:"measurementId"` +} + type NavigationConfig struct { Tabs []TabConfig `yaml:"tabs"` Global *GlobalNav `yaml:"global,omitempty"` @@ -124,18 +133,19 @@ type Redirect struct { // MintlifyConfig represents the output docs.json structure type MintlifyConfig struct { - Schema string `json:"$schema"` - Theme string `json:"theme"` - Name string `json:"name"` - Colors Colors `json:"colors"` - Favicon string `json:"favicon"` - Banner *Banner `json:"banner,omitempty"` - Contextual *Contextual `json:"contextual,omitempty"` - Logo *Logo `json:"logo,omitempty"` - Navbar *Navbar `json:"navbar,omitempty"` - Footer *Footer `json:"footer,omitempty"` - Redirects []Redirect `json:"redirects,omitempty"` - Navigation MintlifyNavigation `json:"navigation"` + Schema string `json:"$schema"` + Theme string `json:"theme"` + Name string `json:"name"` + Colors Colors `json:"colors"` + Favicon string `json:"favicon"` + Banner *Banner `json:"banner,omitempty"` + Contextual *Contextual `json:"contextual,omitempty"` + Logo *Logo `json:"logo,omitempty"` + Navbar *Navbar `json:"navbar,omitempty"` + Footer *Footer `json:"footer,omitempty"` + Integrations *Integrations `json:"integrations,omitempty"` + Redirects []Redirect `json:"redirects,omitempty"` + Navigation MintlifyNavigation `json:"navigation"` } type MintlifyNavigation struct { @@ -187,17 +197,18 @@ func main() { // Generate Mintlify config mintlifyConfig := MintlifyConfig{ - Schema: mergedConfig.Schema, - Theme: mergedConfig.Theme, - Name: mergedConfig.Name, - Colors: mergedConfig.Colors, - Favicon: mergedConfig.Favicon, - Banner: mergedConfig.Banner, - Contextual: mergedConfig.Contextual, - Logo: mergedConfig.Logo, - Navbar: mergedConfig.Navbar, - Footer: mergedConfig.Footer, - Redirects: mergedConfig.Redirects, + Schema: mergedConfig.Schema, + Theme: mergedConfig.Theme, + Name: mergedConfig.Name, + Colors: mergedConfig.Colors, + Favicon: mergedConfig.Favicon, + Banner: mergedConfig.Banner, + Contextual: mergedConfig.Contextual, + Logo: mergedConfig.Logo, + Navbar: mergedConfig.Navbar, + Footer: mergedConfig.Footer, + Integrations: mergedConfig.Integrations, + Redirects: mergedConfig.Redirects, Navigation: MintlifyNavigation{ Global: mergedConfig.Navigation.Global, },