Skip to content

Commit 62e6d9c

Browse files
authored
chore(*): create vitepress website prototype (#14)
This pull request includes significant updates to the `eslint-plugin-mark` package and the VitePress site configuration. The changes include adding new configurations, improving documentation, and enhancing the VitePress theme. ### VitePress Site Configuration: * [`website/.vitepress/config.js`](diffhunk://#diff-44d6965b3c2f9329fe9aacf68bd5c4f638b1ff0d4b1b08649486193c906d68d1R1-R292): Added a comprehensive site configuration including metadata, routing, theming, and plugins to enhance the VitePress site. * [`website/.vitepress/theme/index.js`](diffhunk://#diff-ad87dc71875fb22dd87369888cf1745d026de7048d6cd2ebe18c3c16751dbdbeR1-R32): Introduced a custom theme entry file with additional global properties for emoji support. * [`website/.vitepress/theme/style.css`](diffhunk://#diff-6759218b54439d3be31de7fd72687fb762da52e8a4a2d0f818851dd0e8d55f7fR1-R90): Customized default theme styling by overriding CSS variables and adding specific styles for the home page and markdown documents. ### Documentation Enhancements: * [`website/docs/community/*.md`](diffhunk://#diff-e56920e18dcaac63e4260badc2e7e7dad963028a39eaee15b96fc19118d5523dR1): Included external markdown files such as `CHANGELOG.md`, `CODE_OF_CONDUCT.md`, `CONTRIBUTING.md`, `LICENSE.md`, and `SECURITY.md` to improve the community documentation. [[1]](diffhunk://#diff-e56920e18dcaac63e4260badc2e7e7dad963028a39eaee15b96fc19118d5523dR1) [[2]](diffhunk://#diff-2042778554ba4b5e4fb904c00f7d600edfdfd0a17bb8c217be3b5a021fa09d87R1) [[3]](diffhunk://#diff-53afc90099438fd8dbb1c539a5c30e961c5c497d8a58a98f8a5f0d3a16020016R1) [[4]](diffhunk://#diff-186476bfd701bd77d5f0425514972df9179634bbde91a6f32cd77678c20ecdb8R1) [[5]](diffhunk://#diff-a572858d9474967ece822a81dba2ac16d42c405aa3658195366b118a579bf83eR1) * [`website/docs/get-started/*.md`](diffhunk://#diff-5d3786b57553e4f6aa433dbc0439a0000b2f32d8b2b240b8dfbd3973ebb4411bR1-R70): Added detailed sections for configurations, dependency versions, installation, introduction, and versioning to provide a comprehensive guide for users. [[1]](diffhunk://#diff-5d3786b57553e4f6aa433dbc0439a0000b2f32d8b2b240b8dfbd3973ebb4411bR1-R70) [[2]](diffhunk://#diff-e96558082390e38b1c5e2e3df94bced778e823b82720535a6a7728a4790caf0eR1-R19) [[3]](diffhunk://#diff-5c932f6df78484172c717421fffc4ef01f10355cd96ebd8b86b65e02b39f99b3R1-R8) [[4]](diffhunk://#diff-085b09b29480db7b6f10994f8f7f227fa520c8878d8781cb37a282658383eba0R1-R31) [[5]](diffhunk://#diff-aeb0fea669d0b87f99bf331106ddc13e198f254aa732266a2435acf9a98f82aaR1-R15) [[6]](diffhunk://#diff-1320cdd0a36ffc0b5bf5052ddf81af8592e7d45c36a5afd0b23d6630322a0611R1-R5) ### ESLint Plugin Configuration: * [`packages/eslint-plugin-mark/package.json`](diffhunk://#diff-9b9400561d26b4f60200e53b8fbb54b0ef18955f8348a54f396c6ac386667a0dR11-R14): Updated the package configuration to include new rules and types for better type definitions and module resolution. [[1]](diffhunk://#diff-9b9400561d26b4f60200e53b8fbb54b0ef18955f8348a54f396c6ac386667a0dR11-R14) [[2]](diffhunk://#diff-9b9400561d26b4f60200e53b8fbb54b0ef18955f8348a54f396c6ac386667a0dR24-R26) ### Rule Metadata and Data Loading: * [`website/docs/rules/index.data.js`](diffhunk://#diff-46eb8c4dcb2999cb485b9567fe49db73543c4436c723e51a612b9e1b837219ffR1-R55): Added build-time data loading for rules to dynamically generate rule metadata and improve the documentation of rules. These changes collectively enhance the functionality, usability, and documentation of the `eslint-plugin-mark` package and its associated VitePress site.
1 parent 61fef8b commit 62e6d9c

35 files changed

+14753
-10806
lines changed

package-lock.json

Lines changed: 13953 additions & 10795 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/eslint-plugin-mark/package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
"types": "./build/index.d.ts",
99
"default": "./src/index.js"
1010
},
11+
"./rules": {
12+
"types": "./build/rules/index.d.ts",
13+
"default": "./src/rules/index.js"
14+
},
1115
"./package.json": "./package.json"
1216
},
1317
"typesVersions": {
@@ -17,6 +21,9 @@
1721
],
1822
".": [
1923
"./build/index.d.ts"
24+
],
25+
"./rules": [
26+
"./build/rules/index.d.ts"
2027
]
2128
}
2229
},

website/.gitkeep

Whitespace-only changes.

website/.vitepress/config.js

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
/**
2+
* @fileoverview Vitepress site configuration.
3+
*
4+
* @see https://vitepress.dev/reference/site-config#site-config
5+
*/
6+
7+
// --------------------------------------------------------------------------------
8+
// Import
9+
// --------------------------------------------------------------------------------
10+
11+
import { parse } from 'node:path';
12+
13+
import { generateGoogleAnalyticsScript } from 'bananass-utils-vitepress/head';
14+
import footnote from 'markdown-it-footnote';
15+
import { defineConfig } from 'vitepress';
16+
import { groupIconMdPlugin, groupIconVitePlugin } from 'vitepress-plugin-group-icons';
17+
import { codecovVitePlugin } from '@codecov/vite-plugin';
18+
import isInteractive from 'is-interactive';
19+
import rules from 'eslint-plugin-mark/rules';
20+
21+
// --------------------------------------------------------------------------------
22+
// Constants
23+
// --------------------------------------------------------------------------------
24+
25+
const TITLE = 'eslint-plugin-mark';
26+
const DESCRIPTION = 'Lint your Markdown with ESLint.🛠️';
27+
const AUTHOR = '루밀LuMir';
28+
const SITE_URL = 'https://eslint-plugin-mark.lumir.page';
29+
const GITHUB_URL = 'https://github.com/lumirlumir/npm-eslint-plugin-mark';
30+
const NPM_URL = 'https://www.npmjs.com';
31+
const GOOGLE_GA_ID = 'G-9KLYX5PTLT';
32+
33+
// --------------------------------------------------------------------------------
34+
// Export
35+
// --------------------------------------------------------------------------------
36+
37+
export default defineConfig({
38+
/* Site Metadata */
39+
title: TITLE,
40+
description: DESCRIPTION,
41+
head: [
42+
// Basic
43+
['link', { rel: 'icon', href: '/logo.svg', type: 'image/svg+xml' }],
44+
['link', { rel: 'icon', href: '/logo-small.png', type: 'image/png' }],
45+
['link', { rel: 'icon', href: '/favicon.ico', type: 'image/x-icon' }],
46+
['meta', { name: 'title', content: TITLE }],
47+
['meta', { name: 'theme-color', content: '#a0a0f5' }],
48+
['meta', { name: 'author', content: AUTHOR }],
49+
[
50+
'meta',
51+
{
52+
name: 'keywords',
53+
content: 'eslint, plugin, mark, markdown, lint, linting, eslint-plugin-mark',
54+
},
55+
],
56+
57+
// Open Graph
58+
['meta', { property: 'og:type', content: 'website' }],
59+
['meta', { property: 'og:url', content: SITE_URL }],
60+
['meta', { property: 'og:title', content: TITLE }],
61+
['meta', { property: 'og:description', content: DESCRIPTION }],
62+
['meta', { property: 'og:image', content: `${SITE_URL}/logo-og.png` }],
63+
['meta', { property: 'og:image:width', content: '1280' }],
64+
['meta', { property: 'og:image:height', content: '640' }],
65+
['meta', { property: 'og:site_name', content: TITLE }],
66+
['meta', { property: 'og:article:author', content: AUTHOR }],
67+
68+
// Twitter
69+
['meta', { name: 'twitter:url', content: SITE_URL }],
70+
['meta', { name: 'twitter:title', content: TITLE }],
71+
['meta', { name: 'twitter:description', content: DESCRIPTION }],
72+
['meta', { name: 'twitter:image', content: `${SITE_URL}/logo-og.png` }],
73+
['meta', { name: 'twitter:creator', content: AUTHOR }],
74+
['meta', { name: 'twitter:card', content: 'summary_large_image' }],
75+
76+
// Google Analytics
77+
...generateGoogleAnalyticsScript(GOOGLE_GA_ID),
78+
],
79+
lang: 'en-US',
80+
81+
/* Routing */
82+
cleanUrls: true,
83+
84+
/* Build */
85+
outDir: 'build',
86+
metaChunk: true,
87+
88+
/* Theming */
89+
lastUpdated: true,
90+
91+
/* Sitemap */
92+
sitemap: {
93+
hostname: SITE_URL,
94+
},
95+
96+
/* Theme Configuration */
97+
themeConfig: {
98+
logo: {
99+
src: '/logo.svg',
100+
alt: 'eslint-plugin-mark Logo',
101+
},
102+
103+
outline: {
104+
level: 'deep',
105+
},
106+
107+
nav: [
108+
// TODO: From here
109+
{
110+
text: 'Get Started',
111+
activeMatch: '/docs/(?:get-started|community)',
112+
items: [
113+
{
114+
text: 'Get Started',
115+
link: '/docs/get-started',
116+
activeMatch: '/docs/get-started',
117+
},
118+
{
119+
text: 'Community',
120+
link: '/docs/community/code-of-conduct',
121+
activeMatch: '/docs/community',
122+
},
123+
],
124+
},
125+
{
126+
text: 'Rules',
127+
link: '/docs/rules',
128+
activeMatch: '/docs/rules',
129+
},
130+
{
131+
text: 'Configs',
132+
link: '/docs/get-started/configurations',
133+
activeMatch: '/docs/get-started/configurations',
134+
},
135+
],
136+
137+
sidebar: {
138+
'/docs/rules/': [
139+
{
140+
base: '/docs/rules/',
141+
text: 'Rules',
142+
link: '/',
143+
collapsed: false,
144+
items: Object.keys(rules).map(ruleName => ({
145+
text: ruleName,
146+
link: ruleName,
147+
})),
148+
},
149+
],
150+
151+
'/docs/': [
152+
{
153+
base: '/docs/get-started/',
154+
text: 'Get Started',
155+
link: '/',
156+
collapsed: false, // Set it `false` to show `>` icon.
157+
items: [
158+
{
159+
text: 'Introduction',
160+
link: 'introduction',
161+
},
162+
{
163+
text: 'Installation',
164+
link: 'installation',
165+
},
166+
{
167+
text: 'Configurations',
168+
link: 'configurations',
169+
},
170+
{
171+
text: 'Dependency Versions',
172+
link: 'dependency-versions',
173+
},
174+
{
175+
text: 'Versioning',
176+
link: 'versioning',
177+
},
178+
],
179+
},
180+
181+
{
182+
base: '/docs/community/',
183+
text: 'Community',
184+
collapsed: true,
185+
items: [
186+
{
187+
text: 'Code of Conduct',
188+
link: 'code-of-conduct',
189+
},
190+
{
191+
text: 'Contributing',
192+
link: 'contributing',
193+
},
194+
{
195+
text: 'Change Log',
196+
link: 'change-log',
197+
},
198+
{
199+
text: 'Security',
200+
link: 'security',
201+
},
202+
{
203+
text: 'License',
204+
link: 'license',
205+
},
206+
],
207+
},
208+
],
209+
},
210+
211+
socialLinks: [
212+
{
213+
icon: 'npm',
214+
link: `${NPM_URL}/package/eslint-plugin-mark`,
215+
ariaLabel: 'npm package link for eslint-plugin-mark',
216+
},
217+
{
218+
icon: 'github',
219+
link: GITHUB_URL,
220+
ariaLabel: 'GitHub repository link for eslint-plugin-mark',
221+
},
222+
],
223+
224+
editLink: {
225+
pattern: `${GITHUB_URL}/edit/main/website/:path`,
226+
text: 'Edit this page on GitHub',
227+
},
228+
229+
search: {
230+
provider: 'local',
231+
},
232+
233+
footer: {
234+
message: 'Released under the MIT License.',
235+
copyright: `Copyright © 2024-${new Date().getFullYear()} <a href="https://github.com/lumirlumir">${AUTHOR}(lumirlumir)</a>`,
236+
},
237+
},
238+
239+
markdown: {
240+
config(md) {
241+
md.use(footnote);
242+
md.use(groupIconMdPlugin);
243+
},
244+
},
245+
246+
vite: {
247+
plugins: [
248+
groupIconVitePlugin(),
249+
codecovVitePlugin({
250+
// Put the Codecov vite plugin after all other plugins
251+
enableBundleAnalysis: !isInteractive(), // Works only in CI
252+
bundleName: 'website',
253+
uploadToken: process.env.CODECOV_TOKEN,
254+
gitService: 'github',
255+
}),
256+
],
257+
},
258+
259+
transformPageData(pageData) {
260+
// Process only the files inside `docs/rules/`, excluding `index.md`.
261+
if (/^docs\/rules\/(?!index).+/.test(pageData.relativePath)) {
262+
const ruleName = parse(pageData.relativePath).name;
263+
const rule = rules[ruleName];
264+
265+
pageData.title = ruleName;
266+
pageData.frontmatter.title = ruleName;
267+
pageData.frontmatter.rule = `
268+
269+
<p>
270+
${(rule.meta.docs.recommended ?? false) ? '<code class="rule-emoji">✅ Recommended</code>' : ''}
271+
${(rule.meta.fixable ?? false) ? '<code class="rule-emoji">🔧 Fixable</code>' : ''}
272+
${(rule.meta.docs.suggestion ?? false) ? '<code class="rule-emoji">💡 Suggestion</code>' : ''}
273+
${(rule.meta.dialects.includes('commonmark') ?? false) ? '<code class="rule-emoji">⭐ CommonMark</code>' : ''}
274+
${(rule.meta.dialects.includes('gfm') ?? false) ? '<code class="rule-emoji">🌟 GFM</code>' : ''}
275+
</p>
276+
<p>
277+
${(rule.meta.docs.description ?? '')
278+
.split(/(`[^`]+`)/)
279+
.map(part =>
280+
part.startsWith('`') && part.endsWith('`')
281+
? `<code>${part.slice(1, -1)}</code>`
282+
: part,
283+
)
284+
.join('')}.
285+
</p>
286+
287+
`;
288+
}
289+
290+
return pageData;
291+
},
292+
});

website/.vitepress/theme/index.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* @fileoverview VitePress theme entry file.
3+
*
4+
* @see https://vitepress.dev/guide/custom-theme#using-a-custom-theme
5+
*/
6+
7+
// --------------------------------------------------------------------------------
8+
// Import
9+
// --------------------------------------------------------------------------------
10+
11+
import theme from 'vitepress/theme';
12+
13+
import './style.css';
14+
import 'virtual:group-icons.css'; // eslint-disable-line n/no-missing-import
15+
16+
// --------------------------------------------------------------------------------
17+
// Export
18+
// --------------------------------------------------------------------------------
19+
20+
/** @type {import('vitepress').Theme} */
21+
export default {
22+
...theme,
23+
enhanceApp({ app }) {
24+
app.config.globalProperties.$emoji = {
25+
recommended: '✅',
26+
fixable: '🔧',
27+
suggestion: '💡',
28+
commonmark: '⭐',
29+
gfm: '🌟',
30+
};
31+
},
32+
};

0 commit comments

Comments
 (0)