diff --git a/.github/workflows/website.yaml b/.github/workflows/website.yaml new file mode 100644 index 00000000..b936fa10 --- /dev/null +++ b/.github/workflows/website.yaml @@ -0,0 +1,29 @@ +name: Website + +on: + push: + branches: + - main + - www # remove this branch once this is merged to main + paths: + - website/** + +jobs: + website: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - uses: actions/checkout@v4 + - uses: volta-cli/action@v4 + + - run: yarn install && yarn build + working-directory: website + + - uses: denoland/deployctl@v1 + with: + project: interactors + entrypoint: https://deno.land/std@0.224.0/http/file_server.ts + root: website/build diff --git a/website/.gitignore b/website/.gitignore index 550a50e6..80c13723 100644 --- a/website/.gitignore +++ b/website/.gitignore @@ -11,3 +11,4 @@ build docs/**/api sidebars public +/node_modules diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index d7375bdf..d42d6429 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -1,7 +1,7 @@ module.exports = { title: "Interactors", tagline: "Page Objects for components libraries", - url: "https://frontside.com/", + url: "https://interactors.deno.dev", baseUrl: "/interactors/", onBrokenLinks: "throw", favicon: "images/favicon-interactors.png", @@ -119,6 +119,7 @@ module.exports = { theme: { customCss: require.resolve("./src/css/custom.css"), }, + sitemap: {} }, ], ], diff --git a/website/package.json b/website/package.json index f8cf789d..c3b75a4a 100644 --- a/website/package.json +++ b/website/package.json @@ -4,10 +4,8 @@ "private": true, "scripts": { "start": "docusaurus start", - "build": "docusaurus build --out-dir public/interactors", - "swizzle": "docusaurus swizzle", - "deploy": "docusaurus deploy", - "serve": "docusaurus serve --dir public/interactors" + "build": "docusaurus build --out-dir build/interactors && node sitemap.mjs", + "serve": "docusaurus serve" }, "dependencies": { "@docusaurus/core": "2.0.0-beta.9", @@ -21,7 +19,8 @@ "email-validator": "^2.0.4", "jsonp": "^0.2.1", "react": "^16.8.4", - "react-dom": "^16.8.4" + "react-dom": "^16.8.4", + "xml2js": "^0.6.2" }, "browserslist": { "production": [ @@ -34,5 +33,9 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "volta": { + "node": "16.20.2", + "yarn": "1.22.22" } } diff --git a/website/sitemap.mjs b/website/sitemap.mjs new file mode 100644 index 00000000..028e8ccb --- /dev/null +++ b/website/sitemap.mjs @@ -0,0 +1,58 @@ +/* Add indexes of all dynamically loaded assets so that they can be staticalized */ + +import { readFileSync, writeFileSync, readdirSync } from "node:fs"; +import { Parser, Builder } from "xml2js"; + +const [parser, builder] = [new Parser(), new Builder()]; + +const sitemapXML = readFileSync("./build/interactors/sitemap.xml"); + +const sitemap = await parser.parseStringPromise(sitemapXML); + +// ideally we would use the docusaurs sitemap plugin to do this +// but support for plugins came with => 3.0.0 and upgrade no thank you. +sitemap.urlset.url.push({ + loc: 'https://interactors.deno.dev/interactors/assets/js/index.html', +}, { + loc: 'https://interactors.deno.dev/interactors/images/index.html' +}); + +writeFileSync("./build/interactors/sitemap.xml", builder.buildObject(sitemap)); + +const assets = readdirSync("./build/interactors/assets/js"); + +writeFileSync("./build/interactors/assets/js/index.html",` + +
+${assets.map((asset) => ` `).join("\n")} + + +