環境變數
主題在建置時從 config.ts 和自訂元件讀取環境變數。內容儲存庫在其 GitHub Actions 工作流程中設定這些變數,以便在不修改設定的情況下自訂各個網站。
| 變數 | 預設值 | 用途 |
|---|---|---|
DOCS_TITLE | Documentation | 顯示在頁首和瀏覽器分頁的網站標題 |
DOCS_SITE | https://f5-sales-demo.github.io | 已部署網站的標準基礎 URL |
DOCS_BASE | / | URL 基礎路徑(例如,專案網站使用 /my-repo/) |
DOCS_DESCRIPTION | (空字串) | 用於中繼資料和 llms.txt 插件的網站描述 |
DOCS_HOME | https://f5-sales-demo.github.io/docs/ | 從網站標題連結的首頁 URL |
GITHUB_REPOSITORY | (空字串) | 用於建立 GitHub 社群連結和編輯連結 |
LLMS_OPTIONAL_LINKS | [] | 用於 llms.txt 插件的額外連結 JSON 陣列 |
各變數的使用位置
Section titled “各變數的使用位置”DOCS_TITLE
Section titled “DOCS_TITLE”const title = options.title || process.env.DOCS_TITLE || 'Documentation';傳遞給 Starlight 的 title 選項和 starlight-llms-txt 插件。顯示在網站頁首和 HTML <title> 標籤中。
DOCS_SITE
Section titled “DOCS_SITE”const site = options.site || process.env.DOCS_SITE || 'https://f5-sales-demo.github.io';設定 Astro 的頂層 site 屬性。用於標準 URL、網站地圖生成和 Open Graph 中繼資料。
DOCS_BASE
Section titled “DOCS_BASE”const base = options.base || process.env.DOCS_BASE || '/';設定 Astro 的頂層 base 屬性。部署至子目錄時為必要設定(例如,https://example.com/my-repo/)。
DOCS_DESCRIPTION
Section titled “DOCS_DESCRIPTION”const description = options.description || process.env.DOCS_DESCRIPTION || '';作為網站描述傳遞給 starlight-llms-txt 插件。用於生成的 llms.txt 檔案中。
DOCS_HOME
Section titled “DOCS_HOME”const docsHome = process.env.DOCS_HOME || 'https://f5-sales-demo.github.io/docs/';由自訂 SiteTitle.astro 元件讀取。將頁首中的網站標題包裝為指向此 URL 的連結,讓使用者能夠返回中央文件首頁。當多個內容儲存庫共用相同主題,且您希望在所有網站上保持一致的「首頁」連結時,此功能特別實用。
GITHUB_REPOSITORY
Section titled “GITHUB_REPOSITORY”const githubRepository = options.githubRepository || process.env.GITHUB_REPOSITORY || '';用於生成網站頁首中的 GitHub 社群圖示和編輯連結基礎 URL。GitHub Actions 會自動設定此變數(例如,owner/repo)。
LLMS_OPTIONAL_LINKS
Section titled “LLMS_OPTIONAL_LINKS”const llmsOptionalLinks = options.llmsOptionalLinks || (process.env.LLMS_OPTIONAL_LINKS ? JSON.parse(process.env.LLMS_OPTIONAL_LINKS) : []);傳遞給 starlight-llms-txt 插件的 { title, url } 物件 JSON 編碼陣列。這些項目會顯示為生成的 llms.txt 檔案中的額外連結。
範例值:
[{"title": "API Reference", "url": "https://api.example.com/docs"}]在 GitHub Actions 中設定變數
Section titled “在 GitHub Actions 中設定變數”內容儲存庫透過其工作流程傳遞這些變數:
jobs: docs: uses: f5-sales-demo/docs-control/.github/workflows/github-pages-deploy.yml@main with: docs_title: "My Project Docs" docs_site: "https://example.com" docs_base: "/my-project/" docs_home: "https://example.com/home/"GITHUB_REPOSITORY 變數由 GitHub Actions 執行器自動提供,無需手動設定。