-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Add sitemap.xml to interactors site.
We're going to use sitemaps as a standards based mechanism to compose our static websites. This adds a sitemap for the interactors website so that it can be "mounted" on frontside.com by enabling the docusaurus "sitemap" plugin. Docusaurus does a bunch of dynamic chicanery with React, Webpack and code-splitting to render a static webpage because reasons, so we add a synthetic entry to the sitemap that serves as an index for all dynamic JavaScript resources. That way, the static site generator knows to download all those resources ahead of time even though they are not referenced in any page.
- Loading branch information
Showing
6 changed files
with
125 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/[email protected]/http/file_server.ts | ||
root: website/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ build | |
docs/**/api | ||
sidebars | ||
public | ||
/node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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",` | ||
<html> | ||
<head> | ||
${assets.map((asset) => ` <link rel="asset" href="${asset}"/>`).join("\n")} | ||
</head> | ||
<body> | ||
<h1> JavaScript Index</h1> | ||
<ul> | ||
${assets.map((asset) => ` <li><a href="${asset}">${asset}</a></li>`).join("\n")} | ||
</ul> | ||
<body> | ||
<html> | ||
`); | ||
|
||
const images = readdirSync("./build/interactors/images"); | ||
|
||
writeFileSync("./build/interactors/images/index.html",` | ||
<html> | ||
<head> | ||
${images.map((image) => ` <link rel="asset" href="${image}"/>`).join("\n")} | ||
</head> | ||
<body> | ||
<h1> JavaScript Index</h1> | ||
<ul> | ||
${images.map((image) => ` <li><a href="${image}">${image}</a></li>`).join("\n")} | ||
</ul> | ||
<body> | ||
<html> | ||
`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2578,7 +2578,7 @@ | |
"@docusaurus/theme-classic" "2.0.0-beta.9" | ||
"@docusaurus/theme-search-algolia" "2.0.0-beta.9" | ||
|
||
"@docusaurus/[email protected]", "react-loadable@npm:@docusaurus/[email protected]": | ||
"@docusaurus/[email protected]": | ||
version "5.5.2" | ||
resolved "https://registry.yarnpkg.com/@docusaurus/react-loadable/-/react-loadable-5.5.2.tgz#81aae0db81ecafbdaee3651f12804580868fa6ce" | ||
integrity sha512-A3dYjdBGuy0IGT+wyLIGIKLRE+sAk1iNk0f1HjNDysO7u8lhL4N3VEm+FAubmJbAztn94F7MxBTPmnixbiyFdQ== | ||
|
@@ -7825,6 +7825,14 @@ react-loadable-ssr-addon-v5-slorber@^1.0.1: | |
dependencies: | ||
"@babel/runtime" "^7.10.3" | ||
|
||
"react-loadable@npm:@docusaurus/[email protected]": | ||
version "5.5.2" | ||
resolved "https://registry.yarnpkg.com/@docusaurus/react-loadable/-/react-loadable-5.5.2.tgz#81aae0db81ecafbdaee3651f12804580868fa6ce" | ||
integrity sha512-A3dYjdBGuy0IGT+wyLIGIKLRE+sAk1iNk0f1HjNDysO7u8lhL4N3VEm+FAubmJbAztn94F7MxBTPmnixbiyFdQ== | ||
dependencies: | ||
"@types/react" "*" | ||
prop-types "^15.6.2" | ||
|
||
react-router-config@^5.1.1: | ||
version "5.1.1" | ||
resolved "https://registry.yarnpkg.com/react-router-config/-/react-router-config-5.1.1.tgz#0f4263d1a80c6b2dc7b9c1902c9526478194a988" | ||
|
@@ -8255,6 +8263,11 @@ safe-buffer@>=5.1.0, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@~5.2.0: | |
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" | ||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== | ||
|
||
sax@>=0.6.0: | ||
version "1.4.1" | ||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f" | ||
integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg== | ||
|
||
sax@^1.2.4, sax@~1.2.4: | ||
version "1.2.4" | ||
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" | ||
|
@@ -9545,6 +9558,19 @@ xml-js@^1.6.11: | |
dependencies: | ||
sax "^1.2.4" | ||
|
||
xml2js@^0.6.2: | ||
version "0.6.2" | ||
resolved "https://registry.yarnpkg.com/xml2js/-/xml2js-0.6.2.tgz#dd0b630083aa09c161e25a4d0901e2b2a929b499" | ||
integrity sha512-T4rieHaC1EXcES0Kxxj4JWgaUQHDk+qwHcYOCFHfiwKz7tOVPLq7Hjq9dM1WCMhylqMEfP7hMcOIChvotiZegA== | ||
dependencies: | ||
sax ">=0.6.0" | ||
xmlbuilder "~11.0.0" | ||
|
||
xmlbuilder@~11.0.0: | ||
version "11.0.1" | ||
resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3" | ||
integrity sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA== | ||
|
||
xtend@^4.0.0, xtend@^4.0.1: | ||
version "4.0.2" | ||
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" | ||
|