valaxy-theme-press 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/setup/main.ts ADDED
@@ -0,0 +1,90 @@
1
+ import { defineAppSetup } from 'valaxy'
2
+ import { nextTick } from 'vue'
3
+
4
+ export default defineAppSetup((ctx) => {
5
+ const { router, isClient } = ctx
6
+ if (!isClient)
7
+ return
8
+
9
+ window.addEventListener(
10
+ 'click',
11
+ (e) => {
12
+ const link = (e.target as Element).closest('a')
13
+ if (link) {
14
+ const { protocol, hostname, pathname, hash, target } = link
15
+ const currentUrl = window.location
16
+ const extMatch = pathname.match(/\.\w+$/)
17
+ // only intercept inbound links
18
+ if (
19
+ !e.ctrlKey
20
+ && !e.shiftKey
21
+ && !e.altKey
22
+ && !e.metaKey
23
+ && target !== '_blank'
24
+ && protocol === currentUrl.protocol
25
+ && hostname === currentUrl.hostname
26
+ && !(extMatch && extMatch[0] !== '.html')
27
+ ) {
28
+ if (pathname === currentUrl.pathname) {
29
+ e.preventDefault()
30
+ // scroll between hash anchors in the same page
31
+ if (hash && hash !== currentUrl.hash) {
32
+ history.pushState(null, '', hash)
33
+ // still emit the event so we can listen to it in themes
34
+ window.dispatchEvent(new Event('hashchange'))
35
+ // use smooth scroll when clicking on header anchor links
36
+ scrollTo(link, hash, link.classList.contains('header-anchor'))
37
+ }
38
+ }
39
+ }
40
+ }
41
+ },
42
+ { capture: true },
43
+ )
44
+
45
+ window.addEventListener('hashchange', (e) => {
46
+ e.preventDefault()
47
+ })
48
+
49
+ router.beforeEach((to, from) => {
50
+ if (to.path !== from.path)
51
+ return
52
+
53
+ nextTick(() => {
54
+ scrollTo(document.body, to.hash, true)
55
+ })
56
+ })
57
+ })
58
+
59
+ function scrollTo(el: HTMLElement, hash: string, smooth = false) {
60
+ let target: Element | null = null
61
+
62
+ try {
63
+ target = el.classList.contains('header-anchor')
64
+ ? el
65
+ : document.querySelector(decodeURIComponent(hash))
66
+ }
67
+ catch (e) {
68
+ console.warn(e)
69
+ }
70
+
71
+ if (target) {
72
+ const targetPadding = -64
73
+ const targetTop
74
+ = window.scrollY
75
+ + (target as HTMLElement).getBoundingClientRect().top
76
+ + targetPadding
77
+
78
+ // only smooth scroll if distance is smaller than screen height.
79
+ if (!smooth || Math.abs(targetTop - window.scrollY) > window.innerHeight) {
80
+ window.scrollTo(0, targetTop)
81
+ }
82
+ else {
83
+ window.scrollTo({
84
+ left: 0,
85
+ top: targetTop,
86
+ behavior: 'smooth',
87
+ })
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,43 @@
1
+ :root {
2
+ --pr-c-indigo-lighter: #c9def1;
3
+ }
4
+
5
+ :root {
6
+ --pr-c-text-code: #374562;
7
+
8
+ // aside
9
+ --pr-aside-text-1: #213547;
10
+ --pr-aside-text-2: #3c3c3cb3;
11
+
12
+ --pr-aside-divider: rgba(60, 60, 60, 0.122);
13
+
14
+ --pr-c-divider-light: rgba(60, 60, 60, 0.12);
15
+
16
+ // nav
17
+ --pr-nav-height: var(--pr-nav-height-mobile);
18
+ --pr-nav-height-mobile: 60px;
19
+
20
+ // z-index
21
+ --va-z-overlay: var(--pr-z-index-backdrop);
22
+ --pr-z-index-nav: 8;
23
+ --pr-z-index-local-nav: 9;
24
+ --pr-z-index-backdrop: 10;
25
+ --pr-z-index-sidebar: 11;
26
+
27
+ // switch
28
+ --pr-switch-divider: rgba(60, 60, 60, 0.29);
29
+ --pr-switch-bg: #f1f1f1;
30
+ }
31
+
32
+ .dark {
33
+ --pr-c-text-code: var(--pr-c-indigo-lighter);
34
+
35
+ // aside
36
+ --pr-aside-text-1: #ffffffde;
37
+ --pr-aside-text-2: #ebebeb99;
38
+ --pr-aside-divider: rgba(84, 84, 84, 0.48);
39
+
40
+ // switch
41
+ --pr-switch-divider: rgba(84, 84, 84, 0.65);
42
+ --pr-switch-bg: #3a3a3a;
43
+ }
@@ -0,0 +1,44 @@
1
+ .gradient-text {
2
+ background-clip: text;
3
+ -webkit-background-clip: text;
4
+ -webkit-text-fill-color: transparent;
5
+ }
6
+
7
+ .sese-btn {
8
+ position: relative;
9
+ z-index: 0;
10
+
11
+ @apply transition;
12
+
13
+ &:hover {
14
+ @apply shadow;
15
+ }
16
+ }
17
+
18
+ .press-icon-btn {
19
+ cursor: pointer;
20
+
21
+ display: inline-flex;
22
+ align-items: center;
23
+ justify-content: center;
24
+
25
+ border: none;
26
+ width: 3rem;
27
+ height: 3rem;
28
+
29
+ border-radius: 50%;
30
+
31
+ transition: background-color var(--va-transition-duration);
32
+
33
+ div {
34
+ font-size: 1.2rem;
35
+ }
36
+
37
+ &:hover {
38
+ background-color: rgba(var(--va-c-primary-rgb), 0.08);
39
+ }
40
+
41
+ &:active {
42
+ background-color: rgba(var(--va-c-primary-rgb), 0.16);
43
+ }
44
+ }
@@ -0,0 +1,7 @@
1
+ @use "./helper.scss";
2
+ @use "./markdown.scss";
3
+
4
+ .layout {
5
+ display: flex;
6
+ flex-direction: column;
7
+ }
@@ -0,0 +1,40 @@
1
+ @use "valaxy/client/styles/mixins" as *;
2
+
3
+ .prose {
4
+ --un-prose-body: var(--va-c-text);
5
+ --un-prose-hr: var(--va-c-text);
6
+ --un-prose-borders: var(--va-c-brand);
7
+ --un-prose-links: var(--va-c-brand);
8
+ --un-prose-code: var(--va-c-text);
9
+ --un-prose-font-mono: var(--va-font-mono);
10
+
11
+ blockquote {
12
+ font-style: normal;
13
+ }
14
+
15
+ a {
16
+ text-decoration: none;
17
+ border-bottom: 1px solid transparent;
18
+ transition: all 0.4s;
19
+
20
+ &:hover {
21
+ border-bottom-color: var(--va-c-brand);
22
+ }
23
+ }
24
+
25
+ code:not(pre > code) {
26
+ color: var(--pr-c-text-code);
27
+ background-color: var(--va-c-bg-mute);
28
+ padding: 3px 6px;
29
+ border-radius: 4px;
30
+ font-weight: 500;
31
+ }
32
+ }
33
+
34
+ @include mobile {
35
+ .markdown-body {
36
+ div[class*="language-"] {
37
+ margin: 0 -1.5rem;
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,5 @@
1
+ export interface Feature {
2
+ icon?: string
3
+ title: string
4
+ details: string
5
+ }
@@ -1,3 +1,6 @@
1
+ export * from '../composables'
2
+ export * from './home.d'
3
+
1
4
  export namespace DocsTheme {
2
5
  export type Config = ThemeConfig
3
6
  export type Sidebar = any
@@ -0,0 +1,36 @@
1
+ import type { ResolvedValaxyOptions } from 'valaxy'
2
+ import { defineTheme } from 'valaxy'
3
+ import type { Plugin } from 'vite'
4
+ import type { ThemeConfig } from './types'
5
+
6
+ function ThemeVitePlugin(options: ResolvedValaxyOptions<ThemeConfig>): Plugin {
7
+ const themeConfig = options.config.themeConfig!
8
+
9
+ return {
10
+ name: 'valaxy-theme-press',
11
+ enforce: 'pre',
12
+ config() {
13
+ return {
14
+ css: {
15
+ preprocessorOptions: {
16
+ scss: {
17
+ additionalData: `$c-primary: ${themeConfig.colors?.primary || '#0078E7'} !default;`,
18
+ },
19
+ },
20
+ },
21
+
22
+ optimizeDeps: {
23
+ exclude: ['@docsearch/js'],
24
+ },
25
+ }
26
+ },
27
+ }
28
+ }
29
+
30
+ export default defineTheme<ThemeConfig>((options) => {
31
+ return {
32
+ vite: {
33
+ plugins: [ThemeVitePlugin(options)],
34
+ },
35
+ }
36
+ })
@@ -1,26 +0,0 @@
1
- <script lang="ts" setup>
2
- import { useConfig } from 'valaxy'
3
-
4
- const config = useConfig()
5
- </script>
6
-
7
- <template>
8
- <div class="pt-6 pb-8 space-y-2 md:space-y-5">
9
- <h1
10
- class="
11
- text-3xl
12
- leading-9
13
- font-extrabold
14
- text-gray-900
15
- tracking-tight
16
- sm:text-4xl sm:leading-10
17
- md:text-6xl md:leading-14
18
- "
19
- >
20
- {{ config.title }}
21
- </h1>
22
- <p class="text-lg leading-7 text-gray-500">
23
- {{ config.subtitle }}
24
- </p>
25
- </div>
26
- </template>
package/pages/index.vue DELETED
@@ -1,8 +0,0 @@
1
- <template>
2
- <PressPostList />
3
- </template>
4
-
5
- <route lang="yaml">
6
- meta:
7
- layout: home
8
- </route>
package/tsup.config.ts DELETED
@@ -1,16 +0,0 @@
1
- import { defineConfig } from 'tsup'
2
-
3
- export default defineConfig((options) => {
4
- return {
5
- entry: ['node/index.ts'],
6
- // disable for dev watch before valaxy watch
7
- clean: !options.watch,
8
- dts: true,
9
- format: ['cjs', 'esm'],
10
- minify: !options.watch,
11
- external: [
12
- 'valaxy',
13
- 'vite',
14
- ],
15
- }
16
- })