Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/components/DocsCallout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
</template>

<script>
import packageJson from '../../package.json'
import { useStore } from 'vuex'

export default {
name: 'DocsCallout',
props: {
Expand All @@ -44,7 +45,8 @@ export default {
plural: Boolean,
},
setup(props) {
const url = `https://coreui.io/vue/docs/${packageJson.config.coreui_library_short_version}/${props.url}`
const store = useStore()
const url = `https://coreui.io/vue/docs/${store.getters.coreuiLibraryShortVersion}/${props.href}`

return {
url,
Expand Down
8 changes: 8 additions & 0 deletions src/store/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { createStore } from 'vuex'

const COREUI_LIBRARY_SHORT_VERSION =
process.env.COREUI_LIBRARY_SHORT_VERSION || ''

export default createStore({
state: {
sidebarVisible: '',
Expand All @@ -16,6 +19,11 @@ export default createStore({
state.sidebarVisible = payload.value
},
},
getters: {
coreuiLibraryShortVersion() {
return COREUI_LIBRARY_SHORT_VERSION
},
},
actions: {},
modules: {},
})
15 changes: 15 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
const { DefinePlugin } = require('webpack')
const { defineConfig } = require('@vue/cli-service')
const fs = require('fs')
const packageJson = fs.readFileSync('./package.json')
const coreuiLibraryShortVersion =
JSON.parse(packageJson).config.coreui_library_short_version || ''

module.exports = defineConfig({
transpileDependencies: true,
configureWebpack: {
plugins: [
new DefinePlugin({
'process.env': {
COREUI_LIBRARY_SHORT_VERSION: '"' + coreuiLibraryShortVersion + '"',
},
}),
],
},
})