Commit 3f345fe

Anton Medvedev <anton@medv.io>
2023-09-05 16:22:48
Fix
1 parent bbe6044
.vitepress/theme/index.js
@@ -1,4 +1,10 @@
 import DefaultTheme from 'vitepress/theme'
+import MyLayout from './MyLayout.vue'
 import './custom.css'
 
-export default DefaultTheme
+export default {
+  ...DefaultTheme,
+  // override the Layout with a wrapper component that
+  // injects the slots
+  Layout: MyLayout
+}
.vitepress/theme/MyLayout.vue
@@ -0,0 +1,14 @@
+<script setup>
+import DefaultTheme from 'vitepress/theme'
+import MyOxygen from './MyOxygen.vue'
+
+const { Layout } = DefaultTheme
+</script>
+
+<template>
+  <Layout>
+    <template #aside-ads-after>
+      <MyOxygen/>
+    </template>
+  </Layout>
+</template>
.vitepress/theme/MyOxygen.vue
@@ -0,0 +1,42 @@
+<template>
+  <div class="Oxygen">
+    <a href="https://webpod.dev/?from=zx-site">
+      <!--<img src="https://webpod.dev/img/banner.png" alt="Webpod - deploy JavaScript apps">-->
+      <img src="https://webpod.dev/img/logo.svg" alt="Webpod - deploy JavaScript apps">
+      <p>Webpod – deploy JavaScript apps to own cloud or private server</p>
+    </a>
+  </div>
+</template>
+
+<style scoped>
+.Oxygen {
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  padding: 24px;
+  border-radius: 12px;
+  min-height: 256px;
+  text-align: center;
+  line-height: 18px;
+  font-size: 12px;
+  font-weight: 500;
+  background-color: var(--vp-carbon-ads-bg-color);
+}
+
+.Oxygen :deep(img) {
+  margin: 0 auto;
+}
+
+.Oxygen :deep(p) {
+  display: block;
+  margin: 0 auto;
+  color: var(--vp-carbon-ads-text-color);
+  transition: color 0.25s;
+}
+
+.Oxygen :deep(p:hover) {
+  color: var(--vp-carbon-ads-hover-text-color);
+}
+</style>
+<script setup>
+</script>
api.md
@@ -22,7 +22,7 @@ A wrapper around the [node-fetch](https://www.npmjs.com/package/node-fetch)
 package.
 
 ```js
-let resp = await fetch('https://medv.io')
+const resp = await fetch('https://medv.io')
 ```
 
 ## question()
@@ -30,7 +30,7 @@ let resp = await fetch('https://medv.io')
 A wrapper around the [readline](https://nodejs.org/api/readline.html) package.
 
 ```js
-let bear = await question('What kind of bear is best? ')
+const bear = await question('What kind of bear is best? ')
 ```
 
 ## sleep()
@@ -46,7 +46,7 @@ await sleep(1000)
 A `console.log()` alternative which can take [ProcessOutput](#processoutput).
 
 ```js
-let branch = await $`git branch --show-current`
+const branch = await $`git branch --show-current`
 
 echo`Current branch is ${branch}.`
 // or
@@ -58,7 +58,7 @@ echo('Current branch is', branch)
 Returns the stdin as a string.
 
 ```js
-let content = JSON.parse(await stdin())
+const content = JSON.parse(await stdin())
 ```
 
 ## within()
@@ -82,7 +82,7 @@ await $`pwd` // => /home/path
 ```js
 await $`node --version` // => v20.2.0
 
-let version = await within(async () => {
+const version = await within(async () => {
   $.prefix += 'export NVM_DIR=$HOME/.nvm; source $NVM_DIR/nvm.sh; nvm use 16;'
 
   return $`node --version`
@@ -97,13 +97,13 @@ Retries a callback for a few times. Will return after the first
 successful attempt, or will throw after specifies attempts count.
 
 ```js
-let p = await retry(10, () => $`curl https://medv.io`)
+const p = await retry(10, () => $`curl https://medv.io`)
 
 // With a specified delay between attempts.
-let p = await retry(20, '1s', () => $`curl https://medv.io`)
+const p = await retry(20, '1s', () => $`curl https://medv.io`)
 
 // With an exponential backoff.
-let p = await retry(30, expBackoff(), () => $`curl https://medv.io`)
+const p = await retry(30, expBackoff(), () => $`curl https://medv.io`)
 ```
 
 ## spinner()
@@ -122,7 +122,7 @@ await spinner('working...', () => $`sleep 99`)
 The [globby](https://github.com/sindresorhus/globby) package.
 
 ```js
-let packages = await glob(['package.json', 'packages/*/package.json'])
+const packages = await glob(['package.json', 'packages/*/package.json'])
 ```
 
 ## which()
@@ -130,7 +130,7 @@ let packages = await glob(['package.json', 'packages/*/package.json'])
 The [which](https://github.com/npm/node-which) package.
 
 ```js
-let node = await which('node')
+const node = await which('node')
 ```
 
 ## argv
@@ -172,7 +172,7 @@ console.log(chalk.blue('Hello world!'))
 The [fs-extra](https://www.npmjs.com/package/fs-extra) package.
 
 ```js
-let {version} = await fs.readJson('./package.json')
+const {version} = await fs.readJson('./package.json')
 ```
 
 ## os
cli.md
@@ -41,7 +41,7 @@ EOF
 Evaluate the following argument as a script.
 
 ```bash
-cat package.json | zx --eval 'let v = JSON.parse(await stdin()).version; echo(v)'
+cat package.json | zx --eval 'const v = JSON.parse(await stdin()).version; echo(v)'
 ```
 
 ## Installing dependencies via --install
@@ -92,5 +92,5 @@ The `zx` provides `require()` function, so it can be used with imports in `.mjs`
 files (when using `zx` executable).
 
 ```js
-let {version} = require('./package.json')
+const {version} = require('./package.json')
 ```
faq.md
@@ -16,7 +16,7 @@ individually and concatenated via space.
 Example:
 
 ```js
-let files = [...]
+const files = [...]
 await $`tar cz ${files}`
 ```
 
getting-started.md
@@ -7,7 +7,7 @@
 
 await $`cat package.json | grep name`
 
-let branch = await $`git branch --show-current`
+const branch = await $`git branch --show-current`
 await $`dep deploy --branch=${branch}`
 
 await Promise.all([
@@ -16,7 +16,7 @@ await Promise.all([
   $`sleep 3; echo 3`,
 ])
 
-let name = 'foo bar'
+const name = 'foo bar'
 await $`mkdir /tmp/${name}`
 ```
 
@@ -75,7 +75,7 @@ and returns [`ProcessPromise`](process-promise.md).
 Everything passed through `${...}` will be automatically escaped and quoted.
 
 ```js
-let name = 'foo & bar'
+const name = 'foo & bar'
 await $`mkdir ${name}`
 ```
 
@@ -85,7 +85,7 @@ await $`mkdir ${name}`
 You can pass an array of arguments if needed:
 
 ```js
-let flags = [
+const flags = [
   '--oneline',
   '--decorate',
   '--color',
@@ -124,7 +124,7 @@ If `ProcessOutput` is used as an argument to some other `$` process,
 **zx** will use stdout and trim the new line.
 
 ```js
-let date = await $`date`
+const date = await $`date`
 await $`echo Current date is ${date}.`
 ```
 
known-issues.md
@@ -10,8 +10,8 @@ process to exit itself. Or use something like [exit](https://www.npmjs.com/packa
 
 Workaround is to write to a temp file:
 ```js
-let tmp = await $`mktemp` // Creates a temp file.
-let {stdout} = await $`cmd > ${tmp}; cat ${tmp}`
+const tmp = await $`mktemp` // Creates a temp file.
+const {stdout} = await $`cmd > ${tmp}; cat ${tmp}`
 ```
 
 ## Colors in subprocess
process-promise.md
@@ -3,7 +3,7 @@
 The `$` returns a `ProcessPromise` instance.
 
 ```js
-let p = $`command`
+const p = $`command`
 
 await p
 ```
@@ -16,7 +16,7 @@ this getter will trigger execution of a subprocess with [`stdio('pipe')`](#stdio
 Do not forget to end the stream.
 
 ```js
-let p = $`while read; do echo $REPLY; done`
+const p = $`while read; do echo $REPLY; done`
 p.stdin.write('Hello, World!\n')
 p.stdin.end()
 ```
@@ -65,7 +65,7 @@ await $`echo 1; sleep 1; echo 2; sleep 1; echo 3;`
 The `pipe()` method can combine `$` processes. Same as `|` in bash:
 
 ```js
-let greeting = await $`printf "hello"`
+const greeting = await $`printf "hello"`
   .pipe($`awk '{printf $1", world!"}'`)
   .pipe($`tr '[a-z]' '[A-Z]'`)
 
@@ -87,7 +87,7 @@ Kills the process and all children.
 By default, signal `SIGTERM` is sent. You can specify a signal via an argument.
 
 ```js
-let p = $`sleep 999`
+const p = $`sleep 999`
 setTimeout(() => p.kill('SIGINT'), 100)
 await p
 ```
@@ -99,7 +99,7 @@ Specifies a stdio for the process.
 Default is `.stdio('inherit', 'pipe', 'pipe')`.
 
 ```js
-let p = $`read`.stdio('pipe')
+const p = $`read`.stdio('pipe')
 ```
 
 ## `nothrow()`
quotes.md
@@ -4,7 +4,7 @@ When passing arguments to `${...}` there is no need to add quotes. **Quotes will
 be added automatically if needed.**
 
 ```js
-let name = 'foo & bar'
+const name = 'foo & bar'
 await $`mkdir ${name}`
 ```
 
@@ -37,7 +37,7 @@ will be quoted separately and concatenated via a space.
 Do **not** add a `.join(' ')`.
 
 ```js
-let flags = [
+const flags = [
   '--oneline',
   '--decorate',
   '--color',
@@ -63,13 +63,13 @@ In order for this to work the zx provides
 For instead of this:
 
 ```js
-let files = '~/dev/**/*.md' // wrong
+const files = '~/dev/**/*.md' // wrong
 await $`ls ${files}`
 ```
 
 Use `glob` function and `os` package:
 
 ```js
-let files = await glob(os.homedir() + '/dev/**/*.md')
+const files = await glob(os.homedir() + '/dev/**/*.md')
 await $`ls ${files}`
 ```