diff --git a/__tests__/e2e/__snapshots__/index.test.ts.snap b/__tests__/e2e/__snapshots__/home.test.ts.snap similarity index 100% rename from __tests__/e2e/__snapshots__/index.test.ts.snap rename to __tests__/e2e/__snapshots__/home.test.ts.snap diff --git a/__tests__/e2e/home.md b/__tests__/e2e/home.md new file mode 100644 index 00000000000..3287f3b6f1b --- /dev/null +++ b/__tests__/e2e/home.md @@ -0,0 +1,21 @@ +# Lorem Ipsum + +Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. + +## What is Lorem Ipsum? + +Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. + +## Where does it come from? + +Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. + +The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. + +## Why do we use it? + +It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). + +## Where can I get some? + +There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. diff --git a/__tests__/e2e/index.test.ts b/__tests__/e2e/home.test.ts similarity index 97% rename from __tests__/e2e/index.test.ts rename to __tests__/e2e/home.test.ts index 76279036ed2..9b02c1a239c 100644 --- a/__tests__/e2e/index.test.ts +++ b/__tests__/e2e/home.test.ts @@ -1,6 +1,6 @@ describe('render correct content', async () => { beforeAll(async () => { - await goto('/') + await goto('/home') }) test('main content', async () => { diff --git a/__tests__/e2e/index.md b/__tests__/e2e/index.md index 3287f3b6f1b..f35cb331c9a 100644 --- a/__tests__/e2e/index.md +++ b/__tests__/e2e/index.md @@ -1,21 +1,36 @@ -# Lorem Ipsum - -Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - -## What is Lorem Ipsum? - -Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. - -## Where does it come from? - -Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. Lorem Ipsum comes from sections 1.10.32 and 1.10.33 of "de Finibus Bonorum et Malorum" (The Extremes of Good and Evil) by Cicero, written in 45 BC. This book is a treatise on the theory of ethics, very popular during the Renaissance. The first line of Lorem Ipsum, "Lorem ipsum dolor sit amet..", comes from a line in section 1.10.32. - -The standard chunk of Lorem Ipsum used since the 1500s is reproduced below for those interested. Sections 1.10.32 and 1.10.33 from "de Finibus Bonorum et Malorum" by Cicero are also reproduced in their exact original form, accompanied by English versions from the 1914 translation by H. Rackham. - -## Why do we use it? - -It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like). - -## Where can I get some? - -There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable. If you are going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making this the first true generator on the Internet. It uses a dictionary of over 200 Latin words, combined with a handful of model sentence structures, to generate Lorem Ipsum which looks reasonable. The generated Lorem Ipsum is therefore always free from repetition, injected humour, or non-characteristic words etc. +--- +layout: home + +title: VitePress + +hero: + name: VitePress + text: Vite & Vue Powered Static Site Generator + actions: + - theme: brand + text: Examples + link: /home + +features: + - title: Emoji + details: Emoji on features section + icon: ⚡️ + - title: SVG + details: SVG on features section + icon: + src: /vitepress.svg + alt: VitePress Logo + - title: PNG + details: PNG on features section + icon: + src: /vitepress.png + width: 48 + height: 48 + alt: VitePress Logo + - title: Dark/Light SVG + details: Dark/Light SVG on features section + icon: + dark: /pwa_dark.svg + light: /pwa_light.svg + alt: Vite PWA Logo +--- diff --git a/__tests__/e2e/package.json b/__tests__/e2e/package.json index 25ac353814f..0aea611704a 100644 --- a/__tests__/e2e/package.json +++ b/__tests__/e2e/package.json @@ -1,5 +1,6 @@ { "private": true, + "type": "module", "devDependencies": { "vitepress": "workspace:*" } diff --git a/__tests__/e2e/public/pwa_dark.svg b/__tests__/e2e/public/pwa_dark.svg new file mode 100644 index 00000000000..4faa6269331 --- /dev/null +++ b/__tests__/e2e/public/pwa_dark.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/__tests__/e2e/public/pwa_light.svg b/__tests__/e2e/public/pwa_light.svg new file mode 100644 index 00000000000..f3765583f8a --- /dev/null +++ b/__tests__/e2e/public/pwa_light.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/__tests__/e2e/public/vitepress.png b/__tests__/e2e/public/vitepress.png new file mode 100644 index 00000000000..6cb0b38438a Binary files /dev/null and b/__tests__/e2e/public/vitepress.png differ diff --git a/__tests__/e2e/public/vitepress.svg b/__tests__/e2e/public/vitepress.svg new file mode 100644 index 00000000000..5ac55cbdc7f --- /dev/null +++ b/__tests__/e2e/public/vitepress.svg @@ -0,0 +1,285 @@ + +image/svg+xml diff --git a/docs/config/frontmatter-configs.md b/docs/config/frontmatter-configs.md index f372368d4a7..6b0be9015c7 100644 --- a/docs/config/frontmatter-configs.md +++ b/docs/config/frontmatter-configs.md @@ -169,49 +169,6 @@ This option only takes effect when `layout` is set to `home`. It defines items to display in features section. -```yaml ---- -layout: home - -features: - - icon: ⚡️ - title: Vite, The DX that can't be beat - details: Lorem ipsum... - - icon: 🖖 - title: Power of Vue meets Markdown - details: Lorem ipsum... - - icon: 🛠️ - title: Simple and minimal, always - details: Lorem ipsum... ---- -``` - -```ts -interface Feature { - // Show icon on each feature box. Currently, only emojis - // are supported. - icon?: string - - // Title of the feature. - title: string - - // Details of the feature. - details: string - - // Link when clicked on feature component. The link can - // be both internal or external. - // - // e.g. `guide/theme-home-page` or `htttps://example.com` - link?: string - - // Link text to be shown inside feature component. Best - // used with `link` option. - // - // e.g. `Learn more`, `Visit page`, etc. - linkText?: string -} -``` - You may learn more about it in [Theme: Home Page](../guide/theme-home-page). ## aside diff --git a/docs/config/theme-configs.md b/docs/config/theme-configs.md index 9db0170b860..e3eb1d05e2b 100644 --- a/docs/config/theme-configs.md +++ b/docs/config/theme-configs.md @@ -34,8 +34,10 @@ export default { ``` ```ts -type Image = string | { src: string; alt?: string } -type ThemeableImage = Image | { light: Image; dark: Image } +type ThemeableImage = + | string + | { src: string; alt?: string } + | { light: string; dark: string; alt?: string } ``` ## siteTitle diff --git a/docs/guide/theme-home-page.md b/docs/guide/theme-home-page.md index da90b44a3f1..6f770e18d4d 100644 --- a/docs/guide/theme-home-page.md +++ b/docs/guide/theme-home-page.md @@ -87,28 +87,32 @@ Also you may customize it further by combining `--vp-home-hero-name-background` In Features section, you can list any number of features you would like to show right after the Hero section. To configure it, pass `features` option to the frontmatter. +You can provide an icon for each feature, which can be an emoji or any type of image. When the configured icon is an image (svg, png, jpeg...), you must provide the icon with the proper width and height; you can also provide the description, its intrinsic size as well as its variants for dark and light theme when required. + ```yaml --- layout: home features: - - icon: ⚡️ - title: Vite, The DX that can't be beat - details: Lorem ipsum... - - icon: 🖖 - title: Power of Vue meets Markdown - details: Lorem ipsum... - icon: 🛠️ title: Simple and minimal, always details: Lorem ipsum... + - icon: + src: /cool-feature-icon.svg + title: Another cool feature + details: Lorem ipsum... + - icon: + dark: /dark-feature-icon.svg + light: /light-feature-icon.svg + title: Another cool feature + details: Lorem ipsum... --- ``` ```ts interface Feature { - // Show icon on each feature box. Currently, only emojis - // are supported. - icon?: string + // Show icon on each feature box. + icon?: FeatureIcon // Title of the feature. title: string @@ -128,4 +132,15 @@ interface Feature { // e.g. `Learn more`, `Visit page`, etc. linkText?: string } + +type FeatureIcon = + | string + | { src: string; alt?: string; width?: string; height: string } + | { + light: string + dark: string + alt?: string + width?: string + height: string + } ``` diff --git a/package.json b/package.json index 97a0265426a..e8f68ddcccb 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "test-build": "VITE_TEST_BUILD=1 pnpm test-preview", "debug-preview": "DEBUG=1 vitest -r __tests__/e2e", "debug-build": "VITE_TEST_BUILD=1 pnpm debug-preview", + "e2e-dev": "wait-on -d 100 dist/node/cli.js && node ./bin/vitepress dev __tests__/e2e", "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s", "release": "node scripts/release.js", "docs": "run-p dev docs-dev", diff --git a/src/client/theme-default/components/VPFeature.vue b/src/client/theme-default/components/VPFeature.vue index 4a2be4fcc7c..39ef5e90b5a 100644 --- a/src/client/theme-default/components/VPFeature.vue +++ b/src/client/theme-default/components/VPFeature.vue @@ -1,9 +1,11 @@