Skip to content

Commit b39461b

Browse files
committed
feat: update vitepress, theme and add contributors handling
1 parent f4c588d commit b39461b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4431
-3555
lines changed

.vitepress/config.mts

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
import { defineConfig } from 'vitepress'
2+
import apiSidebar from '../content/api/sidebar.json'
3+
import mainSidebar from '../content/sidebar'
4+
import nav from './nav'
5+
import './theme/cliLanguage'
6+
7+
export default defineConfig({
8+
srcDir: './content',
9+
lang: 'en-US',
10+
title: 'NativeScript',
11+
description: 'NativeScript docs',
12+
ignoreDeadLinks: true,
13+
cleanUrls: true,
14+
lastUpdated: true,
15+
appearance: false,
16+
themeConfig: {
17+
editLink: {
18+
// pattern:
19+
// 'https://github.com/NativeScript/docs/blob/main/content/:filePath',
20+
pattern:
21+
'https://pr.new/github.com/NativeScript/docs/edit/main/content/:filePath?initialPath=:path',
22+
},
23+
algolia: {
24+
appId: '',
25+
apiKey: '8d41b4ae92a02aea355e1dc8cfad1899',
26+
indexName: 'nativescript',
27+
},
28+
nav,
29+
sidebar: {
30+
'/api': apiSidebar,
31+
'/': mainSidebar,
32+
},
33+
},
34+
markdown: {
35+
headers: true,
36+
},
37+
async transformPageData(pageData, { siteConfig }) {
38+
// const contributors = await githubAuthors.getAuthorsForFilePath(
39+
// path.resolve(siteConfig.srcDir, pageData.relativePath)
40+
// )
41+
// pageData.frontmatter.contributors ??= contributors ?? []
42+
43+
pageData.frontmatter.contributors = transformContributors(
44+
pageData.frontmatter.contributors
45+
)
46+
},
47+
})
48+
49+
function transformContributors(contributors?: string[] | false) {
50+
// explicitly set to false to disable contributors list
51+
if (contributors === false) {
52+
return []
53+
}
54+
55+
// if not set, default to NativeScript
56+
if (!contributors) {
57+
return [
58+
{
59+
username: 'NativeScript',
60+
avatarURL: 'https://github.com/NativeScript.png?size=24',
61+
profileURL: 'https://github.com/NativeScript',
62+
},
63+
]
64+
}
65+
66+
// otherwise, transform the list of usernames into a list of objects
67+
return contributors.map((username: string) => {
68+
return {
69+
username,
70+
avatarURL: `https://github.com/${username}.png?size=24`,
71+
profileURL: `https://github.com/${username}`,
72+
}
73+
})
74+
}

.vitepress/config.ts

-35
This file was deleted.

.vitepress/theme/style.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.vitepress/theme/vitepress-theme.d.ts

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { DefaultTheme } from 'vitepress';
2+
import { Theme } from 'vitepress';
3+
4+
export declare type NSNavItem = DefaultTheme.NavItem & {
5+
icon?: string;
6+
};
7+
8+
export declare type NSSidebarGroup = DefaultTheme.SidebarItem & {
9+
items?: NSSidebarItem[];
10+
};
11+
12+
export declare type NSSidebarItem = DefaultTheme.SidebarItem & {
13+
icon?: string;
14+
};
15+
16+
export declare type NSThemeConfig = DefaultTheme.Config & {
17+
mainURL?: string;
18+
sidebar?: NSSidebarGroup[];
19+
nav?: NSNavItem[];
20+
};
21+
22+
declare const theme: (enhanceApp: Theme['enhanceApp']) => Theme;
23+
export default theme;
24+
25+
export { }

0 commit comments

Comments
 (0)