Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
HugoRCD committed Jun 3, 2024
2 parents cb52bc4 + 716bfe7 commit 6ad8dc8
Show file tree
Hide file tree
Showing 19 changed files with 288 additions and 81 deletions.
4 changes: 2 additions & 2 deletions apps/docs/content/1.getting-started/2.installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default <Partial<Config>>{
This module is installed to provide dark mode support out of the box thanks to the Tailwind CSS dark mode `class` strategy.

::callout{icon="i-heroicons-light-bulb"}
You can read more about this in the [Theming](/getting-started/theming#dark-mode) section.
You can read more about this in the [Theming](/getting-started/installation) section.
::

## TypeScript
Expand Down Expand Up @@ -143,7 +143,7 @@ export default defineAppConfig({
```

::callout{icon="i-heroicons-light-bulb"}
You can read more about components configuration in the [Theming](/getting-started/theming#appconfigts) section.
You can read more about components configuration in the [Theming](/getting-started/installation) section.
::

You can write your `tailwind.config` in TypeScript as such:
Expand Down
11 changes: 1 addition & 10 deletions apps/docs/layouts/docs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,7 @@ const { data: page } = await useAsyncData(route.path, () => queryContent(route.p
<Main>
<Page>
<template #right>
<div class="flex flex-col gap-2">
<h3 class="text-gray-12 text-2xl font-bold">
Table of Contents
</h3>
<ul class="list-none">
<li v-for="link in page.body.toc.links" :key="link.id">
<span>{{ link.text }}</span>
</li>
</ul>
</div>
<MContentToc :links="page?.body?.toc?.links" />
</template>
<div>
<slot />
Expand Down
6 changes: 3 additions & 3 deletions packages/mockline/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![Mockline Social Preview](assets/social-preview.jpg)
![Mockline Social Preview](../../assets/social-preview.jpg)

<p align="center">
<a aria-label="NPM version" href="https://www.npmjs.com/package/mockline">
Expand Down Expand Up @@ -102,7 +102,7 @@ To start contributing, you can follow these steps:

<!-- /automd -->

<!-- automd:contributors license=Apache author=HugoRCD -->
<!-- automd:contributors license=Apache author=HugoRCD github="mockline/mockline" -->

Published under the [APACHE](https://github.com/mockline/mockline/blob/main/LICENSE) license.
Made by [@HugoRCD](https://github.com/HugoRCD) and [community](https://github.com/mockline/mockline/graphs/contributors) 💛
Expand All @@ -117,6 +117,6 @@ Made by [@HugoRCD](https://github.com/HugoRCD) and [community](https://github.co

---

_🤖 auto updated with [automd](https://automd.unjs.io) (last updated: Wed May 22 2024)_
_🤖 auto updated with [automd](https://automd.unjs.io) (last updated: Mon Jun 03 2024)_

<!-- /automd -->
2 changes: 1 addition & 1 deletion packages/mockline/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mockline",
"version": "0.1.0",
"version": "0.1.1",
"type": "module",
"exports": {
".": {
Expand Down
9 changes: 4 additions & 5 deletions packages/mockline/playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<script setup lang="ts">
</script>

<template>
<div class="bg-canvas text-gray-12 min-h-screen">
<Html class="bg-canvas text-gray-12 min-h-screen">
<NuxtLoadingIndicator />
<NuxtLayout>
<NuxtPage />
</NuxtLayout>
<MToasts
position="top-center"
close-button
:toast-options="{
style: {
borderColor: 'var(--canvas-5)',
backgroundColor: 'var(--canvas-2)'
}
}"
/>
</div>
</Html>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Button
description: 'Learn how to use the Button component in your application.'
---

## Button

7 changes: 7 additions & 0 deletions packages/mockline/playground/content/2.components/2.switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
title: Switch
description: 'Learn how to use the Switch component in your application.'
---

## Switch

48 changes: 9 additions & 39 deletions packages/mockline/playground/layouts/docs.vue
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
<script setup lang="ts">
import { withoutTrailingSlash } from 'ufo'
const route = useRoute()
const { data: page } = await useAsyncData(route.path, () => queryContent(route.path).findOne())
const [prev, next] = await queryContent()
.where({
_extension: 'md',
_path: {
$exists: true,
},
navigation: {
$ne: false
},
})
.only(['title', '_path'])
.findSurround(withoutTrailingSlash(route.path))
</script>

<template>
<div>
<div class="bg-canvas-3 flex items-center justify-between p-4">
<NuxtLink to="/" class="i-custom-mockline size-6" />
<MThemeToggle />
</div>
<Header :height="16">
<template #left>
<NuxtLink to="/" class="i-custom-mockline size-6" />
</template>
<template #right>
<MThemeToggle />
</template>
</Header>
<Main>
<Page>
<template #right>
<div class="flex flex-col gap-2">
<h3 class="text-gray-12 text-2xl font-bold">
Table of Contents
</h3>
<MContentToc :links="page?.body?.toc?.links" />
</div>
</template>
<div>
<slot />
</div>
<MContentSurround :next :prev />
</Page>
<slot />
</Main>
</div>
</template>
38 changes: 31 additions & 7 deletions packages/mockline/playground/pages/[...slug].vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { withoutTrailingSlash } from 'ufo'
definePageMeta({
layout: 'docs'
})
Expand All @@ -9,14 +11,36 @@ const { data: page } = await useAsyncData(route.path, () => queryContent(route.p
if (!page.value) {
throw createError({ statusCode: 404, statusMessage: 'Page not found', fatal: true })
}
const [prev, next] = await queryContent()
.where({
_extension: 'md',
_path: {
$exists: true,
},
navigation: {
$ne: false
},
})
.only(['title', '_path'])
.findSurround(withoutTrailingSlash(route.path))
const { data: nav } = await useAsyncData('navigation', () => fetchContentNavigation())
</script>

<template>
<div>
<div v-if="page">
<PageBody class="p-4" prose>
<ContentRenderer v-if="page.body" :value="page" />
</PageBody>
</div>
</div>
<Page v-if="page">
<template #left>
<Aside>
<MContentNavigationTree :links="nav" />
</Aside>
</template>
<template #right>
<MContentToc :links="page?.body?.toc?.links" />
</template>
<PageBody class="p-4" prose>
<ContentRenderer v-if="page.body" :value="page" />
</PageBody>
<MContentSurround :next :prev />
</Page>
</template>
4 changes: 2 additions & 2 deletions packages/mockline/playground/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ const components = ['button', 'nav-menu', 'page']
</li>
</ul>
<div class="space-x-4">
<NuxtLink to="/intro">
<NuxtLink to="/getting-started/intro">
<button class="rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700">
Intro
</button>
</NuxtLink>
<NuxtLink to="/installation">
<NuxtLink to="/getting-started/installation">
<button class="rounded-md bg-blue-600 px-4 py-2 text-white hover:bg-blue-700">
Installation
</button>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<script setup lang="ts">
import { computed } from 'vue'
export type NavigationTree = {
title: string
_path: string
children: NavigationTree[]
}
export type NavigationTreeGroup = {
title: string
children: NavigationTree[]
}
export type NavigationTreeProps = {
links: NavigationTreeGroup[]
class?: string
}
const props = withDefaults(defineProps<NavigationTreeProps>(), {
links: () => []
})
</script>

<template>
<nav v-if="links?.length" class="space-y-3">
<template v-for="(link, index) in links" :key="index">
<div>
<h3 class="truncate text-sm/6 font-semibold">
{{ link.title }}
</h3>
<ul class="flex flex-col gap-1">
<li v-for="(child, index) in link.children" :key="index">
<NuxtLink :to="child._path" class="text-gray-11 hover:text-primary-11 text-sm/6" :class="$route.path === child._path ? 'text-primary' : ''">
{{ child.title }}
</NuxtLink>
</li>
</ul>
</div>
</template>
</nav>
</template>
32 changes: 21 additions & 11 deletions packages/mockline/src/runtime/components/content/ContentToc.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
<script setup lang="ts">
import type { PropType } from 'vue'
import type { TocLink } from '@nuxt/content/dist/runtime/types'
const props = defineProps({
links: {
type: Array as PropType<TocLink[]>,
default: () => []
},
export type ContentTocProps = {
title?: string
links: TocLink[]
}
withDefaults(defineProps<ContentTocProps>(), {
title: 'Table of Contents',
links: () => []
})
</script>

<template>
<ul class="list-none">
<li v-for="link in links" :key="link.id">
<span>{{ link.text }}</span>
</li>
</ul>
<nav class="sticky top-[--header-height] max-h-[calc(100vh-var(--header-height))] overflow-y-auto">
<div>
<slot name="top" />

<button v-if="links?.length" tabindex="-1" class="group flex w-full items-center gap-1.5 lg:cursor-text lg:select-text">
<span class="truncate text-sm/6 font-semibold">{{ title }}</span>
</button>

<MContentTocLinks :links />

<slot name="bottom" />
</div>
</nav>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<script setup lang="ts">
import type { TocLink } from '@nuxt/content/dist/runtime/types'
import { useScrollspy } from '#mockline/composables/useScrollSpy'
import { useNuxtApp, useRouter } from '#imports'
const { activeHeadings, updateHeadings } = useScrollspy()
export type ContentTocProps = {
title?: string
links: TocLink[]
active?: string
}
withDefaults(defineProps<ContentTocProps>(), {
title: 'Table of Contents',
links: () => []
})
const nuxtApp = useNuxtApp()
const router = useRouter()
nuxtApp.hooks.hookOnce('page:finish', () => {
updateHeadings([
...document.querySelectorAll('h2'),
...document.querySelectorAll('h3')
])
})
const emit = defineEmits(['move'])
const scrollToHeading = (id: string): void => {
const encodedId = encodeURIComponent(id)
router.push(`#${encodedId}`)
emit('move', id)
}
</script>

<template>
<ul v-if="links?.length">
<li v-for="link in links" :key="link.text" :class="link.depth === 3 ? 'ml-3' : ''">
<a
class="block truncate text-sm/6"
:class="activeHeadings.includes(link.id) ? 'text-primary' : 'text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200'"
:href="`#${link.id}`"
@click.prevent="scrollToHeading(link.id)"
>
{{ link.text }}
</a>

<MContentTocLinks v-if="link.children" :links="link.children" />
</li>
</ul>
</template>
13 changes: 13 additions & 0 deletions packages/mockline/src/runtime/components/layout/Aside.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script setup lang="ts">
</script>

<template>
<aside class="sticky top-[--header-height] overflow-y-auto">
<div class="relative">
<slot />

<slot name="bottom" />
</div>
</aside>
</template>
Loading

0 comments on commit 6ad8dc8

Please sign in to comment.