naive-ui/demo/utils/EditOnGithubHeader.vue

69 lines
1.2 KiB
Vue
Raw Normal View History

2020-03-19 13:26:06 +08:00
<template>
2020-03-19 18:26:48 +08:00
<n-h1 :id="id" class="naive-doc-title">
2020-05-31 00:57:47 +08:00
<span>{{ text }}</span>
2020-03-19 18:26:48 +08:00
<span class="edit-button">
2021-06-09 02:27:40 +08:00
<n-tooltip placement="right">
<template #trigger>
2020-03-19 18:26:48 +08:00
<edit-on-github-button
text
class="edit-button"
2020-09-04 01:06:39 +08:00
:relative-url="relativeUrl"
2020-03-19 18:26:48 +08:00
/>
</template>
2020-10-08 04:14:14 +08:00
{{ t('editOnGithub') }}
2020-03-19 18:26:48 +08:00
</n-tooltip>
</span>
2020-03-19 13:26:06 +08:00
</n-h1>
</template>
2020-03-19 18:26:48 +08:00
2020-03-19 13:26:06 +08:00
<script>
2021-01-13 12:31:41 +08:00
import { i18n } from '../utils/composables'
2021-06-02 17:51:13 +08:00
import EditOnGithubButton from './EditOnGithubButton.vue'
2020-10-08 04:14:14 +08:00
2020-03-19 13:26:06 +08:00
export default {
name: 'EditOnGithubHeader',
2021-06-02 17:51:13 +08:00
components: {
EditOnGithubButton
},
2020-03-19 13:26:06 +08:00
props: {
2020-09-04 01:06:39 +08:00
relativeUrl: {
2020-03-19 13:26:06 +08:00
type: String,
required: true
},
text: {
type: String,
required: true
}
},
2020-10-08 04:14:14 +08:00
setup () {
return {
2020-12-12 13:51:22 +08:00
...i18n({
2020-10-08 04:14:14 +08:00
'zh-CN': {
editOnGithub: '在 GitHub 上编辑'
2020-10-08 04:14:14 +08:00
},
'en-US': {
editOnGithub: 'Edit on GitHub'
2020-10-08 04:14:14 +08:00
}
2020-12-12 13:51:22 +08:00
})
2020-10-08 04:14:14 +08:00
}
},
2020-03-19 13:26:06 +08:00
computed: {
id () {
return this.text.replace(/ /g, '-')
}
}
}
</script>
2020-03-19 18:26:48 +08:00
<style scoped>
2020-05-31 00:57:47 +08:00
.naive-doc-title {
display: flex;
}
2020-03-19 18:26:48 +08:00
.naive-doc-title .edit-button {
2020-11-28 13:34:45 +08:00
margin-left: 4px;
2020-03-19 18:26:48 +08:00
display: inline-flex;
align-items: center;
}
2020-03-19 13:26:06 +08:00
</style>