From 1a42e30a1752be5ab0fba5b224fad5686f12499e Mon Sep 17 00:00:00 2001
From: Bastien Wirtz <bastien.wirtz@gmail.com>
Date: Tue, 9 Jun 2020 19:11:42 -0700
Subject: Adding external config support

---
 src/App.vue | 33 +++++++++++++++++++++------------
 1 file changed, 21 insertions(+), 12 deletions(-)

(limited to 'src/App.vue')

diff --git a/src/App.vue b/src/App.vue
index fddc585..440ffa0 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -63,7 +63,7 @@
               </h2>
               <Service
                 v-for="item in group.items"
-                :key="item.url"
+                :key="item.name"
                 v-bind:item="item"
                 class="column is-one-third-widescreen"
               />
@@ -153,19 +153,28 @@ export default {
     document.title = `${this.config.title} | ${this.config.subtitle}`;
   },
   methods: {
-    getConfig: function () {
-      return fetch("config.yml")
-        .then((response) => {
-          if (!response.ok) {
-            throw Error(response.statusText);
-          }
-          return response.text().then((body) => {
+    getConfig: function (path = "config.yml") {
+      return fetch(path).then((response) => {
+        if (!response.ok) {
+          throw Error(response.statusText);
+        }
+
+        const that = this;
+        return response
+          .text()
+          .then((body) => {
             return jsyaml.load(body);
+          })
+          .then(function (config) {
+            if (config.externalConfig) {
+              return that.getConfig(config.externalConfig);
+            }
+            return config;
+          })
+          .catch((error) => {
+            return this.handleErrors("⚠️ Error loading configuration", error);
           });
-        })
-        .catch((error) => {
-          return this.handleErrors("⚠️ Error loading configuration", error);
-        });
+      });
     },
     matchesFilter: function (item) {
       return (
-- 
cgit v1.2.3

