tiptap/docs/src/layouts/App/index.vue

204 lines
5.2 KiB
Vue
Raw Normal View History

2020-04-17 23:06:55 +08:00
<template>
2020-10-12 19:58:41 +08:00
<div class="app">
2021-01-29 21:18:43 +08:00
<div class="app__navigation">
<g-link class="app__name" to="/">
<img src="~@/assets/images/logo.svg">
</g-link>
<span style="position: relative">
Search
<div class="app__search-docsearch" />
</span>
<g-link to="/overview/installation">
Documentation
</g-link>
<g-link to="https://github.com/ueberdosis/tiptap-next">
GitHub
</g-link>
2020-10-12 23:43:20 +08:00
2021-01-29 21:18:43 +08:00
<button
class="app__menu-icon"
@click="menuIsVisible = true"
v-if="!menuIsVisible"
>
<icon name="menu" />
</button>
<button
class="app__close-icon"
@click="menuIsVisible = false"
v-if="menuIsVisible"
>
<icon name="close" />
</button>
2020-10-12 19:58:41 +08:00
</div>
<div class="app__content">
2021-01-29 21:18:43 +08:00
<div class="app__sidebar">
<portal-target name="desktop-nav" />
2020-10-12 19:58:41 +08:00
</div>
2021-01-29 21:18:43 +08:00
2020-10-13 00:09:20 +08:00
<main class="app__main">
2021-01-29 21:18:43 +08:00
<div class="app__top-bar">
<div class="app__inner app__top-bar-inner" />
<div class="app__mobile-nav" v-if="menuIsVisible">
<portal-target name="mobile-nav" />
</div>
2020-10-13 00:09:20 +08:00
</div>
2021-01-29 21:18:43 +08:00
<main class="app__main">
<div class="app__inner">
<slot />
</div>
</main>
<div class="app__page-navigation">
<div class="app__inner">
<page-navigation />
</div>
2020-10-29 04:23:22 +08:00
</div>
2021-01-29 21:18:43 +08:00
</main>
2020-10-13 00:42:47 +08:00
2021-01-29 21:18:43 +08:00
<portal :to="portal">
<nav class="app__sidebar-navigation">
<div class="app__link-group" v-for="(linkGroup, i) in linkGroups" :key="i">
<div class="app__link-group-title">
{{ linkGroup.title }}
</div>
<ul class="app__link-list">
<li v-for="(item, j) in linkGroup.items" :key="j">
<g-link
:class="{
'app__link': true,
'app__link--exact': $router.currentRoute.path === item.link,
'app__link--active': $router.currentRoute.path.startsWith(item.link),
[`app__link--${item.type}`]: item.type !== null,
'app__link--with-children': !!item.items
}"
:to="item.redirect || item.link"
>
{{ item.title }}
</g-link>
<ul v-if="item.items" class="app__link-list">
<li v-for="(item, k) in item.items" :key="k">
<g-link
:class="{
'app__link': true,
'app__link--exact': $router.currentRoute.path === item.link,
'app__link--active': $router.currentRoute.path.startsWith(item.link),
[`app__link--${item.type}`]: item.type !== null,
}"
:to="item.link"
exact
>
{{ item.title }}
</g-link>
</li>
</ul>
</li>
</ul>
2020-10-13 00:42:47 +08:00
</div>
2021-01-29 21:18:43 +08:00
</nav>
</portal>
</div>
<footer class="app__footer">
<a :href="editLink" target="_blank">Edit this page on GitHub</a>
&middot;
Made with 🖤 by <a href="https://twitter.com/_ueberdosis">überdosis</a>
</footer>
2020-04-17 23:06:55 +08:00
</div>
</template>
<static-query>
query {
metadata {
siteName
}
2020-04-18 18:48:20 +08:00
}
</static-query>
<script>
2020-04-24 16:03:15 +08:00
import linkGroups from '@/links.yaml'
2020-10-13 00:42:47 +08:00
import Icon from '@/components/Icon'
2020-04-19 01:50:06 +08:00
import PageNavigation from '@/components/PageNavigation'
2020-10-12 23:45:38 +08:00
// import GithubButton from 'vue-github-button'
2020-04-18 18:48:20 +08:00
export default {
2020-04-19 01:50:06 +08:00
components: {
2020-10-13 00:42:47 +08:00
Icon,
2020-04-19 01:50:06 +08:00
PageNavigation,
2020-10-12 23:45:38 +08:00
// GithubButton,
2020-04-19 01:50:06 +08:00
},
2020-04-18 18:48:20 +08:00
data() {
return {
2020-04-19 01:50:06 +08:00
linkGroups,
2020-04-23 18:22:59 +08:00
menuIsVisible: false,
2020-10-13 00:42:47 +08:00
windowWidth: null,
2020-04-17 23:06:55 +08:00
}
2020-04-19 01:50:06 +08:00
},
2020-08-13 16:12:52 +08:00
computed: {
2020-10-13 00:42:47 +08:00
portal() {
if (this.windowWidth && this.windowWidth < 800) {
return 'mobile-nav'
}
return 'desktop-nav'
},
2020-09-24 06:29:05 +08:00
currentPath() {
2020-08-13 16:12:52 +08:00
return this.$route.matched[0].path
},
2020-10-13 00:42:47 +08:00
2020-09-24 06:29:05 +08:00
editLink() {
const { currentPath } = this
2020-09-21 23:17:28 +08:00
const filePath = currentPath === '' ? '/introduction' : currentPath
2020-08-13 16:12:52 +08:00
2020-10-31 01:11:54 +08:00
if (process.env.NODE_ENV === 'development') {
return `vscode://file${this.cwd}/src/docPages${filePath}.md`
}
2020-09-21 23:17:28 +08:00
return `https://github.com/ueberdosis/tiptap-next/blob/main/docs/src/docPages${filePath}.md`
2020-08-13 16:12:52 +08:00
},
2020-08-13 23:27:34 +08:00
},
2020-10-13 00:42:47 +08:00
watch: {
$route() {
this.menuIsVisible = false
},
},
2020-08-13 23:27:34 +08:00
methods: {
initSearch() {
2020-09-24 06:29:05 +08:00
// eslint-disable-next-line
2020-08-13 23:27:34 +08:00
docsearch({
apiKey: '1abe7fb0f0dac150d0e963d2eda930fe',
indexName: 'ueberdosis_tiptap',
2020-11-07 00:11:52 +08:00
container: '.app__search-docsearch',
2020-08-13 23:27:34 +08:00
debug: false,
})
2020-09-24 06:29:05 +08:00
},
2020-10-13 00:42:47 +08:00
handleResize() {
this.windowWidth = window.innerWidth
},
2020-08-13 23:27:34 +08:00
},
mounted() {
this.initSearch()
2020-10-13 00:42:47 +08:00
this.handleResize()
window.addEventListener('resize', this.handleResize)
},
beforeDestroy() {
window.removeEventListener('resize', this.handleResize)
2020-08-13 23:27:34 +08:00
},
2020-04-17 23:06:55 +08:00
}
2020-04-18 18:48:20 +08:00
</script>
2020-04-17 23:06:55 +08:00
2020-04-18 05:18:18 +08:00
<style lang="scss" src="./fonts.scss"></style>
2020-04-18 18:48:20 +08:00
<style lang="scss" src="./base.scss"></style>
2020-04-18 05:35:07 +08:00
<style lang="scss" src="./prism.scss"></style>
2020-09-24 06:29:05 +08:00
<style lang="scss" src="./style.scss" scoped></style>