Skip to content

Commit

Permalink
Merge pull request #74 from SpeciesFileGroup/development
Browse files Browse the repository at this point in the history
Use base_url for logo and add default config
  • Loading branch information
José Luis Pereira authored and GitHub committed May 24, 2023
2 parents 1d4a5cb + 8aa1845 commit 7cd6a7a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
10 changes: 8 additions & 2 deletions src/components/Layout/LayoutHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<img
v-if="header_logo_url"
class="mr-3 h-10"
:src="header_logo_url"
:src="logoUrl"
:alt="header_logo_text"
/>
<span>
Expand Down Expand Up @@ -52,6 +52,12 @@
<script setup>
import SwitchTheme from '../SwitchTheme.vue'
import NavbarMobile from '../Navbar/NavbarMobile.vue'
import { isValidUrl } from '@/utils/url'
const { header_links, header_logo_text, header_logo_url } = __APP_ENV__
const { header_links, header_logo_text, header_logo_url, base_url } =
__APP_ENV__
const logoUrl = isValidUrl(header_logo_url)
? header_logo_url
: base_url + header_logo_url
</script>
7 changes: 7 additions & 0 deletions src/constants/defaultConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default {
base_url: '/',
hash_mode: false,
map_tile_server: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
map_tile_attribution:
'&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}
9 changes: 6 additions & 3 deletions src/utils/loadConfiguration.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import fs from 'fs'
import yaml from 'js-yaml'
import glob from 'glob'
import defaultConfig from '../constants/defaultConfig'

export const loadConfiguration = appPath => {
export const loadConfiguration = (appPath) => {
const filePaths = glob.sync(appPath + '/config/*.yml', {})
const jsonConfig = filePaths.map(filepath => yaml.load(fs.readFileSync(filepath, 'utf8')))
const jsonConfig = filePaths.map((filepath) =>
yaml.load(fs.readFileSync(filepath, 'utf8'))
)

return Object.assign({}, ...jsonConfig)
return Object.assign({}, defaultConfig, ...jsonConfig)
}
8 changes: 8 additions & 0 deletions src/utils/url.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export function isValidUrl(string) {
try {
new URL(string)
return true
} catch (err) {
return false
}
}

0 comments on commit 7cd6a7a

Please sign in to comment.