Skip to content

Commit add05f5

Browse files
authored
Combine all pages in docs (#15)
* sidebar rework and search plugin * Changed workflow to only upload MD file and then build vuepress site with all of the folders
1 parent 328794c commit add05f5

12 files changed

Lines changed: 5856 additions & 3185 deletions

File tree

action.yml

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,54 @@
1-
name: 'Build and Deploy Documentation Site'
2-
description: 'Convert Markdown documentation to a BCC documentation site'
1+
name: "Build and Deploy Documentation Site"
2+
description: "Convert Markdown documentation to a BCC documentation site"
33
inputs:
44
title:
5-
description: 'Title of the generated website'
5+
description: "Title of the generated website"
66
required: true
77
default: ${{ github.event.repository.name }}
88
description:
9-
description: 'Description of the generated website, used for the head meta tag'
9+
description: "Description of the generated website, used for the head meta tag"
1010
required: true
1111
default: ${{ github.event.repository.description }}
1212
docs-dir:
13-
description: 'Directory where the docs are located'
13+
description: "Directory where the docs are located"
1414
required: false
15-
default: 'docs'
15+
default: "docs"
1616
branch:
1717
description: 'Which branch to use for "Edit this page on GitHub" links'
1818
required: false
19-
default: 'main'
19+
default: "main"
2020
base:
21-
description: 'The base url for the website'
21+
description: "The base url for the website"
2222
required: false
2323
default: /${{ github.event.repository.name }}/
2424
collapse-sidebar:
25-
description: 'Whether to collapse sidebar sections by default'
25+
description: "Whether to collapse sidebar sections by default"
2626
required: false
2727
default: false
2828
auto-register-components:
29-
description: 'Whether to automatically register Vue components'
29+
description: "Whether to automatically register Vue components"
3030
required: false
3131
default: false
3232
components-dir:
33-
description: 'The directory from where Vue components should automatically be registered'
33+
description: "The directory from where Vue components should automatically be registered"
3434
required: false
35-
default: 'src/components'
35+
default: "src/components"
3636
debug-build:
37-
description: 'Whether or not to enable debugging for the Vite build'
37+
description: "Whether or not to enable debugging for the Vite build"
3838
required: false
3939
default: false
4040
public:
41-
description: 'Whether or not to make the documentation publicly available (only works for private repositories)'
41+
description: "Whether or not to make the documentation publicly available (only works for private repositories)"
4242
required: false
4343
default: false
4444
authentication:
45-
description: 'Which provider to use for the login flow when accessing the documentation'
45+
description: "Which provider to use for the login flow when accessing the documentation"
4646
required: false
47-
default: 'github'
47+
default: "github"
48+
root:
49+
description: "Whether or not to deploy the site to the root of the custom container (true) or to a subfolder named after the repository (false)"
50+
required: false
51+
default: false
4852
runs:
4953
using: "composite"
5054
steps:
@@ -58,14 +62,11 @@ runs:
5862
with:
5963
path: source
6064

61-
- name: Copy documentation to VuePress theme
65+
- name: Zip Markdown files
6266
shell: bash
6367
run: |
64-
cd source
65-
cp -r ./${{ inputs.docs-dir }}/* $GITHUB_WORKSPACE/vuepress/docs/
66-
${{ inputs.auto-register-components }} && mkdir $GITHUB_WORKSPACE/vuepress/docs/.vuepress/auto-register-components/
67-
${{ inputs.auto-register-components }} && cp -r ./${{ inputs.components-dir }}/* $GITHUB_WORKSPACE/vuepress/docs/.vuepress/auto-register-components/
68-
true
68+
cd source/${{ inputs.docs-dir }}
69+
zip -r MarkdownDocs.zip . -i '*.md'
6970
7071
- uses: microsoft/variable-substitution@v1
7172
with:
@@ -80,25 +81,39 @@ runs:
8081
collapseSidebarSections: ${{ inputs.collapse-sidebar }}
8182
autoRegisterComponents: ${{ inputs.auto-register-components }}
8283

83-
- name: Build VuePress site
84+
- name: Get Token from GitHub
85+
id: token
8486
shell: bash
8587
run: |
86-
cd vuepress
87-
npm ci && ${{ inputs.debug-build == true && 'DEBUG=*' || '' }} npm run build ${{ inputs.debug-build == true && '-- --debug' || '' }}
88+
curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://github.com/bcc-code" | jq -r ".value" | echo -e "token=$(</dev/stdin)\n" >> $GITHUB_OUTPUT
8889
89-
- name: Zips built site files
90+
- name: Upload Markdown files to azure storage
9091
shell: bash
9192
run: |
92-
cd vuepress/docs/.vuepress/dist
93-
zip -r Docs.zip *
94-
95-
- name: Get Token from GitHub
96-
id: token
93+
curl --request POST \
94+
--header "Authorization: Bearer ${{steps.token.outputs.token}}" \
95+
--form Docs=@source/${{ inputs.docs-dir }}/MarkdownDocs.zip \
96+
"https://developer.bcc.no/UploadMdContainer?aggregateContainer=MdDocs&root=${{inputs.root}}"
97+
98+
- name: Download Markdown files from azure storage
9799
shell: bash
98100
run: |
99-
curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL&audience=https://github.com/bcc-code" | jq -r ".value" | echo -e "token=$(</dev/stdin)\n" >> $GITHUB_OUTPUT
100-
101-
- name: Upload files to azure storage
101+
curl --header "Authorization: Bearer ${{steps.token.outputs.token}}" \
102+
"https://developer.bcc.no/GetDoc?container=MdDocs" \
103+
--output MarkdownDocs.zip
104+
unzip -o MarkdownDocs.zip -d vuepress/docs/
105+
106+
- name: Build VuePress site
107+
shell: bash
108+
run: |
109+
cd vuepress
110+
npm ci && ${{ inputs.debug-build == true && 'DEBUG=*' || '' }} npm run build ${{ inputs.debug-build == true && '-- --debug' || '' }}
111+
112+
- name: Upload VuePress site
102113
shell: bash
103114
run: |
104-
curl --request POST --header "Authorization: Bearer ${{steps.token.outputs.token}}" --header 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36' --form Docs=@vuepress/docs/.vuepress/dist/Docs.zip "https://developer.bcc.no/UploadDoc?isPublic=${{inputs.public}}&auth=${{inputs.authentication}}"
115+
cd vuepress
116+
curl --request POST \
117+
--header "Authorization: Bearer ${{steps.token.outputs.token}}" \
118+
--form Docs=@./.vuepress/dist.zip \
119+
"https://developer.bcc.no/UploadDoc?isPublic=${{inputs.public}}&auth=${{inputs.authentication}}&customContainerName=DocumentationSite"

vuepress/docs/.vuepress/client.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
import { defineClientConfig } from '@vuepress/client'
2-
import NotFound from './theme/layouts/NotFound.vue'
3-
import PrimeVue from 'primevue/config'
4-
import Aura from '@primeuix/themes/aura';
5-
1+
import { defineClientConfig } from "@vuepress/client";
2+
import NotFound from "./theme/layouts/NotFound.vue";
3+
import PrimeVue from "primevue/config";
4+
import Aura from "@primeuix/themes/aura";
65

76
export default defineClientConfig({
87
layouts: {
98
NotFound,
109
},
1110
enhance({ app, router, siteData }) {
1211
app.use(PrimeVue, {
13-
ripple: false,
14-
theme: {
15-
preset: Aura,
16-
options: {
17-
prefix: 'prime',
18-
darkModeSelector: 'html[data-theme=dark]',
19-
cssLayer: false
20-
},
21-
}
22-
});
23-
}
12+
ripple: false,
13+
theme: {
14+
preset: Aura,
15+
options: {
16+
prefix: "prime",
17+
darkModeSelector: "html[data-theme=dark]",
18+
cssLayer: false,
19+
},
20+
},
21+
});
22+
},
2423
});

vuepress/docs/.vuepress/config.ts

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
import process from 'node:process'
2-
import { defineUserConfig } from '@vuepress/cli'
3-
import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
1+
import process from "node:process";
2+
import { defineUserConfig } from "@vuepress/cli";
3+
import { registerComponentsPlugin } from "@vuepress/plugin-register-components";
44

5-
import theme from './theme/theme'
5+
import theme from "./theme/theme";
66
import * as data from "./data.json";
77

8-
import { getDirname, path } from '@vuepress/utils'
9-
import { viteBundler } from '@vuepress/bundler-vite'
10-
import Components from 'unplugin-vue-components/vite'
11-
import { PrimeVueResolver } from 'unplugin-vue-components/resolvers'
8+
import { getDirname, path } from "@vuepress/utils";
9+
import { viteBundler } from "@vuepress/bundler-vite";
10+
import Components from "unplugin-vue-components/vite";
11+
import { PrimeVueResolver } from "unplugin-vue-components/resolvers";
1212

13-
const __dirname = getDirname(import.meta.url)
14-
15-
const isProd = process.env.NODE_ENV === 'production';
13+
const __dirname = getDirname(import.meta.url);
1614

15+
const isProd = process.env.NODE_ENV === "production";
1716

1817
export default defineUserConfig({
1918
base: data.base,
2019

2120
title: data.title,
2221
description: data.description,
2322

24-
head: [
25-
['link', { rel: 'icon', href: `${data.base}favicon.ico` }]
26-
],
23+
head: [["link", { rel: "icon", href: `${data.base}favicon.ico` }]],
2724

2825
theme,
2926

@@ -42,11 +39,21 @@ export default defineUserConfig({
4239
}),
4340

4441
alias: {
45-
'@theme-hope/HomeFeatures.vue': path.resolve(__dirname, './components/HomeFeatures.vue'),
46-
'@theme-hope/NavbarBrand.vue': path.resolve(__dirname, './components/NavbarBrand.vue'),
42+
"@theme-hope/HomeFeatures.vue": path.resolve(
43+
__dirname,
44+
"./components/HomeFeatures.vue"
45+
),
46+
"@theme-hope/NavbarBrand.vue": path.resolve(
47+
__dirname,
48+
"./components/NavbarBrand.vue"
49+
),
4750
},
48-
51+
4952
plugins: [
50-
data.autoRegisterComponents ? registerComponentsPlugin({ componentsDir: path.resolve(__dirname, `./auto-register-components`) }) : [],
53+
data.autoRegisterComponents
54+
? registerComponentsPlugin({
55+
componentsDir: path.resolve(__dirname, `./auto-register-components`),
56+
})
57+
: [],
5158
],
52-
})
59+
});

vuepress/docs/.vuepress/theme/components/HomeFeatures.vue

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,37 @@
11
<script setup lang="ts">
2-
import { usePageFrontmatter } from '@vuepress/client'
3-
import { isArray } from '@vuepress/shared'
4-
import { computed } from 'vue'
5-
import type { DefaultThemeHomePageFrontmatter } from '@vuepress/shared/dist/index'
2+
import { usePageFrontmatter } from "@vuepress/client";
3+
import { isArray } from "@vuepress/shared";
4+
import { computed } from "vue";
5+
import type { DefaultThemeHomePageFrontmatter } from "@vuepress/shared/dist/index";
66
7-
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>()
7+
const frontmatter = usePageFrontmatter<DefaultThemeHomePageFrontmatter>();
88
const features = computed(() => {
99
if (isArray(frontmatter.value.features)) {
10-
return frontmatter.value.features
10+
return frontmatter.value.features;
1111
}
12-
return []
13-
})
12+
return [];
13+
});
1414
</script>
1515

1616
<template>
1717
<div v-if="features.length" class="bcc-features">
1818
<div v-for="feature in features" :key="feature.title" class="bcc-feature">
19-
<a :href="feature.link" v-if="feature.link.startsWith('http')" rel="noopener"><h2>{{ feature.title }}</h2></a>
20-
<router-link :to="feature.link ?? '/'" v-else><h2>{{ feature.title }}</h2></router-link>
19+
<a
20+
:href="feature.link"
21+
v-if="feature.link.startsWith('http')"
22+
rel="noopener"
23+
><h2>{{ feature.title }}</h2></a
24+
>
25+
<router-link :to="feature.link ?? '/'" v-else
26+
><h2>{{ feature.title }}</h2></router-link
27+
>
2128
<p>{{ feature.details }}</p>
22-
<a :href="feature.link" v-if="feature.link.startsWith('http')" rel="noopener">Read More →</a>
29+
<a
30+
:href="feature.link"
31+
v-if="feature.link.startsWith('http')"
32+
rel="noopener"
33+
>Read More →</a
34+
>
2335
<router-link v-else :to="feature.link ?? '/'">Read More →</router-link>
2436
</div>
2537
</div>

vuepress/docs/.vuepress/theme/components/NavbarBrand.vue

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
<script setup lang="ts">
2-
import { ClientOnly, withBase } from '@vuepress/client'
3-
import { computed, h } from 'vue'
4-
import type { FunctionalComponent } from 'vue'
5-
import { useDarkMode, useThemeLocaleData } from '@vuepress/theme-default/lib/client/composables/index'
2+
import { ClientOnly, withBase } from "@vuepress/client";
3+
import { computed, h } from "vue";
4+
import type { FunctionalComponent } from "vue";
5+
import {
6+
useDarkMode,
7+
useThemeLocaleData,
8+
} from "@vuepress/theme-default/lib/client/composables/index";
69
7-
const themeLocale = useThemeLocaleData()
8-
const isDarkMode = useDarkMode()
10+
const themeLocale = useThemeLocaleData();
11+
const isDarkMode = useDarkMode();
912
1013
const navbarBrandLogo = computed(() => {
1114
if (isDarkMode.value && themeLocale.value.logoDark !== undefined) {
12-
return themeLocale.value.logoDark
15+
return themeLocale.value.logoDark;
1316
}
14-
return themeLocale.value.logo
15-
})
17+
return themeLocale.value.logo;
18+
});
1619
const NavbarBrandLogo: FunctionalComponent = () => {
17-
if (!navbarBrandLogo.value) return null
18-
const img = h('img', {
19-
class: 'logo',
20+
if (!navbarBrandLogo.value) return null;
21+
const img = h("img", {
22+
class: "logo",
2023
src: withBase(navbarBrandLogo.value),
2124
alt: "BCC",
22-
})
25+
});
2326
if (themeLocale.value.logoDark === undefined) {
24-
return img
27+
return img;
2528
}
2629
// wrap brand logo with <ClientOnly> to avoid ssr-mismatch
2730
// when using a different brand logo in dark mode
28-
return h(ClientOnly, () => img)
29-
}
31+
return h(ClientOnly, () => img);
32+
};
3033
</script>
3134

3235
<template>

0 commit comments

Comments
 (0)