Merge branch 'main' into prefetch-intent
This commit is contained in:
commit
b4afcae5a4
4 changed files with 39 additions and 34 deletions
5
.changeset/soft-plants-hope.md
Normal file
5
.changeset/soft-plants-hope.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'astro': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Simplify internal resolver in dev
|
|
@ -1,4 +1,8 @@
|
||||||
---
|
---
|
||||||
|
export interface Props {
|
||||||
|
date: Date;
|
||||||
|
}
|
||||||
|
|
||||||
const { date } = Astro.props;
|
const { date } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ Feel free to check [our documentation](https://docs.astro.build) or jump into ou
|
||||||
|
|
||||||
### Site metadata
|
### Site metadata
|
||||||
|
|
||||||
`src/config.ts` contains several data objects that describe metadata about your site like title, description, default language, and Open Graph details. You can customize these to match your project.
|
`src/consts.ts` contains several data objects that describe metadata about your site like title, description, default language, and Open Graph details. You can customize these to match your project.
|
||||||
|
|
||||||
### CSS styling
|
### CSS styling
|
||||||
|
|
||||||
|
@ -82,19 +82,18 @@ For more SEO related properties, look at `src/components/HeadSEO.astro`
|
||||||
|
|
||||||
### Sidebar navigation
|
### Sidebar navigation
|
||||||
|
|
||||||
The sidebar navigation is controlled by the `SIDEBAR` variable in your `src/config.ts` file. You can customize the sidebar by modifying this object. A default, starter navigation has already been created for you.
|
The sidebar navigation is controlled by the `SIDEBAR` variable in your `src/consts.ts` file. You can customize the sidebar by modifying this object. A default, starter navigation has already been created for you.
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
export const SIDEBAR = {
|
export const SIDEBAR = {
|
||||||
en: [
|
en: {
|
||||||
{ text: "Section Header", header: true },
|
'Section Header': [
|
||||||
{ text: "Introduction", link: "en/introduction" },
|
{ text: 'Introduction', link: 'en/introduction' },
|
||||||
{ text: "Page 2", link: "en/page-2" },
|
{ text: 'Page 2', link: 'en/page-2' },
|
||||||
{ text: "Page 3", link: "en/page-3" },
|
{ text: 'Page 3', link: 'en/page-3' },
|
||||||
|
],
|
||||||
{ text: "Another Section", header: true },
|
'Another Section': [{ text: 'Page 4', link: 'en/page-4' }],
|
||||||
{ text: "Page 4", link: "en/page-4" },
|
},
|
||||||
],
|
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -118,10 +117,10 @@ To add a new language to your project, you'll want to extend the current `src/co
|
||||||
+ ┃ ┣ 📜 page-3.astro
|
+ ┃ ┣ 📜 page-3.astro
|
||||||
```
|
```
|
||||||
|
|
||||||
You'll also need to add the new language name to the `KNOWN_LANGUAGES` map in your `src/config.ts` file. This will enable your new language switcher in the site header.
|
You'll also need to add the new language name to the `KNOWN_LANGUAGES` map in your `src/consts.ts` file. This will enable your new language switcher in the site header.
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
// src/config.ts
|
// src/consts.ts
|
||||||
export const KNOWN_LANGUAGES = {
|
export const KNOWN_LANGUAGES = {
|
||||||
English: 'en',
|
English: 'en',
|
||||||
+ Spanish: 'es',
|
+ Spanish: 'es',
|
||||||
|
@ -133,18 +132,22 @@ Last step: you'll need to add a new entry to your sidebar, to create the table o
|
||||||
> Make sure the sidebar `link` value points to the correct language!
|
> Make sure the sidebar `link` value points to the correct language!
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
// src/config.ts
|
// src/consts.ts
|
||||||
export const SIDEBAR = {
|
export const SIDEBAR = {
|
||||||
en: [
|
en: {
|
||||||
{ text: 'Section Header', header: true, },
|
'Section Header': [
|
||||||
{ text: 'Introduction', link: 'en/introduction' },
|
{ text: 'Introduction', link: 'en/introduction' },
|
||||||
// ...
|
// ...
|
||||||
],
|
],
|
||||||
+ es: [
|
// ...
|
||||||
+ { text: 'Encabezado de sección', header: true, },
|
},,
|
||||||
+ { text: 'Introducción', link: 'es/introduction' },
|
+ es: {
|
||||||
+ // ...
|
+ 'Encabezado de sección': [
|
||||||
+ ],
|
+ { text: 'Introducción', link: 'en/introduction' },
|
||||||
|
+ // ...
|
||||||
|
+ ],
|
||||||
|
+ // ...
|
||||||
|
+ },
|
||||||
};
|
};
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
@ -169,8 +172,8 @@ If that single language is not English, you can just replace `en` in directory l
|
||||||
|
|
||||||
### Search (Powered by Algolia)
|
### Search (Powered by Algolia)
|
||||||
|
|
||||||
[Algolia](https://www.algolia.com/) offers a free service to qualified open source projects called [DocSearch](https://docsearch.algolia.com/). If you are accepted to the DocSearch program, provide your API Key & index name in `src/config.ts` and a search box will automatically appear in your site header.
|
[Algolia](https://www.algolia.com/) offers a free service to qualified open source projects called [DocSearch](https://docsearch.algolia.com/). If you are accepted to the DocSearch program, provide your API Key & index name in `src/consts.ts` and a search box will automatically appear in your site header.
|
||||||
|
|
||||||
Note that Aglolia and Astro are not affiliated. We have no say over acceptance to the DocSearch program.
|
Note that Algolia and Astro are not affiliated. We have no say over acceptance to the DocSearch program.
|
||||||
|
|
||||||
If you'd prefer to remove Algolia's search and replace it with your own, check out the `src/components/Header.astro` component to see where the component is added.
|
If you'd prefer to remove Algolia's search and replace it with your own, check out the `src/components/Header.astro` component to see where the component is added.
|
||||||
|
|
|
@ -8,13 +8,6 @@ export function createResolve(loader: ModuleLoader, root: URL) {
|
||||||
// - /Users/macos/project/src/Foo.vue
|
// - /Users/macos/project/src/Foo.vue
|
||||||
// - C:/Windows/project/src/Foo.vue (normalized slash)
|
// - C:/Windows/project/src/Foo.vue (normalized slash)
|
||||||
return async function (s: string) {
|
return async function (s: string) {
|
||||||
const url = await resolveIdToUrl(loader, s, root);
|
return await resolveIdToUrl(loader, s, root);
|
||||||
// Vite does not resolve .jsx -> .tsx when coming from hydration script import,
|
|
||||||
// clip it so Vite is able to resolve implicitly.
|
|
||||||
if (url.startsWith('/') && url.endsWith('.jsx')) {
|
|
||||||
return url.slice(0, -4);
|
|
||||||
} else {
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue