Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(en): merge docs-cn/sync-docs into docs-cn/dev @ 8b72e230 #867

Merged
merged 30 commits into from
Nov 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
21a5065
docs: 🇩🇪 added german locale link to config.ts; (#14724)
rojadesign Nov 7, 2023
4ef681f
docs: add note about complex env based replacement (#14899)
patak-dev Nov 7, 2023
deb9fe7
feat(hmr): improve circular import updates (#14867)
bluwy Nov 8, 2023
8ad9f25
docs: clarify origin part of `base` is not used in dev (#14907)
sapphi-red Nov 8, 2023
39f5285
docs(ssr): properly handle vite.middlewares after restart (#14917)
patak-dev Nov 9, 2023
5bb79d0
docs: note skipLibCheck (#14932)
bluwy Nov 10, 2023
3fa6027
docs: update library mode env var tip (#14935)
bluwy Nov 10, 2023
0ef84f2
docs: add mastodon link to sapphi-red (#14940)
sapphi-red Nov 10, 2023
588f0f9
docs: Shinigami92 from X to Mastodon (#14941)
Shinigami92 Nov 10, 2023
92fd640
docs: add v4.vitejs.dev link to nav bar (#14939)
sapphi-red Nov 10, 2023
af2f106
docs(performance): use lesser or native tooling section (#14874)
ArnaudBarre Nov 10, 2023
e4d2400
docs: add back link to ViteConf replay (#14972)
patak-dev Nov 13, 2023
216a5b6
docs: explain node_env and modes (#14978)
bluwy Nov 14, 2023
f249faf
docs(performance): fix barrel file section (#14983)
jay-es Nov 14, 2023
1d1cfe7
docs: update static-deploy.md to support custom domains with GitHub P…
mark-mxwl Nov 14, 2023
7b70370
docs: adjust sponsor logo
yyx990803 Nov 14, 2023
cdc7fd1
feat: allow providing parent httpServer on middleware mode (#14632)
antfu Nov 15, 2023
a034dea
docs: improve why not bundle with esbuild (#14998)
patak-dev Nov 16, 2023
948098c
docs: vite 5 announcement blog post (#14860)
patak-dev Nov 16, 2023
80b75c1
docs: dev vs build target (#14997)
patak-dev Nov 16, 2023
17faadd
docs: remove Vite 5 feedback discussion note (#15008)
patak-dev Nov 16, 2023
b33580a
docs: add blog index page
yyx990803 Nov 17, 2023
3a738c4
docs: temporary css fix for blog index
yyx990803 Nov 17, 2023
17154cd
docs: update vite 5 blog grammar (#15014)
frankkepler Nov 17, 2023
3a58a4e
docs(troubleshooting): note config mts extension (#15017)
bluwy Nov 17, 2023
48d9369
fix: update type CSSModulesOptions interface (#14987)
psychobolt Nov 17, 2023
7c0fcb2
docs: indirect use vite.middlewares in example (#15020)
patak-dev Nov 17, 2023
8b72e23
docs: add a note about `moduleResolution` for rollup 4 (#15023)
sapphi-red Nov 17, 2023
cf35b96
docs(en): merging all conflicts
docschina-bot Nov 17, 2023
9d40428
docs(cn): resolve all conflicts
ShenQingchuan Nov 19, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,61 @@ const ogImage = 'https://vitejs.dev/og-image.png'
const ogTitle = 'Vite'
const ogUrl = 'https://vitejs.dev'

// netlify envs
const deployURL = process.env.DEPLOY_PRIME_URL || ''
const commitRef = process.env.COMMIT_REF?.slice(0, 8) || 'dev'

const deployType = (() => {
switch (deployURL) {
case 'https://main--vite-docs-main.netlify.app':
return 'main'
case '':
return 'local'
default:
return 'release'
}
})()
const additionalTitle = ((): string => {
switch (deployType) {
case 'main':
return ' (main branch)'
case 'local':
return ' (local)'
case 'release':
return ''
}
})()
const versionLinks = ((): DefaultTheme.NavItemWithLink[] => {
const oldVersions: DefaultTheme.NavItemWithLink[] = [
{
text: 'Vite 4 Docs',
link: 'https://v4.vitejs.dev',
},
{
text: 'Vite 3 Docs',
link: 'https://v3.vitejs.dev',
},
{
text: 'Vite 2 Docs',
link: 'https://v2.vitejs.dev',
},
]

switch (deployType) {
case 'main':
case 'local':
return [
{
text: 'Vite 5 Docs (release)',
link: 'https://vitejs.dev',
},
...oldVersions,
]
case 'release':
return oldVersions
}
})()

export default defineConfig({
title: 'Vite 官方中文文档',
description: '下一代前端工具链',
Expand Down Expand Up @@ -38,6 +93,7 @@ export default defineConfig({
es: { label: 'Español', link: 'https://es.vitejs.dev' },
pt: { label: 'Português', link: 'https://pt.vitejs.dev' },
ko: { label: '한국어', link: 'https://ko.vitejs.dev' },
de: { label: 'Deutsch', link: 'https://de.vitejs.dev' },
},

themeConfig: {
Expand Down Expand Up @@ -126,6 +182,7 @@ export default defineConfig({
text: '相关链接',
items: [
{ text: 'Team', link: '/team' },
{ text: 'Blog', link: '/blog' },
{ text: 'Releases', link: '/releases' },
{
items: [
Expand Down
10 changes: 6 additions & 4 deletions .vitepress/rewrite-title/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const path = require('path')
const fsp = require('fs').promises
const matterService = require('../utils/frontmatter-service')
import path from 'node:path'
import fsp from 'node:fs/promises'
import matterService from '../utils/frontmatter-service.js'
import { fileURLToPath } from 'node:url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const workspacePath = path.resolve(__dirname, '..', '..')

const h1MdRegExp = /^#\s+(.+)\s+(\{#([\w-]+)\})$/
Expand Down Expand Up @@ -41,4 +43,4 @@ const ergodicDirectory = async (dirPath) => {
}
}

module.exports = () => ergodicDirectory(workspacePath)
export default () => ergodicDirectory(workspacePath)
65 changes: 65 additions & 0 deletions .vitepress/theme/components/AsideSponsors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,70 @@ const sponsors = computed(() => {
</script>

<template>
<a
class="viteconf"
href="https://viteconf.org/23/replay?utm=vite-sidebar"
target="_blank"
>
<img width="22" height="22" src="/viteconf.svg" />
<span>
<p class="extra-info">Beyond Fast</p>
<p class="heading">ViteConf 2023</p>
<p class="extra-info">Watch the replay!</p>
</span>
</a>
<VPDocAsideSponsors v-if="data" :data="sponsors" />
</template>

<style>
.viteconf {
margin-top: 1rem;
margin-bottom: 1rem;
border-radius: 14px;
padding-top: 0.4rem;
padding-bottom: 0.4rem;
position: relative;
font-size: 0.9rem;
font-weight: 700;
line-height: 1.1rem;
display: flex;
align-items: center;
justify-content: center;
width: 100%;
gap: 1rem;
background-color: var(--vp-c-bg-alt);
border: 2px solid var(--vp-c-bg-alt);
transition: border-color 0.5s;
}
.viteconf:hover {
border: 2px solid var(--vp-c-brand-light);
}
.viteconf img {
transition: transform 0.5s;
transform: scale(1.25);
}
.viteconf:hover img {
transform: scale(1.75);
}
.viteconf .heading {
background-image: linear-gradient(
120deg,
#b047ff 16%,
var(--vp-c-brand-lighter),
var(--vp-c-brand-lighter)
);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.viteconf .extra-info {
color: var(--vp-c-text-1);
opacity: 0;
font-size: 0.7rem;
padding-left: 0.1rem;
transition: opacity 0.5s;
}
.viteconf:hover .extra-info {
opacity: 0.9;
}
</style>
46 changes: 46 additions & 0 deletions .vitepress/theme/components/BlogIndex.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<script setup lang="ts">
import { data as posts } from './blog.data'

function getDateTime(time: number) {
return new Date(time).toISOString()
}
</script>

<template>
<ul class="blog-list">
<li class="blog-entry" v-for="post of posts">
<article>
<time :datetime="getDateTime(post.date.time)">{{
post.date.string
}}</time>
<h2 class="title">
<a :href="post.url">{{ post.title }}</a>
</h2>
</article>
</li>
</ul>
</template>

<style scoped>
.blog-list {
list-style-type: none;
padding: 0;
}
.blog-entry {
margin-top: 3em;
border-bottom: 1px solid var(--vp-c-divider);
}
.blog-entry time {
font-size: 14px;
}
.title {
border: none;
margin-top: 0;
padding-top: 0;
font-size: 22px;
}
.title a {
font-weight: 600;
text-decoration: none;
}
</style>
40 changes: 40 additions & 0 deletions .vitepress/theme/components/blog.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createContentLoader } from 'vitepress'

interface Post {
title: string
url: string
date: {
time: number
string: string
}
}

declare const data: Post[]
export { data }

export default createContentLoader('blog/*.md', {
// excerpt: true,
transform(raw): Post[] {
return raw
.map(({ url, frontmatter }) => ({
title: frontmatter.head.find((e) => e[1].property === 'og:title')[1]
.content,
url,
date: formatDate(frontmatter.date),
}))
.sort((a, b) => b.date.time - a.date.time)
},
})

function formatDate(raw: string): Post['date'] {
const date = new Date(raw)
date.setUTCHours(12)
return {
time: +date,
string: date.toLocaleDateString('en-US', {
year: 'numeric',
month: 'long',
day: 'numeric',
}),
}
}
3 changes: 3 additions & 0 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import AsideSponsors from './components/AsideSponsors.vue'
import SvgImage from './components/SvgImage.vue'
import WwAds from './components/WwAds.vue'
import './custom.css'
// temporary fix for vitepress not including component css when only
// imported in a single page
import './components/BlogIndex.vue'

export default {
extends: DefaultTheme,
Expand Down
8 changes: 8 additions & 0 deletions .vitepress/theme/styles/vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,11 @@
.vp-sponsor.aside .vp-sponsor-grid.mini .vp-sponsor-grid-image {
max-width: 124px;
}

.vp-sponsor.aside .vp-sponsor-grid.mini .vp-sponsor-grid-image[alt='Bit'] {
max-height: 44px;
}

.vp-sponsor-grid.big .vp-sponsor-grid-image {
max-height: 96px;
}
13 changes: 7 additions & 6 deletions .vitepress/utils/frontmatter-service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const fs = require('fs')
const matter = require('gray-matter')
const { extend, isEmpty: _isEmpty } = require('lodash')
import fs from 'node:fs'
import matter from 'gray-matter'
import _ from 'lodash'

// gray-matter is a dep for vitepress,
// no need to specify that in package.json

Expand All @@ -21,7 +22,7 @@ class FrontMatterService {
}

isEmpty() {
return _isEmpty(this.matter.data)
return _._isEmpty(this.matter.data)
}

/** @param{(data: string) => void} callback */
Expand All @@ -48,7 +49,7 @@ class FrontMatterService {

/** @param {Record<string, any>} src */
extend(src) {
extend(this.matter.data, src)
_.extend(this.matter.data, src)
return this
}

Expand All @@ -63,4 +64,4 @@ class FrontMatterService {
}
}

module.exports = new FrontMatterService()
export default new FrontMatterService()
5 changes: 3 additions & 2 deletions _data/team.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ export const core = [
avatar: 'https://github.com/sapphi-red.png',
name: 'green',
title: 'Web Developer',
desc: 'Vite team member. Call me sapphi or green or midori ;)',
desc: 'Vite core team member. Call me sapphi or green or midori ;)',
links: [
{ icon: 'github', link: 'https://github.com/sapphi-red' },
{ icon: 'twitter', link: 'https://twitter.com/sapphi_red' },
{ icon: 'mastodon', link: 'https://elk.zone/m.webtoo.ls/@sapphi_red' },
],
sponsor: 'https://github.com/sponsors/sapphi-red',
},
Expand All @@ -82,7 +83,7 @@ export const core = [
desc: 'Passionate TypeScript enthusiast working extensively with Vue SPA and pug.',
links: [
{ icon: 'github', link: 'https://github.com/Shinigami92' },
{ icon: 'twitter', link: 'https://twitter.com/Shini_92' },
{ icon: 'mastodon', link: 'https://elk.zone/mas.to/@Shini92' },
],
sponsor: 'https://github.com/sponsors/Shinigami92',
},
Expand Down
13 changes: 13 additions & 0 deletions blog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
sidebar: false
editLink: false
outline: false
---

<script setup>
import BlogIndex from './.vitepress/theme/components/BlogIndex.vue'
</script>

# Latest From the Vite Blog

<BlogIndex/>
14 changes: 14 additions & 0 deletions blog/announcing-vite2.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
---
sidebar: false
date: 2021-02-16
head:
- - meta
- property: og:type
content: website
- - meta
- property: og:title
content: Announcing Vite 2.0
- - meta
- property: og:url
content: https://vitejs.dev/blog/announcing-vite2
- - meta
- property: og:description
content: Vite 2 Release Announcement
---

# Vite 2.0 发布了 {#announcing-vite-2-0}
Expand Down
1 change: 1 addition & 0 deletions blog/announcing-vite3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar: false
date: 2022-07-23
head:
- - meta
- property: og:type
Expand Down
1 change: 1 addition & 0 deletions blog/announcing-vite4-3.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
sidebar: false
date: 2023-04-20
head:
- - meta
- property: og:type
Expand Down
Loading