diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ba8a385a4e8d..c0127b063d4bc 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -156,7 +156,7 @@ pnpm install pnpm start ``` -If you’re copying these instructions, remember to [configure this project as a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-for-a-fork). +If you’re copying these instructions, remember to [configure this project as a fork](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/configuring-a-remote-repository-for-a-fork). ```shell git remote add upstream git@github.com:withastro/docs.git diff --git a/package.json b/package.json index 5274777cc5830..ebbde7951cef7 100644 --- a/package.json +++ b/package.json @@ -77,8 +77,8 @@ "p-retry": "^5.1.1", "parse-numeric-range": "^1.3.0", "preact": "^10.10.1", - "prettier": "^2.8.1", - "prettier-plugin-astro": "^0.7.0", + "prettier": "^2.8.8", + "prettier-plugin-astro": "^0.8.0", "prompts": "^2.4.2", "rehype": "^12.0.1", "remark": "^14.0.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aed1bb8f91a7e..00937088e561f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -178,11 +178,11 @@ devDependencies: specifier: ^10.10.1 version: 10.10.1 prettier: - specifier: ^2.8.1 - version: 2.8.1 + specifier: ^2.8.8 + version: 2.8.8 prettier-plugin-astro: - specifier: ^0.7.0 - version: 0.7.0 + specifier: ^0.8.0 + version: 0.8.0 prompts: specifier: ^2.4.2 version: 2.4.2 @@ -422,7 +422,7 @@ packages: dependencies: '@vscode/emmet-helper': 2.8.4 events: 3.3.0 - prettier: 2.8.1 + prettier: 2.8.8 prettier-plugin-astro: 0.7.0 source-map: 0.7.4 vscode-css-languageservice: 6.0.1 @@ -5352,13 +5352,23 @@ packages: engines: {node: ^14.15.0 || >=16.0.0, npm: '>=6.14.0'} dependencies: '@astrojs/compiler': 0.29.13 - prettier: 2.8.1 + prettier: 2.8.8 sass-formatter: 0.7.5 synckit: 0.8.4 dev: true - /prettier@2.8.1: - resolution: {integrity: sha512-lqGoSJBQNJidqCHE80vqZJHWHRFoNYsSpP9AjFhlhi9ODCJA541svILes/+/1GM3VaL/abZi7cpFzOpdR9UPKg==} + /prettier-plugin-astro@0.8.0: + resolution: {integrity: sha512-kt9wk33J7HvFGwFaHb8piwy4zbUmabC8Nu+qCw493jhe96YkpjscqGBPy4nJ9TPy9pd7+kEx1zM81rp+MIdrXg==} + engines: {node: ^14.15.0 || >=16.0.0, pnpm: '>=7.14.0'} + dependencies: + '@astrojs/compiler': 1.3.2 + prettier: 2.8.8 + sass-formatter: 0.7.5 + synckit: 0.8.4 + dev: true + + /prettier@2.8.8: + resolution: {integrity: sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==} engines: {node: '>=10.13.0'} hasBin: true dev: true diff --git a/src/components/PageContent/PageContent.astro b/src/components/PageContent/PageContent.astro index 7e4360ad3ab38..da4dab73c551f 100644 --- a/src/components/PageContent/PageContent.astro +++ b/src/components/PageContent/PageContent.astro @@ -20,14 +20,13 @@ const title = content.title .replace('@astrojs/', '@astrojs/') .replaceAll('-', '-'); const isFallback = !!Astro.params.fallback || undefined; -const outdated = - Astro.params.lang === 'en' || Astro.params.fallback - ? false - : await isOutdated( - ( - await getEntryBySlug('docs', `${Astro.params.lang}/${Astro.params.slug}`) - )?.id! - ); +let outdated: boolean; +if (Astro.params.lang === 'en' || Astro.params.fallback) { + outdated = false; +} else { + const currentEntry = await getEntryBySlug('docs', `${Astro.params.lang}/${Astro.params.slug}`); + outdated = await isOutdated(currentEntry?.id!); +} const lang = getLanguageFromURL(Astro.url.pathname); const bcpLang = normalizeLangTag(lang); const direction = rtlLanguages.has(lang) ? 'rtl' : 'ltr'; diff --git a/src/components/RecipeLinks.astro b/src/components/RecipeLinks.astro index 9eb664d4beaa5..af3dca0df5a5d 100644 --- a/src/components/RecipeLinks.astro +++ b/src/components/RecipeLinks.astro @@ -1,6 +1,7 @@ --- import { recipePages } from '~/content'; import { getLanguageFromURL, stripLangFromSlug } from '~/util'; +import UIString from './UIString.astro'; export interface Props { slugs: string[]; @@ -24,7 +25,7 @@ const recipes = Astro.props.slugs.map((slug) => { }); const isList = recipes.length > 1; -const noun = isList ? 'recipes' : 'recipe'; +const labelKey = isList ? 'recipesLink.plural' : 'recipesLink.singular'; const firstRecipe = recipes[0]; if (!firstRecipe) { throw new Error('No slugs passed to `` component. Make sure you pass at least one.'); @@ -34,7 +35,7 @@ if (!firstRecipe) { - Related {noun}: + { !isList && ( diff --git a/src/components/tabs/AstroJSXTabs.astro b/src/components/tabs/AstroJSXTabs.astro index 275ae9f7d63b2..5832006548ecf 100644 --- a/src/components/tabs/AstroJSXTabs.astro +++ b/src/components/tabs/AstroJSXTabs.astro @@ -6,12 +6,12 @@ import Tabs from './Tabs'; JSX Astro - + + - + + diff --git a/src/components/tabs/AstroVueTabs.astro b/src/components/tabs/AstroVueTabs.astro index 009f82488401f..f1dc5c7284842 100644 --- a/src/components/tabs/AstroVueTabs.astro +++ b/src/components/tabs/AstroVueTabs.astro @@ -6,12 +6,12 @@ import Tabs from './Tabs'; Vue Astro - + + - + + diff --git a/src/components/tutorial/TutorialNav.astro b/src/components/tutorial/TutorialNav.astro index f769c45108d28..269cae9c28482 100644 --- a/src/components/tutorial/TutorialNav.astro +++ b/src/components/tutorial/TutorialNav.astro @@ -19,7 +19,7 @@ const tutorialPages = getTutorialPages(pages, lang); const units = getTutorialUnits(tutorialPages); const makeUnitId = (index: number) => `${Astro.props.id}__tutorial-unit-nav-panel-${index}`; -const isCurrentUnit = (unit: typeof units[number]) => +const isCurrentUnit = (unit: (typeof units)[number]) => unit.lessons.some((lesson) => currentUrl.endsWith(lesson.slug)); --- diff --git a/src/content/docs/en/core-concepts/project-structure.mdx b/src/content/docs/en/core-concepts/project-structure.mdx index 1b0550f28d2d3..7f4faec74131e 100644 --- a/src/content/docs/en/core-concepts/project-structure.mdx +++ b/src/content/docs/en/core-concepts/project-structure.mdx @@ -62,12 +62,20 @@ Astro processes, optimizes, and bundles your `src/` files to create the final we Some files (like Astro components) are not even sent to the browser as written but are instead rendered to static HTML. Other files (like CSS) are sent to the browser but may be optimized or bundled with other CSS files for performance. +### `src/assets` + +The [`src/assets`](/en/guides/assets/) directory is the recommended folder to use for storing assets (e.g. images) that are processed by Astro. This is not required, and this is not a special reserved folder. + ### `src/components` **Components** are reusable units of code for your HTML pages. These could be [Astro components](/en/core-concepts/astro-components/), or [UI framework components](/en/core-concepts/framework-components/) like React or Vue. It is common to group and organize all of your project components together in this folder. This is a common convention in Astro projects, but it is not required. Feel free to organize your components however you like! +### `src/content` + +The `src/content/` directory is reserved to store [content collections](/en/guides/content-collections/) and an optional collections configuration file. No other files are allowed inside this folder. + ### `src/layouts` [Layouts](/en/core-concepts/layouts/) are a special kind of component that wrap some content in a larger page layout. These are most often used by [Astro pages](/en/core-concepts/astro-pages/) and [Markdown or MDX pages](/en/guides/markdown-content/) to define the layout of the page. diff --git a/src/content/docs/en/editor-setup.mdx b/src/content/docs/en/editor-setup.mdx index 69411824004ff..2133846cfd39d 100644 --- a/src/content/docs/en/editor-setup.mdx +++ b/src/content/docs/en/editor-setup.mdx @@ -53,6 +53,12 @@ In addition to local editors, Astro also runs well on in-browser hosted editors, See [the project's User Guide](https://ota-meshi.github.io/eslint-plugin-astro/user-guide/) for more information on how to install and set up ESLint for your project. +### Stylelint + +[Stylelint](https://stylelint.io/) is a popular linter for CSS. [A community maintained Stylelint configuration](https://github.com/ota-meshi/stylelint-config-html) provides Astro support. + +Installation instructions, editor integration, and additional information can be found in the project's README. + ### Prettier [Prettier](https://prettier.io/) is a popular formatter for JavaScript, HTML, CSS, and more. If you're using the [Astro VS Code Extension](https://marketplace.visualstudio.com/items?itemName=astro-build.astro-vscode) or [the Astro language server within another editor](#other-code-editors), code formatting with Prettier is included. diff --git a/src/content/docs/en/guides/backend.mdx b/src/content/docs/en/guides/backend.mdx index 2ea3eee920a7c..6954aaf156a6e 100644 --- a/src/content/docs/en/guides/backend.mdx +++ b/src/content/docs/en/guides/backend.mdx @@ -20,8 +20,8 @@ A backend service is a cloud-based system that helps you build and manage your b ## Why would I use a backend service? You might want to consider a backend service if your project has complex server-side needs, for example: -- user signups and authentication -- persistant data storage +- user sign-ups and authentication +- persistent data storage - user-uploaded asset storage - API generation - realtime communication diff --git a/src/content/docs/en/guides/backend/google-firebase.mdx b/src/content/docs/en/guides/backend/google-firebase.mdx index 71d5bbffe6c23..4ca50e555ee37 100644 --- a/src/content/docs/en/guides/backend/google-firebase.mdx +++ b/src/content/docs/en/guides/backend/google-firebase.mdx @@ -112,7 +112,7 @@ const firebaseConfig = { apiKey: "my-public-api-key", authDomain: "my-auth-domain", projectId: "my-project-id", - storageBucket: "my-storage-bucket, + storageBucket: "my-storage-bucket", messagingSenderId: "my-sender-id", appId: "my-app-id", }; @@ -186,7 +186,7 @@ Create three endpoints related to authentication in a new directory `src/pages/a ```ts title="src/pages/api/auth/signin.ts" import type { APIRoute } from "astro"; -import { app } from "../../../lib/firebase/server"; +import { app } from "../../../firebase/server"; import { getAuth } from "firebase-admin/auth"; export const get: APIRoute = async ({ request, cookies, redirect }) => { @@ -196,35 +196,29 @@ export const get: APIRoute = async ({ request, cookies, redirect }) => { const idToken = request.headers.get("Authorization")?.split("Bearer ")[1]; if (!idToken) { return new Response( - JSON.stringify({ - error: "No token found", - }), + "No token found", { status: 401 } ); } - /* Verify the token */ - const decodedToken = await auth.verifyIdToken(idToken).catch(() => null); - - if (!decodedToken) { + /* Verify id token */ + try { + await auth.verifyIdToken(idToken); + } catch (error) { return new Response( - JSON.stringify({ - error: "Invalid token", - }), + "Invalid token", { status: 401 } ); } - const fiveDays = 60 * 60 * 24 * 5 * 1000; - /* Create and set session cookie */ + const fiveDays = 60 * 60 * 24 * 5 * 1000; const sessionCookie = await auth.createSessionCookie(idToken, { expiresIn: fiveDays, }); cookies.set("session", sessionCookie, { path: "/", - // more options }); return redirect("/dashboard"); @@ -270,9 +264,7 @@ export const post: APIRoute = async ({ request, redirect }) => { if (!email || !password || !name) { return new Response( - JSON.stringify({ - error: "Missing data", - }), + "Missing form data", { status: 400 } ); } @@ -286,9 +278,7 @@ export const post: APIRoute = async ({ request, redirect }) => { }); } catch (error: any) { return new Response( - JSON.stringify({ - error: error.code, - }), + "Something went wrong", { status: 400 } ); } @@ -333,18 +323,19 @@ The example `src/pages/register.astro` below includes a form that will send a `P --- import Layout from "../layouts/Layout.astro"; --- + - Register + Register Already have an account? Sign in - + Name Email - + Password - - Login - + + Login + ``` @@ -372,44 +363,53 @@ if (sessionCookie) { --- - Sign in + Sign in New here? Create an account - + Email - + Password - - Login - + + Login + @@ -442,14 +442,14 @@ if (!user) { return Astro.redirect("/signin"); } --- + - Welcome {user.displayName} - We are happy to see you here + Welcome {user.displayName} + We are happy to see you here Sign out -
Already have an account? Sign in
New here? Create an account
We are happy to see you here