diff --git a/docs/package.json b/docs/package.json index b0f94591e..636fd63c5 100644 --- a/docs/package.json +++ b/docs/package.json @@ -12,7 +12,7 @@ "lint:a11y:local": "pa11y-ci --sitemap 'http://localhost:3000/sitemap.xml' --sitemap-find 'https://docs.astro.build' --sitemap-replace 'http://localhost:3000'", "lint:a11y:remote": "pa11y-ci --sitemap 'https://docs.astro.build/sitemap.xml'", "lint:linkcheck": "start-test 'yarn dev --silent' 3000 'yarn lint:linkcheck:local'", - "lint:linkcheck:local": "blc -ro --user-agent 'broken-link-checker/0.7.8' 'http://localhost:3000'", + "lint:linkcheck:local": "blc -roe --user-agent 'broken-link-checker/0.7.8' 'http://localhost:3000/en/getting-started'", "lint:linkcheck:remote": "blc -ro --user-agent 'broken-link-checker/0.7.8' 'https://docs.astro.build/'" }, "devDependencies": { diff --git a/docs/src/components/Header/LanguageSelect.tsx b/docs/src/components/Header/LanguageSelect.tsx index 37fef6d08..70fb405a4 100644 --- a/docs/src/components/Header/LanguageSelect.tsx +++ b/docs/src/components/Header/LanguageSelect.tsx @@ -29,11 +29,7 @@ const LanguageSelect: FunctionalComponent<{ lang: string }> = ({ lang }) => { aria-label="Select language" onChange={(e) => { const newLang = e.target.value; - if (newLang === 'en') { - window.location.pathname = `/getting-started`; - } else { - window.location.pathname = `/${newLang}/getting-started`; - } + window.location.pathname = `/${newLang}/getting-started`; // TODO: Preserve the current page, if it exists: // const oldPathname = window.location.pathname; // const oldPathnameParts = oldPathname.split('/'); diff --git a/docs/src/config.ts b/docs/src/config.ts index 88e41aad4..8514a171f 100644 --- a/docs/src/config.ts +++ b/docs/src/config.ts @@ -1,43 +1,43 @@ export const SIDEBAR = { en: [ { text: 'Setup', header: true }, - { text: 'Getting Started', link: 'getting-started' }, - { text: 'Quickstart', link: 'quick-start' }, - { text: 'Installation', link: 'installation' }, - { text: 'Themes', link: 'themes' }, - { text: 'Astro vs. X', link: 'comparing-astro-vs-other-tools' }, - { text: 'Migrate to v0.21', link: 'migration/0.21.0' }, + { text: 'Getting Started', link: 'en/getting-started' }, + { text: 'Quickstart', link: 'en/quick-start' }, + { text: 'Installation', link: 'en/installation' }, + { text: 'Themes', link: 'en/themes' }, + { text: 'Astro vs. X', link: 'en/comparing-astro-vs-other-tools' }, + { text: 'Migrate to v0.21', link: 'en/migration/0.21.0' }, { text: 'Basics', header: true }, - { text: 'Project Structure', link: 'core-concepts/project-structure' }, - { text: 'Component Syntax', link: 'core-concepts/astro-components' }, - { text: 'Pages', link: 'core-concepts/astro-pages' }, - { text: 'Layouts', link: 'core-concepts/layouts' }, - { text: 'Routing', link: 'core-concepts/routing' }, - { text: 'Partial Hydration', link: 'core-concepts/component-hydration' }, + { text: 'Project Structure', link: 'en/core-concepts/project-structure' }, + { text: 'Component Syntax', link: 'en/core-concepts/astro-components' }, + { text: 'Pages', link: 'en/core-concepts/astro-pages' }, + { text: 'Layouts', link: 'en/core-concepts/layouts' }, + { text: 'Routing', link: 'en/core-concepts/routing' }, + { text: 'Partial Hydration', link: 'en/core-concepts/component-hydration' }, { text: 'Guides', header: true }, - { text: 'Styling & CSS', link: 'guides/styling' }, - { text: 'Markdown', link: 'guides/markdown-content' }, - { text: 'Debugging', link: 'guides/debugging' }, - { text: 'Data Fetching', link: 'guides/data-fetching' }, - { text: 'Pagination', link: 'guides/pagination' }, - { text: 'RSS', link: 'guides/rss' }, - { text: 'Supported Imports', link: 'guides/imports' }, - { text: 'Aliases', link: 'guides/aliases' }, - { text: 'Environment Variables', link: 'guides/environment-variables' }, - { text: 'Deploy to the web', link: 'guides/deploy' }, - { text: 'Publish to npm', link: 'guides/publish-to-npm' }, + { text: 'Styling & CSS', link: 'en/guides/styling' }, + { text: 'Markdown', link: 'en/guides/markdown-content' }, + { text: 'Debugging', link: 'en/guides/debugging' }, + { text: 'Data Fetching', link: 'en/guides/data-fetching' }, + { text: 'Pagination', link: 'en/guides/pagination' }, + { text: 'RSS', link: 'en/guides/rss' }, + { text: 'Supported Imports', link: 'en/guides/imports' }, + { text: 'Aliases', link: 'en/guides/aliases' }, + { text: 'Environment Variables', link: 'en/guides/environment-variables' }, + { text: 'Deploy to the web', link: 'en/guides/deploy' }, + { text: 'Publish to npm', link: 'en/guides/publish-to-npm' }, { text: 'Reference', header: true }, - { text: 'Built-In Components', link: 'reference/builtin-components' }, - { text: 'API Reference', link: 'reference/api-reference' }, - { text: 'CLI Reference', link: 'reference/cli-reference' }, + { text: 'Built-In Components', link: 'en/reference/builtin-components' }, + { text: 'API Reference', link: 'en/reference/api-reference' }, + { text: 'CLI Reference', link: 'en/reference/cli-reference' }, { text: 'Configuration Reference', - link: 'reference/configuration-reference', + link: 'en/reference/configuration-reference', }, - { text: 'Renderer Reference', link: 'reference/renderer-reference' }, + { text: 'Renderer Reference', link: 'en/reference/renderer-reference' }, ], de: [ { text: 'Einrichtung', header: true }, diff --git a/docs/src/pages/[slug].astro b/docs/src/pages/[slug].astro new file mode 100644 index 000000000..7c08ff268 --- /dev/null +++ b/docs/src/pages/[slug].astro @@ -0,0 +1,20 @@ +--- +export async function getStaticPaths() { + // get english pages that moved from `/` to `/en/` + const englishPages = Astro.fetchContent('./en/**.md'); + + // add pages that are `*.astro` files as well + const otherPages = [{ url: "/en/themes" }]; + + return [...englishPages, ...otherPages].map((page) => ({ + params: { + slug: page.url.slice(4), + }, + props: { + englishSlug: page.url, + } + })); +} +--- + + \ No newline at end of file diff --git a/docs/src/pages/comparing-astro-vs-other-tools.md b/docs/src/pages/en/comparing-astro-vs-other-tools.md similarity index 94% rename from docs/src/pages/comparing-astro-vs-other-tools.md rename to docs/src/pages/en/comparing-astro-vs-other-tools.md index 952d525c1..b760c2c14 100644 --- a/docs/src/pages/comparing-astro-vs-other-tools.md +++ b/docs/src/pages/en/comparing-astro-vs-other-tools.md @@ -22,7 +22,7 @@ Docusaurus was designed to build documentation websites and has some built-in, d ### Comparing Docusaurus vs. Astro Performance -In most cases, Astro websites will load significantly faster than Docusaurus websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). +In most cases, Astro websites will load significantly faster than Docusaurus websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). Docusaurus doesn't support partial hydration, and instead makes the user load and rehydrate the entire page in the browser, even if most of the page content is static. This creates a slower page load and worse performance for your website. There is no way to disable this behavior in Docusaurus. @@ -41,9 +41,9 @@ One big reason behind this performance difference is Astro's smaller JavaScript Elder.js uses Svelte to render your website. Astro is more flexible: you are free to build UI with any popular component library (React, Preact, Vue, Svelte, Solid and others) or Astro's HTML-like component syntax which is similar to HTML + JSX. -Elder.js is unique on this list as the only other site builder to support [partial hydration](/core-concepts/component-hydration). Both Astro and Elder.js automatically strip unnecessary JavaScript from the page, hydrating only the individual components that need it. Elder's API for partial hydration is a bit different and Astro supports a few features that Elder.js doesn't (like `client:media`). However performance-wise, both projects will build very similar sites. +Elder.js is unique on this list as the only other site builder to support [partial hydration](/en/core-concepts/component-hydration). Both Astro and Elder.js automatically strip unnecessary JavaScript from the page, hydrating only the individual components that need it. Elder's API for partial hydration is a bit different and Astro supports a few features that Elder.js doesn't (like `client:media`). However performance-wise, both projects will build very similar sites. -Elder.js uses a custom routing solution that may feel unfamiliar to new developers. Astro uses [file-based routing](/core-concepts/routing) which should feel familiar to anyone coming from Next.js, SvelteKit, and even other static site builders like Eleventy. +Elder.js uses a custom routing solution that may feel unfamiliar to new developers. Astro uses [file-based routing](/en/core-concepts/routing) which should feel familiar to anyone coming from Next.js, SvelteKit, and even other static site builders like Eleventy. Elder.js was designed to run on large websites, and claims to build one website of ~20k pages in less than 10 minutes (on a modest VM). At the time of writing, Astro builds ~1k pages in 66 seconds but has not yet been tested on 20k+ page projects. Astro is still in early beta, and matching Elder.js build speed is a goal for Astro v1.0. @@ -61,7 +61,7 @@ Conceptually, Eleventy is aligned with Astro's "minimal client-side JavaScript" Eleventy achieves this by pushing you to avoid JavaScript entirely. Eleventy sites are often written with little to no JavaScript at all. This becomes an issue when you do need client-side JavaScript. It is up to you to create your own asset build pipeline for Eleventy. This can be time consuming and forces you to set up bundling, minification, and other complex optimizations yourself. -By contrast, Astro automatically builds your client-side JavaScript & CSS for you. Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). While it is possible to achieve this yourself in Eleventy, Astro offers it built in by default. +By contrast, Astro automatically builds your client-side JavaScript & CSS for you. Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). While it is possible to achieve this yourself in Eleventy, Astro offers it built in by default. ## Gatsby vs. Astro @@ -75,7 +75,7 @@ Gatsby requires a custom GraphQL API for working with all of your site content. ### Comparing Gastby vs. Astro Performance -In most cases, Astro websites will load significantly faster than Gatsby websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). +In most cases, Astro websites will load significantly faster than Gatsby websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). Gatsby doesn't support partial hydration, and instead makes the user load and rehydrate the entire page in the browser, even if most of the page content is static. This creates a slower page load and worse performance for your website. Gatsby has [a community plugin](https://www.gatsbyjs.com/plugins/gatsby-plugin-no-javascript/) for removing all JavaScript from the page, but this would break many websites. This leaves you with an all-or-nothing decision for interactivity on each page. @@ -100,7 +100,7 @@ Hugo uses a custom [templating language](https://gohugo.io/templates/introductio Conceptually, Hugo is aligned with Astro's "minimal client-side JavaScript" approach to web development. Hugo and Astro both offer similar, zero-JavaScript-by-default performance baselines. -Both Hugo and Astro offer built-in support for building, bundling and minifying JavaScript. Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). While it is possible to achieve this yourself in Hugo, Astro offers it built in by default. +Both Hugo and Astro offer built-in support for building, bundling and minifying JavaScript. Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). While it is possible to achieve this yourself in Hugo, Astro offers it built in by default. ## Jekyll vs. Astro @@ -128,7 +128,7 @@ SvelteKit supports both Static Site Generation (SSG) and Server-Side Rendering ( ### Comparing SvelteKit vs. Astro Performance -In most cases, Astro websites will load faster than SvelteKit websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). +In most cases, Astro websites will load faster than SvelteKit websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). SvelteKit doesn't support partial hydration, and instead makes the user load and rehydrate the entire page in the browser, even if most of the page content is static. This creates a slower page load and worse performance for your website. SvelteKit does offer support for [page-level static, zero-JavaScript pages](https://kit.svelte.dev/docs#ssr-and-javascript-hydrate). However, there is no planned support for hydrating individual components on the page. This leaves you with an all-or-nothing decision for interactivity on each page. @@ -155,7 +155,7 @@ Next.js supports both Static Site Generation (SSG) and Server-Side Rendering (SS ### Comparing Next.js vs. Astro Performance -In most cases, Astro websites will load significantly faster than Next.js websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). +In most cases, Astro websites will load significantly faster than Next.js websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). Next.js doesn't support partial hydration, and instead makes the user load and rehydrate the entire page in the browser, even if most of the page content is static. This creates a slower page load and worse performance for your website. Next.js has [experimental support](https://piccalil.li/blog/new-year-new-website/#heading-no-client-side-react-code) for fully-static, zero-JavaScript pages. However, there is no planned support for hydrating individual components on the page. This leaves you with an all-or-nothing decision for interactivity on each page. @@ -182,7 +182,7 @@ Nuxt supports both Static Site Generation (SSG) and Server-Side Rendering (SSR). ### Comparing Nuxt vs. Astro Performance -In most cases, Astro websites will load significantly faster than Nuxt websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). +In most cases, Astro websites will load significantly faster than Nuxt websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). Nuxt doesn't support partial hydration, and instead makes the user load and rehydrate the entire page in the browser, even if most of the page content is static. This creates a slower page load and worse performance for your website. There is no way to disable this behavior in Nuxt. @@ -207,7 +207,7 @@ Evan You (creator of Vue.js) is currently working on a new version of Vuepress c ### Comparing VuePress vs. Astro Performance -In most cases, Astro websites will load significantly faster than VuePress websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). +In most cases, Astro websites will load significantly faster than VuePress websites. This is because Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). VuePress doesn't support partial hydration, and instead makes the user load and rehydrate the entire page in the browser, even if most of the page content is static. This creates a slower page load and worse performance for your website. There is no way to disable this behavior in VuePress. @@ -230,4 +230,4 @@ Zola uses [Tera](https://tera.netlify.app/) to render your website. Astro lets y Conceptually, Zola is aligned with Astro's "minimal client-side JavaScript" approach to web development. Zola and Astro both offer similar, zero-JavaScript-by-default performance baselines. -Astro offer built-in support for building, bundling and minifying JavaScript. Zola requires using another build tool like Webpack to bundle and process JavaScript. Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/core-concepts/component-hydration). While it is possible to achieve this yourself in Zola, Astro offers it built in by default. +Astro offer built-in support for building, bundling and minifying JavaScript. Zola requires using another build tool like Webpack to bundle and process JavaScript. Astro automatically strips unnecessary JavaScript from the page, hydrating only the individual components that need it. This feature is called [partial hydration](/en/core-concepts/component-hydration). While it is possible to achieve this yourself in Zola, Astro offers it built in by default. diff --git a/docs/src/pages/core-concepts/astro-components.md b/docs/src/pages/en/core-concepts/astro-components.md similarity index 97% rename from docs/src/pages/core-concepts/astro-components.md rename to docs/src/pages/en/core-concepts/astro-components.md index 2394f3696..0c7f6d71a 100644 --- a/docs/src/pages/core-concepts/astro-components.md +++ b/docs/src/pages/en/core-concepts/astro-components.md @@ -27,7 +27,7 @@ For example, this three-line file is a valid Astro component: ``` -An Astro component represents some snippet of HTML in your project. This can be a reusable component, or an entire page of HTML including ``, `` and `` elements. See our guide on [Astro Pages](/core-concepts/astro-pages) to learn how to build your first full HTML page with Astro. +An Astro component represents some snippet of HTML in your project. This can be a reusable component, or an entire page of HTML including ``, `` and `` elements. See our guide on [Astro Pages](/en/core-concepts/astro-pages) to learn how to build your first full HTML page with Astro. **Every Astro component must include an HTML template.** While you can enhance your component in several ways (see below), at the end of the day it's the HTML template that dictates what your rendered Astro component will look like. @@ -68,13 +68,13 @@ Using `