Skip to content

Commit a76e71b

Browse files
committed
feat: enhance Nimiq theme with Git changelog integration and update dependencies
1 parent 98d82e9 commit a76e71b

File tree

19 files changed

+699
-677
lines changed

19 files changed

+699
-677
lines changed

docs/.vitepress/config.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { NimiqVitepressThemeConfig } from 'nimiq-vitepress-theme'
1+
import type { NimiqVitepressThemeConfig } from 'nimiq-vitepress-theme/types.js'
22
import type { UserConfig } from 'vitepress'
33
import { transformerTwoslash } from '@shikijs/vitepress-twoslash'
44
import { createFileSystemTypesCache } from '@shikijs/vitepress-twoslash/cache-fs'
@@ -33,10 +33,12 @@ export default defineConfigWithTheme<NimiqVitepressThemeConfig>({
3333
items: [
3434
{ text: 'Palette', link: '/nimiq-css/palette', icon: 'i-tabler:palette ' },
3535
{ text: 'Utilities', link: '/nimiq-css/utilities', icon: 'i-tabler:building-factory-2 ' },
36-
{ text: 'Typography', icon: 'i-nimiq:file-text ', items: [
37-
{ text: 'Getting started', link: '/nimiq-css/typography' },
38-
{ text: 'Example', link: '/nimiq-css/typography/demo-article' },
39-
] },
36+
{
37+
text: 'Typography', icon: 'i-nimiq:file-text ', items: [
38+
{ text: 'Getting started', link: '/nimiq-css/typography' },
39+
{ text: 'Example', link: '/nimiq-css/typography/demo-article' },
40+
]
41+
},
4042
{
4143
text: 'CSS Layers',
4244
icon: 'i-tabler:binary-tree ',

docs/.vitepress/theme/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import TwoslashFloatingVue from '@shikijs/vitepress-twoslash/client'
22

3-
import { defineNimiqThemeConfig } from 'nimiq-vitepress-theme'
3+
import { defineNimiqThemeConfig } from 'nimiq-vitepress-theme/client.js'
44

55
import ComponentPreview from './components/ComponentPreview.vue'
66

docs/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@
2424
"devDependencies": {
2525
"@iconify-json/nimiq": "https://pkg.pr.new/onmax/nimiq-ui/nimiq-icons@8db5bac",
2626
"@iconify-json/simple-icons": "^1.2.27",
27+
"@nolebase/vitepress-plugin-git-changelog": "catalog:",
2728
"@iconify-json/tabler": "^1.2.16",
2829
"@iconify/utils": "catalog:",
2930
"@shikijs/vitepress-twoslash": "^3.1.0",
31+
"unocss-preset-scale-px": "^1.0.0-beta.13",
3032
"@unocss/reset": "catalog:",
3133
"@vueuse/core": "^12.7.0",
3234
"nimiq-css": "workspace:*",

docs/uno.config.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { PresetWind3Theme } from 'unocss'
22
import { createExternalPackageIconLoader } from '@iconify/utils/lib/loader/external-pkg'
3-
import { defineConfig, presetIcons, transformerDirectives } from 'unocss'
4-
import { presetFluidSizing } from 'unocss-preset-fluid-sizing'
3+
import { defineConfig, presetIcons, presetWind3, transformerDirectives } from 'unocss'
54
import { presetOnmax } from 'unocss-preset-onmax'
65
import { FileSystemIconLoader } from 'unplugin-icons/loaders'
76
import { presetNimiq } from '../packages/nimiq-css/src/index'
7+
import { presetScalePx } from 'unocss-preset-scale-px'
88

99
export default defineConfig<PresetWind3Theme>({
1010
content: {
@@ -14,7 +14,11 @@ export default defineConfig<PresetWind3Theme>({
1414
['stack', 'w-full grid grid-cols-1 grid-rows-1 children:row-span-full children:col-span-full children:self-center children:justify-self-center'],
1515
],
1616
presets: [
17-
presetOnmax(),
17+
presetWind3(),
18+
presetScalePx({ spacing: { DEFAULT: '0.0625rem' } }),
19+
presetOnmax({
20+
presets: { wind4: false }
21+
}),
1822
presetNimiq({
1923
utilities: true,
2024
attributifyUtilities: true,
@@ -24,7 +28,6 @@ export default defineConfig<PresetWind3Theme>({
2428
},
2529
typography: true,
2630
}),
27-
presetFluidSizing(),
2831
presetIcons({
2932
collections: {
3033
...createExternalPackageIconLoader('@iconify-json/nimiq'),

docs/vite.config.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import type { Plugin } from 'vite'
22
import { dirname, resolve } from 'node:path'
3+
import { GitChangelog } from "@nolebase/vitepress-plugin-git-changelog/vite";
34

45
import { fileURLToPath } from 'node:url'
56
import UnoCSS from 'unocss/vite'
67

78
import { defineConfig } from 'vite'
89
import Inspect from 'vite-plugin-inspect'
910
import VueDevTools from 'vite-plugin-vue-devtools'
11+
import NimiqVitepressVite from '../packages/nimiq-vitepress-theme/src/vite'
1012

1113
const __filename = fileURLToPath(import.meta.url)
1214
const __dirname = dirname(__filename)
1315

1416
export default defineConfig({
15-
optimizeDeps: {
16-
exclude: [
17-
'vitepress',
18-
],
19-
},
2017
resolve: {
2118
alias: {
2219
'nimiq-vitepress-theme': resolve(__dirname, '../packages/nimiq-vitepress-theme/src/'),
@@ -29,5 +26,12 @@ export default defineConfig({
2926
outputDir: '.vite-inspect',
3027
}),
3128
UnoCSS(),
29+
30+
GitChangelog({
31+
repoURL: 'https://github.com/onmax/nimiq-ui'
32+
}),
33+
NimiqVitepressVite({
34+
repoURL: 'https://github.com/onmax/nimiq-ui'
35+
})
3236
],
3337
})

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@
3535
"pnpm": {
3636
"overrides": {
3737
"vite": "catalog:"
38+
},
39+
"patchedDependencies": {
40+
"@nolebase/vitepress-plugin-git-changelog": "patches/@nolebase__vitepress-plugin-git-changelog.patch"
3841
}
3942
},
4043
"simple-git-hooks": {

packages/nimiq-vitepress-theme/package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
"require": "./dist/index.js"
3030
},
3131
"./style.css": "./dist/assets/index.css",
32+
"./vite": {
33+
"types": "./dist/vite.d.ts",
34+
"import": "./dist/vite.mjs",
35+
"require": "./dist/vite.js"
36+
},
3237
"./*": {
3338
"types": "./dist/*",
3439
"import": "./dist/*.mjs",
@@ -63,8 +68,9 @@
6368
"vitepress": "^1.5.0 || ^2.0.0-alpha.3"
6469
},
6570
"dependencies": {
66-
"@iconify-json/nimiq": "https://pkg.pr.new/onmax/nimiq-ui/nimiq-icons@24e0317",
71+
"nimiq-icons": "workspace:*",
6772
"@iconify-json/tabler": "^1.2.16",
73+
"@nolebase/vitepress-plugin-git-changelog": "catalog:",
6874
"@vueuse/core": "^12.7.0",
6975
"mark.js": "^8.11.1",
7076
"minisearch": "^7.1.2",
@@ -85,7 +91,6 @@
8591
"typescript": "catalog:",
8692
"unbuild": "^3.3.1",
8793
"unocss": "catalog:",
88-
"unocss-preset-fluid-sizing": "catalog:",
8994
"unocss-preset-onmax": "catalog:",
9095
"unplugin-vue-components": "^28.4.0"
9196
}

packages/nimiq-vitepress-theme/src/composables/useOutline.ts renamed to packages/nimiq-vitepress-theme/src/composables/useSecondarySidebar.ts

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { useThrottleFn } from '@vueuse/core'
2-
import { getScrollOffset } from 'vitepress'
3-
import { onMounted, onUnmounted, onUpdated, ref } from 'vue'
2+
import { getScrollOffset, useData } from 'vitepress'
3+
import { computed, onMounted, onUnmounted, onUpdated, ref } from 'vue'
4+
import type { NimiqVitepressThemeConfig } from '../types'
45

56
export interface HeadingItem {
67
hashPath: string
@@ -41,7 +42,7 @@ function getAbsoluteTop(element: HTMLElement): number {
4142
return offsetTop
4243
}
4344

44-
export function useOutline() {
45+
export function useSecondarySidebar() {
4546
const headingTree = ref<HeadingTree[]>([])
4647
const activeHeadingIds = ref<string[]>([])
4748

@@ -133,7 +134,33 @@ export function useOutline() {
133134
window.removeEventListener('scroll', onScroll)
134135
})
135136

137+
const { frontmatter } = useData<NimiqVitepressThemeConfig>()
138+
const showOutline = computed(() => {
139+
// Explicit setting in frontmatter takes precedence
140+
if (frontmatter.value.outline !== undefined)
141+
return !!frontmatter.value.outline
142+
// Default: show if there are headings
143+
return headingTree.value.length > 0
144+
})
145+
146+
const showWidget = computed(() => frontmatter.value.widget !== false)
147+
148+
const showSecondarySidebar = computed(() => {
149+
const { secondarySidebar } = frontmatter.value
150+
151+
// Explicit setting in frontmatter takes precedence
152+
if (secondarySidebar !== undefined)
153+
return !!secondarySidebar
154+
// Default: show if there are headings
155+
return showOutline.value || showWidget.value
156+
})
157+
158+
159+
136160
return {
161+
showSecondarySidebar,
162+
showOutline,
163+
showWidget,
137164
headingTree,
138165
activeHeadingIds,
139166
isHeadingActive: (hashPath: string) => activeHeadingIds.value.includes(hashPath),
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<script setup lang="ts">
2+
import { useChangelog } from '@nolebase/vitepress-plugin-git-changelog/client/composables/changelog';
3+
import { onMounted } from 'vue';
4+
5+
const { authors, useHmr } = useChangelog();
6+
7+
onMounted(useHmr)
8+
</script>
9+
10+
<template>
11+
<h2>
12+
{{ 'Contributors' }}
13+
<a class="header-anchor" mt-6 href="#contributors" aria-label="Permalink to Contributors" />
14+
</h2>
15+
<div flex="~ wrap gap-16">
16+
<em v-if="!authors.length">
17+
No contributors available.
18+
</em>
19+
<template v-else>
20+
<template v-for="c of authors" :key="c.name">
21+
<a v-if="(typeof c.url !== 'undefined')" :href="c.url" flex="~ items-center gap-8">
22+
<img :src="c.avatarUrl" :alt="`The avatar of contributor named as ${c.name}`" f-size-lg rounded-full>
23+
{{ c.name }}
24+
</a>
25+
<div v-else flex="~ items-center gap-8">
26+
<img :src="c.avatarUrl" :alt="`The avatar of contributor named as ${c.name}`" f-size-lg rounded-full>
27+
{{ c.name }}
28+
</div>
29+
</template>
30+
</template>
31+
</div>
32+
</template>

0 commit comments

Comments
 (0)