diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6f922786..9cabed9e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -168,51 +168,36 @@ jobs: url: ${{ steps.deployment.outputs.page_url }} steps: - uses: actions/checkout@v4 - - uses: denoland/setup-deno@v1 + - uses: oven-sh/setup-bun@v1 with: - deno-version: v1.x - - if: github.event_name == 'push' && github.ref_type == 'tag' - run: | - jq \ - --arg url "$UNSTABLE_DOCS_URL" \ - '.nav_links = [{"title":"Go to unstable","url":$url}] + .nav_links' \ - _data.json > _data.json.tmp - mv _data.json.tmp _data.json - env: - UNSTABLE_DOCS_URL: ${{ vars.UNSTABLE_DOCS_URL }} - working-directory: ${{ github.workspace }}/docs/ - - if: github.event_name != 'push' || github.ref_type != 'tag' - run: | - jq \ - --arg url "$STABLE_DOCS_URL" \ - '.nav_links = [{"title":"Go to stable","url":$url}] + .nav_links' \ - _data.json > _data.json.tmp - mv _data.json.tmp _data.json - env: - STABLE_DOCS_URL: ${{ vars.STABLE_DOCS_URL }} - working-directory: ${{ github.workspace }}/docs/ + bun-version: latest - run: | set -ex - jq \ - --arg domain "$PLAUSIBLE_DOMAIN" \ - '.plausible_domain = $domain' \ - _data.json > _data.json.tmp - mv _data.json.tmp _data.json + bun install + if [[ "$GITHUB_EVENT_NAME" = "push" && "$GITHUB_REF_TYPE" = "tag" ]]; then + EXTRA_NAV_TEXT=Unstable \ + EXTRA_NAV_LINK="$UNSTABLE_DOCS_URL" \ + bun run build + else + EXTRA_NAV_TEXT=Stable \ + EXTRA_NAV_LINK="$STABLE_DOCS_URL" \ + bun run build + fi env: PLAUSIBLE_DOMAIN: ${{ secrets.PLAUSIBLE_DOMAIN }} - working-directory: ${{ github.workspace }}/docs/ - - run: deno task lume + STABLE_DOCS_URL: ${{ vars.STABLE_DOCS_URL }} + UNSTABLE_DOCS_URL: ${{ vars.UNSTABLE_DOCS_URL }} working-directory: ${{ github.workspace }}/docs/ - uses: actions/upload-pages-artifact@v3 with: - path: docs/_site + path: docs/.vitepress/dist - id: deployment if: github.event_name == 'push' && github.ref_type == 'tag' uses: actions/deploy-pages@v4 - if: github.event_name == 'pull_request' || github.ref_type == 'branch' uses: nwtgck/actions-netlify@v3.0 with: - publish-dir: docs/_site + publish-dir: docs/.vitepress/dist production-branch: main github-token: ${{ github.token }} enable-pull-request-comment: false diff --git a/.vscode/settings.json b/.vscode/settings.json index 33b11397..eca2156c 100755 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -36,6 +36,7 @@ "callouts", "cfworker", "codegen", + "deflist", "Deno", "denokv", "dereferenceable", @@ -69,6 +70,7 @@ "unfollow", "unfollowing", "urlpattern", + "vitepress", "webfinger" ] } diff --git a/docs/.vitepress/config.mts b/docs/.vitepress/config.mts index fc3f54ed..70c80fd3 100644 --- a/docs/.vitepress/config.mts +++ b/docs/.vitepress/config.mts @@ -2,6 +2,7 @@ import { Presets, SingleBar } from "cli-progress"; import deflist from "markdown-it-deflist"; import footnote from "markdown-it-footnote"; import { jsrRef } from "markdown-it-jsr-ref"; +import process from "node:process"; import { defineConfig } from "vitepress"; const progress = new SingleBar({}, Presets.shades_classic); @@ -20,6 +21,30 @@ const jsrRefPlugin = await jsrRef({ }, }); +let extraNav: { text: string; link: string }[] = []; +if (process.env.EXTRA_NAV_TEXT && process.env.EXTRA_NAV_LINK) { + extraNav = [ + { + text: process.env.EXTRA_NAV_TEXT, + link: process.env.EXTRA_NAV_LINK, + }, + ]; +} + +let plausibleScript: [string, Record][] = []; +if (process.env.PLAUSIBLE_DOMAIN) { + plausibleScript = [ + [ + "script", + { + defer: "defer", + "data-domain": process.env.PLAUSIBLE_DOMAIN, + src: "https://plausible.io/js/plausible.js", + }, + ], + ]; +} + export default defineConfig({ title: "Fedify", description: "Fedify docs", @@ -29,6 +54,7 @@ export default defineConfig({ { text: "Home", link: "/" }, { text: "Manual", link: "/manual.md", activeMatch: "/manual" }, { text: "API reference", link: "https://jsr.io/@fedify/fedify" }, + ...extraNav ], sidebar: [ @@ -94,6 +120,7 @@ export default defineConfig({ href: "/assets/favicon-32x32.png", }, ], + ...plausibleScript ], cleanUrls: true, diff --git a/docs/bun.lockb b/docs/bun.lockb index 2d49b95d..155890fd 100755 Binary files a/docs/bun.lockb and b/docs/bun.lockb differ diff --git a/docs/package.json b/docs/package.json index 39677bff..666603ae 100644 --- a/docs/package.json +++ b/docs/package.json @@ -3,7 +3,7 @@ "cli-progress": "^3.12.0", "markdown-it-deflist": "^3.0.0", "markdown-it-footnote": "^4.0.0", - "markdown-it-jsr-ref": "0.1.0-dev.11", + "markdown-it-jsr-ref": "^0.1.0", "vitepress": "^1.0.2" }, "scripts": {