@eox/pages-theme-eox 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.prettierignore +1 -0
- package/config.mjs +20 -0
- package/package.json +9 -2
- package/src/https-hooks.mjs +31 -0
- package/src/index.js +8 -2
- package/src/vitepressConfig.mjs +34 -0
package/.prettierignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
package-lock.json
|
package/config.mjs
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { register } from "node:module";
|
|
2
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file
|
|
6
|
+
const __dirname = path.dirname(__filename); // get the name of the directory
|
|
7
|
+
|
|
8
|
+
export default async (brandId = "eox") => {
|
|
9
|
+
// Register the https-hooks.mjs module
|
|
10
|
+
register(pathToFileURL(path.join(__dirname, "./src/https-hooks.mjs")));
|
|
11
|
+
|
|
12
|
+
// Load the remote brand configuration
|
|
13
|
+
const brand = await import(`https://hub-brands.eox.at/${brandId}/config.mjs`);
|
|
14
|
+
|
|
15
|
+
// Load the base VitePress configuration
|
|
16
|
+
const vitepressConfig = await import("./src/vitepressConfig.mjs");
|
|
17
|
+
|
|
18
|
+
// Generate the VitePress configuration for the brand
|
|
19
|
+
return vitepressConfig.generate(brand.config);
|
|
20
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eox/pages-theme-eox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vitepress Theme with EOX branding",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"author": "EOX",
|
|
8
|
-
"license": "MIT"
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"format": "npx prettier --write ."
|
|
11
|
+
},
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@eox/eslint-config": "^2.0.0",
|
|
14
|
+
"vitepress": "^1.6.3"
|
|
15
|
+
}
|
|
9
16
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This is required to be able to import modules from https
|
|
3
|
+
* See https://nodejs.org/api/module.html#import-from-https
|
|
4
|
+
*/
|
|
5
|
+
import { get } from "node:https";
|
|
6
|
+
|
|
7
|
+
export function load(url, context, nextLoad) {
|
|
8
|
+
// For JavaScript to be loaded over the network, we need to fetch and
|
|
9
|
+
// return it.
|
|
10
|
+
if (url.startsWith("https://")) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
get(url, (res) => {
|
|
13
|
+
let data = "";
|
|
14
|
+
res.setEncoding("utf8");
|
|
15
|
+
res.on("data", (chunk) => (data += chunk));
|
|
16
|
+
res.on("end", () =>
|
|
17
|
+
resolve({
|
|
18
|
+
// This example assumes all network-provided JavaScript is ES module
|
|
19
|
+
// code.
|
|
20
|
+
format: "module",
|
|
21
|
+
shortCircuit: true,
|
|
22
|
+
source: data,
|
|
23
|
+
}),
|
|
24
|
+
);
|
|
25
|
+
}).on("error", (err) => reject(err));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Let Node.js handle all other URLs.
|
|
30
|
+
return nextLoad(url);
|
|
31
|
+
}
|
package/src/index.js
CHANGED
|
@@ -2,7 +2,13 @@ import DefaultTheme from "vitepress/theme";
|
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
extends: DefaultTheme,
|
|
5
|
-
enhanceApp({ siteData }) {
|
|
5
|
+
enhanceApp({ router, siteData }) {
|
|
6
|
+
router.onAfterRouteChanged = () => {
|
|
7
|
+
if (!import.meta.env.SSR) {
|
|
8
|
+
window.scrollTo(0, 0);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
6
12
|
if (!import.meta.env.SSR) {
|
|
7
13
|
const brandStyle = document.createElement("style");
|
|
8
14
|
brandStyle.appendChild(
|
|
@@ -20,7 +26,7 @@ export default {
|
|
|
20
26
|
--vp-c-brand-3: color-mix(in srgb, ${siteData.value.themeConfig.theme.primaryColor} 80%, white);
|
|
21
27
|
--vp-c-brand-soft: color-mix(in srgb, ${siteData.value.themeConfig.theme.primaryColor} 16%, transparent);
|
|
22
28
|
}
|
|
23
|
-
`)
|
|
29
|
+
`),
|
|
24
30
|
);
|
|
25
31
|
document.head.appendChild(brandStyle);
|
|
26
32
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base configuration for VitePress
|
|
3
|
+
* Documentation: see https://vitepress.dev/reference/site-config
|
|
4
|
+
* @param {object} brandConfig The brand config
|
|
5
|
+
* @returns
|
|
6
|
+
*/
|
|
7
|
+
export const generate = (brandConfig) => ({
|
|
8
|
+
appearance: false,
|
|
9
|
+
cleanUrls: true,
|
|
10
|
+
themeConfig: {
|
|
11
|
+
siteTitle: false,
|
|
12
|
+
theme: {
|
|
13
|
+
primaryColor: brandConfig.theme?.primary_color,
|
|
14
|
+
},
|
|
15
|
+
logo: brandConfig.logo,
|
|
16
|
+
footer: {
|
|
17
|
+
message: `Powered by <img src="https://cockpit.hub.eox.at/storage/uploads/eoxhub/eoxhub_icon.svg" style="display: inline; height: 20px; transform: translateY(5px)" />`,
|
|
18
|
+
copyright:
|
|
19
|
+
'Copyright © 2014-present <a href="https://eox.at" target="_blank">EOX IT Services GmbH</a>',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
title: brandConfig.meta?.title,
|
|
23
|
+
description: brandConfig.meta?.description,
|
|
24
|
+
head: [["link", { rel: "icon", href: brandConfig.meta?.favicon }]],
|
|
25
|
+
vue: {
|
|
26
|
+
template: {
|
|
27
|
+
compilerOptions: {
|
|
28
|
+
isCustomElement: (tag) => {
|
|
29
|
+
return tag.toLowerCase().includes("-");
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
});
|