"use strict";(self.webpackChunkdashy=self.webpackChunkdashy||[]).push([[714],{3905:function(e,t,n){n.d(t,{Zo:function(){return p},kt:function(){return c}});var a=n(7294);function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function r(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,a)}return n}function o(e){for(var t=1;t=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);for(a=0;a=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var l=a.createContext({}),u=function(e){var t=a.useContext(l),n=t;return e&&(n="function"==typeof e?e(t):o(o({},t),e)),n},p=function(e){var t=u(e.components);return a.createElement(l.Provider,{value:t},e.children)},d={inlineCode:"code",wrapper:function(e){var t=e.children;return a.createElement(a.Fragment,{},t)}},h=a.forwardRef((function(e,t){var n=e.components,i=e.mdxType,r=e.originalType,l=e.parentName,p=s(e,["components","mdxType","originalType","parentName"]),h=u(n),c=i,m=h["".concat(l,".").concat(c)]||h[c]||d[c]||r;return n?a.createElement(m,o(o({ref:t},p),{},{components:n})):a.createElement(m,o({ref:t},p))}));function c(e,t){var n=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var r=n.length,o=new Array(r);o[0]=h;var s={};for(var l in t)hasOwnProperty.call(t,l)&&(s[l]=t[l]);s.originalType=e,s.mdxType="string"==typeof e?e:i,o[1]=s;for(var u=2;u ({\n statusCode: 200,\n body: 'Return some data here...',\n});\n")),(0,r.kt)("h4",{id:"3-redirect-the-node-endpoint-to-the-function"},"3. Redirect the Node endpoint to the function"),(0,r.kt)("p",null,"In the ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/FEATURE/serverless-functions/netlify.toml"},(0,r.kt)("inlineCode",{parentName:"a"},"netlify.toml"))," file, add a 301 redirect, with the path to the original Node.js endpoint, and the name of your cloud function"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-toml"},'[[redirects]]\n from = "/status-check"\n to = "/.netlify/functions/cloud-status-check"\n status = 301\n force = true\n')),(0,r.kt)("hr",null),(0,r.kt)("h2",{id:"hiding-page-furniture-on-certain-routes"},"Hiding Page Furniture on Certain Routes"),(0,r.kt)("p",null,"For some pages (such as the login page, the minimal start page, etc) the basic page furniture, (like header, footer, nav, etc) is not needed. This section explains how you can hide furniture on a new view (step 1), or add a component that should be hidden on certain views (step 2)."),(0,r.kt)("h5",{id:"1-add-the-route-name-to-the-should-hide-array"},"1. Add the route name to the should hide array"),(0,r.kt)("p",null,"In ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/master/src/utils/defaults.js"},(0,r.kt)("inlineCode",{parentName:"a"},"./src/utils/defaults.js")),", there's an array called ",(0,r.kt)("inlineCode",{parentName:"p"},"hideFurnitureOn"),". Append the name of the route (the same as it appears in ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/master/src/router.js"},(0,r.kt)("inlineCode",{parentName:"a"},"router.js")),") here."),(0,r.kt)("h5",{id:"2-add-the-conditional-to-the-structural-component-to-hide"},"2. Add the conditional to the structural component to hide"),(0,r.kt)("p",null,"First, import the helper function:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-javascript"},"import { shouldBeVisible } from '@/utils/MiscHelpers';\n")),(0,r.kt)("p",null,"Then you can create a computed value, that calls this function, passing in the route name:"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-javascript"},"export default {\n ...\n computed: {\n ...\n isVisible() {\n return shouldBeVisible(this.$route.name);\n },\n },\n};\n")),(0,r.kt)("p",null,"Finally, in the markup of your component, just add a ",(0,r.kt)("inlineCode",{parentName:"p"},"v-if")," statement, referencing your computed value"),(0,r.kt)("pre",null,(0,r.kt)("code",{parentName:"pre",className:"language-vue"},'
\n ...\n
\n')),(0,r.kt)("hr",null),(0,r.kt)("h2",{id:"adding--using-environmental-variables"},"Adding / Using Environmental Variables"),(0,r.kt)("p",null,"All environmental variables are optional. Currently there are not many environmental variables used, as most of the user preferences are stored under ",(0,r.kt)("inlineCode",{parentName:"p"},"appConfig")," in the ",(0,r.kt)("inlineCode",{parentName:"p"},"conf.yml")," file."),(0,r.kt)("p",null,"You can set variables either in your environment, or using the ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/master/.env"},(0,r.kt)("inlineCode",{parentName:"a"},".env"))," file."),(0,r.kt)("p",null,"Any environmental variables used by the frontend are preceded with ",(0,r.kt)("inlineCode",{parentName:"p"},"VUE_APP_"),". Vue will merge the contents of your ",(0,r.kt)("inlineCode",{parentName:"p"},".env")," file into the app in a similar way to the ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/motdotla/dotenv"},"'dotenv'")," package, where any variables that you set on your system will always take preference over the contents of any ",(0,r.kt)("inlineCode",{parentName:"p"},".env")," file."),(0,r.kt)("p",null,"If add any new variables, ensure that there is always a fallback (define it in ",(0,r.kt)("a",{parentName:"p",href:"https://github.com/Lissy93/dashy/blob/master/src/utils/defaults.js"},(0,r.kt)("inlineCode",{parentName:"a"},"defaults.js")),"), so as to not cause breaking changes. Don't commit the contents of your ",(0,r.kt)("inlineCode",{parentName:"p"},".env")," file to git, but instead take a few moments to document what you've added under the appropriate section. Try and follow the concepts outlined in the ",(0,r.kt)("a",{parentName:"p",href:"https://12factor.net/config"},"12 factor app"),"."))}h.isMDXComponent=!0}}]);