@eox/pages-theme-eox 0.2.0 → 0.3.1

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/config.mjs CHANGED
@@ -1,17 +1,20 @@
1
- import { defineConfig } from "vitepress";
1
+ import { register } from "node:module";
2
+ import { fileURLToPath, pathToFileURL } from "node:url";
3
+ import path from "node:path";
2
4
 
3
- // https://vitepress.dev/reference/site-config
4
- export default defineConfig({
5
- srcDir: "./pages",
6
- appearance: "force-light",
7
- cleanUrls: true,
8
- vue: {
9
- template: {
10
- compilerOptions: {
11
- isCustomElement: (tag) => {
12
- return tag.toLowerCase().includes("-");
13
- },
14
- },
15
- },
16
- },
17
- });
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@eox/pages-theme-eox",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "description": "Vitepress Theme with EOX branding",
6
6
  "main": "src/index.js",
@@ -10,6 +10,7 @@
10
10
  "format": "npx prettier --write ."
11
11
  },
12
12
  "devDependencies": {
13
- "@eox/eslint-config": "^2.0.0"
13
+ "@eox/eslint-config": "^2.0.0",
14
+ "vitepress": "^1.6.3"
14
15
  }
15
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
+ }
@@ -0,0 +1,39 @@
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
+ vite: {
26
+ ssr: {
27
+ noExternal: ["@eox/pages-theme-eox"],
28
+ },
29
+ },
30
+ vue: {
31
+ template: {
32
+ compilerOptions: {
33
+ isCustomElement: (tag) => {
34
+ return tag.toLowerCase().includes("-");
35
+ },
36
+ },
37
+ },
38
+ },
39
+ });