add algolia and cleanup docs readme
This commit is contained in:
parent
b7ada11ddb
commit
2e8db7ad23
19 changed files with 286 additions and 617 deletions
|
@ -4,25 +4,134 @@
|
|||
npm init astro -- --template docs
|
||||
```
|
||||
|
||||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||
## Features
|
||||
|
||||
Features:
|
||||
- ✅ **Full Markdown support**
|
||||
- ✅ **Responsive mobile-friendly design**
|
||||
- ✅ **Sidebar navigation**
|
||||
- ✅ **Search (powered by Algolia)**
|
||||
- ✅ **Multi-language i18n**
|
||||
- ✅ **Automatic table of contents**
|
||||
- ✅ **Automatic list of contributors**
|
||||
- ✅ (and, best of all) **dark mode**
|
||||
|
||||
- ✅ CSS Grid Layout
|
||||
- ✅ Full Markdown support
|
||||
- ✅ Automatic header navigation sidebar
|
||||
- ✅ Dark mode enabled by default
|
||||
|
||||
## 🧞 Commands
|
||||
## Commands Cheatsheet
|
||||
|
||||
All commands are run from the root of the project, from a terminal:
|
||||
|
||||
| Command | Action |
|
||||
|:----------------|:--------------------------------------------|
|
||||
| `npm install` | Installs dependencies |
|
||||
| `npm run dev` | Starts local dev server at `localhost:3000` |
|
||||
| `npm run build` | Build your production site to `./dist/` |
|
||||
| Command | Action |
|
||||
|:-----------------|:---------------------------------------------|
|
||||
| `npm install` | Installs dependencies |
|
||||
| `npm run dev` | Starts local dev server at `localhost:3000` |
|
||||
| `npm run build` | Build your production site to `./dist/` |
|
||||
| `npm run preview`| Preview your build locally, before deploying |
|
||||
|
||||
## 👀 Want to learn more?
|
||||
To deploy your site to production, check out our [Deploy an Astro Website](https://docs.astro.build/guides/deploy) guide.
|
||||
|
||||
Feel free to check [our documentation](https://github.com/snowpackjs/astro) or jump into our [Discord server](https://astro.build/chat).
|
||||
## New to Astro?
|
||||
|
||||
Welcome! Check out [our documentation](https://github.com/snowpackjs/astro) or jump into our [Discord server](https://astro.build/chat).
|
||||
|
||||
## Customize This Theme
|
||||
|
||||
### 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.
|
||||
### CSS styling
|
||||
|
||||
The theme's look and feel is controlled by a few key variables that you can customize yourself. You'll find them in the `public/theme.css` CSS file.
|
||||
|
||||
If you've never worked with CSS variables before, give [MDN's guide on CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) a quick read.
|
||||
|
||||
This theme uses a "cool blue" accent color by default. To customize this for your project, change the `--theme-accent` variable to whatever color you'd like:
|
||||
|
||||
```diff
|
||||
/* public/theme.css */
|
||||
:root {
|
||||
color-scheme: light;
|
||||
- --theme-accent: hsla(var(--color-blue), 1);
|
||||
+ --theme-accent: hsla(var(--color-red), 1); /* or: hsla(#FF0000, 1); */
|
||||
```
|
||||
|
||||
|
||||
### 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.
|
||||
|
||||
```ts
|
||||
export const SIDEBAR = {
|
||||
en: [
|
||||
{ text: 'Section Header', header: true, },
|
||||
{ text: 'Introduction', link: 'en/introduction' },
|
||||
{ text: 'Page 2', link: 'en/page-2' },
|
||||
{ text: 'Page 3', link: 'en/page-3' },
|
||||
|
||||
{ text: 'Another Section', header: true },
|
||||
{ text: 'Page 4', link: 'en/page-4' },
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
Note the top-level `en` key: This is needed for multi-language support. You can change it to whatever language you'd like, or add new languages as you go. More details on this below.
|
||||
|
||||
### Multiple Languages support
|
||||
|
||||
The Astro docs template supports multiple langauges out of the box. The default theme only shows `en` documentation, but you can enable multi-language support features by adding a second language to your project.
|
||||
|
||||
To add a new language to your project, you'll want to extend the current `src/pages/[lang]/...` layout:
|
||||
|
||||
```diff
|
||||
📂 src/pages
|
||||
┣ 📂 en
|
||||
┃ ┣ 📜 page-1.md
|
||||
┃ ┣ 📜 page-2.md
|
||||
┃ ┣ 📜 page-3.astro
|
||||
+ ┣ 📂 es
|
||||
+ ┃ ┣ 📜 page-1.md
|
||||
+ ┃ ┣ 📜 page-2.md
|
||||
+ ┃ ┣ 📜 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.
|
||||
|
||||
```diff
|
||||
// src/config.ts
|
||||
export const KNOWN_LANGUAGES = {
|
||||
English: 'en',
|
||||
+ Spanish: 'es',
|
||||
};
|
||||
```
|
||||
|
||||
Last step: you'll need to add a new entry to your sidebar, to create the table of contents for that language. While duplicating every page might not sound ideal to everyone, this extra control allows you to create entirely custom content for every language.
|
||||
|
||||
> Make sure the sidebar `link` value points to the correct language!
|
||||
|
||||
```diff
|
||||
// src/config.ts
|
||||
export const SIDEBAR = {
|
||||
en: [
|
||||
{ text: 'Section Header', header: true, },
|
||||
{ text: 'Introduction', link: 'en/introduction' },
|
||||
// ...
|
||||
],
|
||||
+ es: [
|
||||
+ { text: 'Encabezado de sección', header: true, },
|
||||
+ { text: 'Introducción', link: 'es/introduction' },
|
||||
+ // ...
|
||||
+ ],
|
||||
};
|
||||
|
||||
// ...
|
||||
```
|
||||
|
||||
### What if I don't plan to support multiple languages?
|
||||
|
||||
That's totally fine! Not all projects need (or can support) multiple languages. You can continue to use this theme without ever adding a second language.
|
||||
|
||||
### 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.
|
||||
|
||||
Note that Aglolia 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.
|
|
@ -56,8 +56,8 @@
|
|||
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--theme-accent: hsla(var(--color-orange), 1);
|
||||
--theme-text-accent: hsla(var(--color-orange), 1);
|
||||
--theme-accent: hsla(var(--color-blue), 1);
|
||||
--theme-text-accent: hsla(var(--color-blue), 1);
|
||||
--theme-accent-opacity: 0.1;
|
||||
--theme-divider: hsla(var(--color-gray-95), 1);
|
||||
--theme-text: hsla(var(--color-gray-10), 1);
|
||||
|
@ -67,15 +67,15 @@
|
|||
--theme-bg: hsla(var(--color-base-white), 100%, 1);
|
||||
--theme-bg-hover: hsla(var(--color-gray-95), 1);
|
||||
--theme-bg-offset: hsla(var(--color-gray-90), 1);
|
||||
--theme-bg-accent: hsla(var(--color-orange), var(--theme-accent-opacity));
|
||||
--theme-bg-accent: hsla(var(--color-blue), var(--theme-accent-opacity));
|
||||
--theme-code-inline-bg: hsla(var(--color-gray-95), 1);
|
||||
--theme-code-inline-text: var(--theme-text);
|
||||
--theme-code-bg: hsla(217, 19%, 27%, 1);
|
||||
--theme-code-text: hsla(var(--color-gray-95), 1);
|
||||
--theme-navbar-bg: hsla(var(--color-base-white), 100%, 1);
|
||||
--theme-navbar-height: 6rem;
|
||||
--theme-selection-color: hsla(var(--color-orange), 1);
|
||||
--theme-selection-bg: hsla(var(--color-orange), var(--theme-accent-opacity));
|
||||
--theme-selection-color: hsla(var(--color-blue), 1);
|
||||
--theme-selection-bg: hsla(var(--color-blue), var(--theme-accent-opacity));
|
||||
}
|
||||
|
||||
body {
|
||||
|
|
|
@ -18,7 +18,7 @@ const imageAlt = content?.image?.alt ?? OPEN_GRAPH.image.alt;
|
|||
<meta property="og:title" content={formattedContentTitle}/>
|
||||
<meta property="og:type" content="article"/>
|
||||
<meta property="og:url" content={canonicalURL}/>
|
||||
<meta property="og:locale" content={content.ogLocale ?? OPEN_GRAPH.locale}/>
|
||||
<meta property="og:locale" content={content.ogLocale ?? SITE.defaultLanguage}/>
|
||||
<meta property="og:image" content={canonicalImageSrc}/>
|
||||
<meta property="og:image:alt" content={imageAlt}/>
|
||||
<meta property="og:description" content={content.description ? content.description : SITE.description}/>
|
||||
|
|
|
@ -4,12 +4,10 @@ const {size} = Astro.props;
|
|||
<svg class="logo" width={size} height={size} viewBox="0 0 256 256" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
#flame {
|
||||
/* fill: #ff5d01; */
|
||||
fill: #3894ff;
|
||||
fill: var(--theme-text-accent);
|
||||
}
|
||||
#a {
|
||||
/* fill: #000014; */
|
||||
fill: #3894ff;
|
||||
fill: var(--theme-text-accent);
|
||||
}
|
||||
</style>
|
||||
<title>Logo</title>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
---
|
||||
import { getLanguageFromURL, KNOWN_LANGUAGE_CODES } from '../../languages.ts';
|
||||
import * as CONFIG from '../../config.ts';
|
||||
import AstroLogo from './AstroLogo.astro';
|
||||
import SkipToContent from './SkipToContent.astro';
|
||||
import SidebarToggle from './SidebarToggle.tsx';
|
||||
import LanguageSelect from './LanguageSelect.jsx';
|
||||
import Search from "./Search.jsx";
|
||||
import { getLanguageFromURL } from '../util.ts';
|
||||
|
||||
const {currentPage} = Astro.props;
|
||||
const lang = currentPage && getLanguageFromURL(currentPage);
|
||||
|
@ -27,40 +29,30 @@ const lang = currentPage && getLanguageFromURL(currentPage);
|
|||
display: flex;
|
||||
overflow: hidden;
|
||||
width: 30px;
|
||||
font-size: 1rem;
|
||||
font-size: 2rem;
|
||||
flex-shrink: 0;
|
||||
font-weight: 600;
|
||||
line-height: 1;
|
||||
color: hsla(var(--color-base-white), 100%, 1);
|
||||
text-decoration: none;
|
||||
gap: 0.5em;
|
||||
gap: 0.25em;
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
.logo a {
|
||||
padding: 0.5em 0.25em;
|
||||
margin: -0.5em -0.25em;
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.logo svg {
|
||||
height: 40px;
|
||||
width: auto;
|
||||
display: block;
|
||||
color: var(--theme-accent);
|
||||
}
|
||||
|
||||
.logo .hover {
|
||||
opacity: 0.0;
|
||||
}
|
||||
.logo a {
|
||||
transition: transform 180ms ease-out;
|
||||
transition: color 100ms ease-out;
|
||||
color: var(--theme-text);
|
||||
}
|
||||
|
||||
.logo a:hover,
|
||||
.logo a:focus {
|
||||
outline: none;
|
||||
opacity: 1.0;
|
||||
transform: translateY(-2px);
|
||||
color: var(--theme-text-accent);
|
||||
}
|
||||
|
||||
.logo h1 {
|
||||
|
@ -82,7 +74,7 @@ const lang = currentPage && getLanguageFromURL(currentPage);
|
|||
@media (min-width: 50em) {
|
||||
header {
|
||||
position: static;
|
||||
padding: 2rem 0rem 0 2rem;
|
||||
padding: 2rem 0rem;
|
||||
}
|
||||
.logo {
|
||||
width: auto;
|
||||
|
@ -128,31 +120,13 @@ const lang = currentPage && getLanguageFromURL(currentPage);
|
|||
<SidebarToggle client:idle/>
|
||||
</div>
|
||||
<div class="logo flex">
|
||||
<AstroLogo size={40} />
|
||||
<a href="/">
|
||||
<h1 class="sr-only">Astro</h1>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="363" height="102" viewBox="0 0 363 102" fill="none">
|
||||
<style>
|
||||
.text {
|
||||
fill: var(--theme-text);
|
||||
}
|
||||
.hover {
|
||||
fill: var(--theme-accent);
|
||||
}
|
||||
</style>
|
||||
<path class="text" fill-rule="evenodd" d="M55.07 14.216l16.81 54.865a72.6 72.6 0 00-20.765-6.984L39.808 24.135a1.475 1.475 0 00-2.827.005L25.81 62.078a72.598 72.598 0 00-20.859 6.995L21.847 14.2c.998-3.243 1.497-4.865 2.47-6.066a8 8 0 013.239-2.392c1.434-.576 3.13-.576 6.524-.576h8.751c3.398 0 5.097 0 6.532.577a8 8 0 013.241 2.397c.972 1.203 1.47 2.827 2.465 6.076z" clip-rule="evenodd"/>
|
||||
<path fill="#FF5D01" fill-rule="evenodd" d="M54.618 71.779c-2.863 2.432-8.578 4.091-15.161 4.091-8.08 0-14.852-2.499-16.649-5.86-.642 1.926-.786 4.13-.786 5.539 0 0-.423 6.915 4.418 11.725 0-2.498 2.037-4.522 4.551-4.522 4.309 0 4.304 3.734 4.3 6.764v.27c0 4.6 2.829 8.541 6.852 10.203a9.22 9.22 0 01-.938-4.064c0-4.386 2.592-6.02 5.604-7.917 2.396-1.51 5.06-3.188 6.894-6.554a12.297 12.297 0 001.502-5.905c0-1.314-.206-2.581-.587-3.77z" clip-rule="evenodd"/>
|
||||
<path class="text" d="M126.554 69c13.115 0 21.047-3.14 25.68-9.654 0 2.904.157 5.651.55 8.163h7.774c-.706-4.082-.863-6.75-.863-14.128V43.334c0-10.831-8.403-16.56-24.424-16.56-15.47 0-25.522 5.964-26.779 14.598h8.246c1.256-5.808 7.774-8.87 18.533-8.87 10.602 0 16.885 3.69 16.885 9.969v.785l-24.502 1.413c-9.974.549-13.665 1.962-16.492 4.003-2.67 1.962-4.162 5.023-4.162 8.555C107 64.683 114.696 69 126.554 69zm2.513-5.573c-9.109 0-14.135-2.119-14.135-6.357 0-4.553 3.141-6.593 14.214-7.3l23.01-1.412v1.805c0 8.241-9.66 13.264-23.089 13.264zM196.086 69c16.256 0 22.775-5.337 22.775-13.108 0-6.436-4.006-9.732-14.215-10.596l-19.083-1.49c-5.183-.393-8.088-1.884-8.088-5.102 0-4.082 4.476-6.201 14.135-6.201 10.995 0 16.727 2.198 20.497 7.064l6.361-3.061c-3.927-6.122-12.644-9.733-26.151-9.733-13.9 0-22.224 4.631-22.224 12.244 0 6.829 4.947 10.125 14.292 10.91l18.926 1.492c6.204.47 8.089 1.726 8.089 4.944 0 4.631-4.79 6.829-14.293 6.829-11.544 0-18.847-3.14-22.381-8.87l-6.204 3.376C173.312 64.918 181.715 69 196.086 69zM234.929 34.151v18.916c0 7.77 2.67 15.54 17.198 15.54 3.691 0 8.167-.706 10.131-1.57V60.68c-2.749.628-6.047 1.1-9.267 1.1-6.832 0-10.523-2.67-10.523-9.42V34.151h19.633v-5.887h-19.633V15l-7.539 3.061v10.204h-12.33v5.886h12.33zM280.823 28.265h-6.911v39.244h7.461V52.83c0-5.65 1.099-10.439 4.24-13.735 2.749-3.061 6.283-4.788 12.487-4.788 2.12 0 3.455.157 5.262.471v-7.22c-1.65-.393-3.063-.472-5.184-.472-8.402 0-15.078 4.945-17.355 12.558v-11.38zM334.807 69C351.534 69 363 60.523 363 47.887c0-12.637-11.466-21.114-28.193-21.114-16.727 0-28.193 8.477-28.193 21.114C306.614 60.523 318.08 69 334.807 69zm0-6.2c-12.329 0-20.261-5.809-20.261-14.913 0-9.105 7.932-14.913 20.261-14.913 12.251 0 20.261 5.808 20.261 14.913 0 9.104-8.01 14.912-20.261 14.912z"/>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="/">
|
||||
<h1 class="sr-only">Docs</h1>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="226" height="102" viewBox="0 0 226 102" fill="none">
|
||||
<path fill="currentColor" d="M25.805 68c14.688 0 24.883-8.41 24.883-21.14 0-12.786-9.62-19.756-24.653-19.756H0V68h25.805zm-14.17-33.005H24.25c8.352 0 14.17 4.09 14.17 12.039 0 8.236-5.3 13.075-14.113 13.075H11.635V34.995zM82.673 69.382c16.704 0 27.418-8.582 27.418-21.83 0-13.248-10.771-21.83-27.418-21.83-16.589 0-27.418 8.582-27.418 21.83 0 13.19 10.83 21.83 27.418 21.83zm0-8.64c-9.1 0-15.149-5.299-15.149-13.19 0-7.891 6.048-13.19 15.15-13.19 9.1 0 15.205 5.299 15.205 13.19 0 7.891-6.105 13.19-15.206 13.19zM141.497 69.382c13.306 0 22.637-5.299 25.978-14.572l-11.866-2.535c-1.67 5.415-6.393 8.295-13.709 8.295-9.216 0-15.033-5.127-15.033-13.018 0-8.006 5.702-13.018 14.918-13.018 7.43 0 12.154 3.053 13.709 8.64l12.038-2.13c-2.707-9.562-12.268-15.322-25.574-15.322-16.128 0-27.302 9.043-27.302 22.003 0 13.133 10.425 21.657 26.841 21.657zM194.94 69.382c14.745 0 23.212-5.01 23.212-14.054 0-7.603-4.665-10.944-15.955-12.096l-11.289-1.094c-5.242-.576-6.97-1.556-6.97-4.09 0-2.765 3.456-4.262 9.792-4.262 7.834 0 13.709 2.476 16.762 6.508l7.315-6.163c-5.069-5.702-13.133-8.41-23.501-8.41-13.997 0-21.888 4.781-21.888 12.903 0 7.546 4.781 11.232 14.803 12.326l12.557 1.383c4.896.518 6.624 1.555 6.624 4.09 0 3.225-3.456 4.723-10.886 4.723-8.352 0-14.688-3.226-18.087-8.007l-8.294 5.818c4.205 6.451 13.709 10.425 25.805 10.425z"/>
|
||||
</svg>
|
||||
<h1>Documentation</h1>
|
||||
</a>
|
||||
</div>
|
||||
<div style="flex-grow: 1;"></div>
|
||||
{lang && <LanguageSelect lang={lang} client:idle />}
|
||||
<div class="search-item"><Search client:idle /></div>
|
||||
{KNOWN_LANGUAGE_CODES.length > 1 && <LanguageSelect lang={lang} client:idle />}
|
||||
{CONFIG.ALGOLIA && <div class="search-item"><Search client:idle /></div>}
|
||||
</nav>
|
||||
</header>
|
|
@ -1,7 +1,7 @@
|
|||
import type { FunctionalComponent } from 'preact';
|
||||
import { h } from 'preact';
|
||||
import './LanguageSelect.css';
|
||||
import { LANGUAGE_NAMES, langPathRegex } from '../../languages';
|
||||
import { KNOWN_LANGUAGES, langPathRegex } from '../../languages';
|
||||
|
||||
const LanguageSelect: FunctionalComponent<{ lang: string }> = ({ lang }) => {
|
||||
return (
|
||||
|
@ -23,9 +23,9 @@ const LanguageSelect: FunctionalComponent<{ lang: string }> = ({ lang }) => {
|
|||
window.location.pathname = '/' + newLang + actualDest;
|
||||
}}
|
||||
>
|
||||
{Object.keys(LANGUAGE_NAMES).map((key) => {
|
||||
{Object.keys(KNOWN_LANGUAGES).map((key) => {
|
||||
return (
|
||||
<option value={LANGUAGE_NAMES[key]}>
|
||||
<option value={KNOWN_LANGUAGES[key]}>
|
||||
<span>{key}</span>
|
||||
</option>
|
||||
);
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
import { useState, useCallback, useRef } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { DocSearchModal, useDocSearchKeyboardEvents } from '@docsearch/react';
|
||||
import '@docsearch/css//dist/style.css';
|
||||
import * as CONFIG from '../../config.js';
|
||||
import '@docsearch/css/dist/style.css';
|
||||
import './Search.css';
|
||||
|
||||
export default function Search() {
|
||||
|
@ -53,8 +54,8 @@ export default function Search() {
|
|||
initialQuery={initialQuery}
|
||||
initialScrollY={window.scrollY}
|
||||
onClose={onClose}
|
||||
indexName="astro"
|
||||
apiKey="0f387260ad74f9cbf4353facd29c919c"
|
||||
indexName={(CONFIG as any).ALGOLIA.indexName}
|
||||
apiKey={(CONFIG as any).ALGOLIA.apiKey}
|
||||
transformItems={(items) => {
|
||||
return items.map((item) => {
|
||||
// We transform the absolute URL into a relative URL to
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
---
|
||||
import { getLanguageFromURL } from '../../languages.ts';
|
||||
import { SIDEBAR } from '../../config.ts';
|
||||
import { getLanguageFromURL } from '../util.ts';
|
||||
const {currentPage} = Astro.props;
|
||||
const currentPageMatch = currentPage.slice(1);
|
||||
const langCode = getLanguageFromURL(currentPage);
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
export function getLanguageFromURL(pathname: string) {
|
||||
const langCodeMatch = pathname.match(/\/([a-z]{2}-?[A-Z]{0,2})\//);
|
||||
return langCodeMatch ? langCodeMatch[1] : 'en';
|
||||
}
|
|
@ -1,22 +1,36 @@
|
|||
export const SIDEBAR = {
|
||||
en: [
|
||||
{ text: 'Getting Started', header: true },
|
||||
{ text: 'Introduction', link: 'en/introduction' },
|
||||
{ text: 'Getting Started', link: 'en/getting-started' },
|
||||
{ text: 'Example', link: 'en/example' },
|
||||
],
|
||||
};
|
||||
|
||||
export const SITE = {
|
||||
title: 'Astro Documentation',
|
||||
description: 'Build faster websites with less client-side Javascript.',
|
||||
title: 'Your Documentation Website',
|
||||
description: 'Your website description.',
|
||||
defaultLanguage: 'en_US',
|
||||
};
|
||||
|
||||
export const OPEN_GRAPH = {
|
||||
locale: 'en_US',
|
||||
image: {
|
||||
src: 'https://github.com/snowpackjs/astro/blob/main/assets/social/banner.png?raw=true',
|
||||
alt: 'astro logo on a starry expanse of space,' + ' with a purple saturn-like planet floating in the right foreground',
|
||||
},
|
||||
twitter: 'astrodotbuild',
|
||||
};
|
||||
|
||||
export const KNOWN_LANGUAGES = {
|
||||
English: 'en',
|
||||
};
|
||||
|
||||
// Uncomment this to enable site search.
|
||||
// See "Algolia" section of the README for more information.
|
||||
// export const ALGOLIA = {
|
||||
// indexName: 'XXXXXXXXXX',
|
||||
// apiKey: 'XXXXXXXXXX',
|
||||
// }
|
||||
|
||||
export const SIDEBAR = {
|
||||
en: [
|
||||
{ text: 'Section Header', header: true },
|
||||
{ text: 'Introduction', link: 'en/introduction' },
|
||||
{ text: 'Page 2', link: 'en/page-2' },
|
||||
{ text: 'Page 3', link: 'en/page-3' },
|
||||
|
||||
{ text: 'Another Section', header: true },
|
||||
{ text: 'Page 4', link: 'en/page-4' },
|
||||
],
|
||||
};
|
||||
|
|
|
@ -1,19 +1,8 @@
|
|||
export const LANGUAGE_NAMES = {
|
||||
English: 'en',
|
||||
};
|
||||
import { KNOWN_LANGUAGES } from './config.js';
|
||||
|
||||
export const KNOWN_LANGUAGES = Object.values(LANGUAGE_NAMES);
|
||||
export const langPathRegex = new RegExp(`\/(${KNOWN_LANGUAGES.join('|')})\/`);
|
||||
export const getLanguageDetails = () => {
|
||||
// @ts-ignore
|
||||
let newLangWithRegion = (window.navigator.userLanguage || window.navigator.language || 'en-US').substr(0, 5);
|
||||
let newLang = newLangWithRegion.substr(0, 2);
|
||||
export const KNOWN_LANGUAGE_CODES = Object.values(KNOWN_LANGUAGES);
|
||||
|
||||
let actualDest = window.location.pathname.replace(langPathRegex, '/');
|
||||
return {
|
||||
newLangWithRegion,
|
||||
newLang,
|
||||
langPathRegex,
|
||||
actualDest,
|
||||
};
|
||||
};
|
||||
export function getLanguageFromURL(pathname: string) {
|
||||
const langCodeMatch = pathname.match(/\/([a-z]{2}-?[A-Z]{0,2})\//);
|
||||
return langCodeMatch ? langCodeMatch[1] : 'en';
|
||||
}
|
||||
|
|
|
@ -1,239 +0,0 @@
|
|||
---
|
||||
// Component Imports
|
||||
import ArticleFooter from '../components/ArticleFooter.astro';
|
||||
import SiteSidebar from '../components/SiteSidebar.astro';
|
||||
import ThemeToggle from '../components/ThemeToggle.tsx';
|
||||
import DocSidebar from '../components/DocSidebar.tsx';
|
||||
|
||||
// Component Script:
|
||||
// You can write any JavaScript/TypeScript that you'd like here.
|
||||
// It will run during the build, but never in the browser.
|
||||
// All variables are available to use in the HTML template below.
|
||||
const { content } = Astro.props;
|
||||
const headers = content.astro.headers;
|
||||
const currentPage = Astro.request.url.pathname;
|
||||
const currentFile = currentPage === '/' ? 'src/pages/index.md' : `src/pages${currentPage.replace(/\/$/, "")}.md`;
|
||||
const githubEditUrl = `https://github.com/USER/REPO/blob/main/${currentFile}`
|
||||
|
||||
// Full Astro Component Syntax:
|
||||
// https://docs.astro.build/core-concepts/astro-components/
|
||||
---
|
||||
<html lang={ content.lang || 'en' }>
|
||||
<head>
|
||||
<title>{content.title}</title>
|
||||
|
||||
<link rel="stylesheet" href="/index.css" />
|
||||
<link rel="stylesheet" href="/theme.css" />
|
||||
<link rel="stylesheet" href="/code.css" />
|
||||
<script src="/theme.js" />
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
|
||||
|
||||
<style>
|
||||
body {
|
||||
width: 100%;
|
||||
display: grid;
|
||||
grid-template-rows: 3.5rem 1fr;
|
||||
--gutter: 0.5rem;
|
||||
--doc-padding: 2rem;
|
||||
}
|
||||
|
||||
header {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: var(--theme-bg-offset);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.layout {
|
||||
display: grid;
|
||||
grid-auto-flow: column;
|
||||
grid-template-columns: minmax(var(--gutter), 1fr) minmax(0, var(--max-width)) minmax(var(--gutter), 1fr);
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
.menu-and-logo {
|
||||
gap: 1em;
|
||||
}
|
||||
|
||||
nav.layout {
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
nav.layout :global(> :nth-child(1)) {
|
||||
grid-column: 2;
|
||||
}
|
||||
|
||||
#site-title {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.25em;
|
||||
font-size: 1.5rem;
|
||||
font-weight: 700;
|
||||
margin: 0;
|
||||
line-height: 1;
|
||||
color: var(--theme-text);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#site-title:hover,
|
||||
#site-title:focus {
|
||||
color: var(--theme-text-light);
|
||||
}
|
||||
|
||||
#site-title h1 {
|
||||
font: inherit;
|
||||
color: inherit;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.nav-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
width: 100%;
|
||||
max-width: 64ch;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.layout :global(> *) {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
max-height: 100vh;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
padding: var(--doc-padding) 0;
|
||||
}
|
||||
|
||||
#sidebar-nav {
|
||||
display: none;
|
||||
max-height: 100vh;
|
||||
padding: var(--doc-padding) 0;
|
||||
}
|
||||
|
||||
#article {
|
||||
padding: var(--doc-padding) var(--gutter);
|
||||
grid-column: 2;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.content {
|
||||
max-width: 64ch;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content > main {
|
||||
margin-bottom: 4rem;
|
||||
}
|
||||
|
||||
#sidebar-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@media (min-width: 64em) {
|
||||
.menu-and-logo button {
|
||||
display: none;
|
||||
}
|
||||
.layout {
|
||||
grid-template-columns: 20rem minmax(0, 1fr);
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
}
|
||||
#article {
|
||||
grid-column: 2;
|
||||
}
|
||||
#sidebar-nav {
|
||||
display: flex;
|
||||
}
|
||||
#sidebar-content {
|
||||
/* display: flex; */
|
||||
grid-column: 3;
|
||||
}
|
||||
|
||||
.nav-wrapper {
|
||||
display: contents;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 88em) {
|
||||
.layout {
|
||||
grid-template-columns: minmax(var(--gutter), 1fr) 20rem minmax(0, var(--max-width)) 16rem minmax(var(--gutter), 1fr);
|
||||
padding-left: 0;
|
||||
padding-right: 0;
|
||||
}
|
||||
|
||||
#sidebar-nav,
|
||||
.nav-wrapper :global(:nth-child(1)) {
|
||||
grid-column: 2;
|
||||
}
|
||||
#article,
|
||||
.nav-wrapper :global(:nth-child(2)) {
|
||||
grid-column: 3;
|
||||
}
|
||||
#sidebar-content,
|
||||
.nav-wrapper :global(:nth-child(3)) {
|
||||
display: flex;
|
||||
grid-column: 4;
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<header>
|
||||
<nav class="layout">
|
||||
<div class="nav-wrapper">
|
||||
<div class="menu-and-logo flex">
|
||||
<button id="menu-toggle">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h16M4 18h16" />
|
||||
</svg>
|
||||
</button>
|
||||
<a id="site-title" href="/">
|
||||
<svg width="1em" height="1em" viewBox="0 0 340 340" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M320 170C320 170 296.88 171.746 267.428 188.75C237.975 205.754 205.754 237.975 188.75 267.428C171.746 296.88 170 320 170 320C170 320 168.254 296.88 151.25 267.428C134.246 237.975 102.025 205.754 72.5721 188.75C43.1197 171.746 20 170 20 170C20 170 43.1197 168.254 72.5721 151.25C102.025 134.246 134.246 102.025 151.25 72.5721C168.254 43.1197 170 20 170 20C170 20 171.746 43.1197 188.75 72.5721C205.754 102.025 237.975 134.246 267.428 151.25C296.88 168.254 320 170 320 170Z" fill="currentColor"/>
|
||||
</svg>
|
||||
<h1>Astroid</h1>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div />
|
||||
|
||||
<div>
|
||||
<ThemeToggle client:idle />
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<main class="layout">
|
||||
<aside class="sidebar" id="sidebar-nav">
|
||||
<SiteSidebar />
|
||||
</aside>
|
||||
<div id="article">
|
||||
<article class="content">
|
||||
<main>
|
||||
<h1>{content.title}</h1>
|
||||
<slot />
|
||||
</main>
|
||||
<ArticleFooter />
|
||||
</article>
|
||||
</div>
|
||||
<aside class="sidebar" id="sidebar-content">
|
||||
<DocSidebar client:idle headers={headers} editHref={githubEditUrl} />
|
||||
</aside>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
|
@ -1,190 +0,0 @@
|
|||
---
|
||||
title: Getting Started
|
||||
layout: ~/layouts/MainLayout.astro
|
||||
---
|
||||
|
||||
This template already provides your pages with a side bar navigation (on the left) for your pages, and a content navigation (on the right) for your sections.
|
||||
|
||||
## Page navigation
|
||||
|
||||
The page navigation, through the side bar on the left, needs to be manually updated. Open the `config.ts` file and you will find the following structure:
|
||||
|
||||
```ts
|
||||
export const SIDEBAR = {
|
||||
en: [
|
||||
{ text: 'Getting Started', header: true },
|
||||
{ text: 'Introduction', link: 'en/introduction' },
|
||||
{ text: 'Getting Started', link: 'en/getting-started' },
|
||||
{ text: 'Example', link: 'en/example' },
|
||||
],
|
||||
es: [
|
||||
{ text: 'Empezando', header: true },
|
||||
{ text: 'Introducción', link: 'es/introduction' },
|
||||
{ text: 'Empezando', link: 'es/getting-started' },
|
||||
{ text: 'Ejemplo', link: 'es/example' },
|
||||
],
|
||||
fr: [
|
||||
{ text: 'Commencer', header: true },
|
||||
{ text: 'Introduction', link: 'fr/introduction' },
|
||||
{ text: 'Commencer', link: 'fr/getting-started' },
|
||||
{ text: 'Exemple', link: 'fr/example' },
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
The sidebar supports many languages, and each language has items to display, and pages to link to, allowing for a truly native experience for international users. You can change this file to match the pages you want to display, the object with the `{ header: true, ... }` set to true will act as a section title and cannot contain a link.
|
||||
|
||||
The page navigation is generated in the `src/components/LeftSidebar/LeftSidebar.astro`, so if you want to change the depth of elements displayed, styles, etc, that's the place to go.
|
||||
|
||||
## Section navigation
|
||||
|
||||
The section navigation, through the side bar on the right, is automatically generated by the `src/components/RightSidebar/RightSidebar.astro` file, it uses the meta-data from markdown files to generate the structure you see.
|
||||
|
||||
By default only elements from depth 2 to 5 will be displayed, and at the moment doesn't work for `.astro files`.
|
||||
|
||||
## Other Components
|
||||
|
||||
### Footer
|
||||
|
||||
You can edit your footer here `src/components/Footer/Footer.astro`, at the moment it is composed of a list of avatars. You can generate your own avatar [here](https://getavataaars.com/) and replace the ones from `src/components/Footer/AvatarList.astro`.
|
||||
|
||||
### Theme
|
||||
|
||||
The `src/components/RightSidebar/ThemeToggleButton.tsx` is only responsible for applying the theme, to change the theme colors see `public/theme.css`
|
||||
|
||||
## Multiple Languages
|
||||
|
||||
By default the Astro docs template encourages writing your docs in mutliple languages, it also encourages writing your docs in a specific file structure
|
||||
|
||||
```
|
||||
📦pages
|
||||
┣ 📂en
|
||||
┃ ┣ 📜example.md
|
||||
┃ ┣ 📜getting-started.md
|
||||
┃ ┣ 📜index.astro
|
||||
┃ ┗ 📜introduction.md
|
||||
┣ 📂es
|
||||
┃ ┣ 📜example.md
|
||||
┃ ┣ 📜getting-started.md
|
||||
┃ ┣ 📜index.astro
|
||||
┃ ┗ 📜introduction.md
|
||||
┣ 📂fr
|
||||
┃ ┣ 📜example.md
|
||||
┃ ┣ 📜getting-started.md
|
||||
┃ ┣ 📜index.astro
|
||||
┃ ┗ 📜introduction.md
|
||||
┗ 📜index.astro
|
||||
```
|
||||
|
||||
each folder within the `pages/` folder represents a language, to add new languages, you will need to create a new langauge folder,
|
||||
add the langauges name to the `LANGUAGE_NAMES` variable in the [`languages.ts`](../../languages.ts) file, and add new sidebar links corrosponding to the new language. E.g. Adding Deutsch as a supported language
|
||||
|
||||
1. Create the `de/` folder in the pages directory
|
||||
|
||||
```
|
||||
📦pages
|
||||
┣ 📂en
|
||||
┃ ┣ 📜example.md
|
||||
┃ ┣ 📜getting-started.md
|
||||
┃ ┣ 📜index.astro
|
||||
┃ ┗ 📜introduction.md
|
||||
┣ 📂de
|
||||
┃ ┣ 📜example.md
|
||||
┃ ┣ 📜getting-started.md
|
||||
┃ ┣ 📜index.astro
|
||||
┃ ┗ 📜introduction.md
|
||||
┗ 📜index.astro
|
||||
```
|
||||
|
||||
2. Add Deutsch to the `LANGUAGE_NAMES` variable in the [`languages.ts`](../../languages.ts) file
|
||||
|
||||
```ts
|
||||
// src/languages.ts
|
||||
export const LANGUAGE_NAMES = {
|
||||
English: 'en',
|
||||
Deutsch: 'de',
|
||||
};
|
||||
|
||||
// ...
|
||||
```
|
||||
|
||||
3. Add Deutch as a localized language for the SIDEBAR
|
||||
|
||||
```ts
|
||||
// src/config.ts
|
||||
export const SIDEBAR = {
|
||||
en: [
|
||||
{ text: 'Getting Started', header: true },
|
||||
{ text: 'Introduction', link: 'en/introduction' },
|
||||
{ text: 'Getting Started', link: 'en/getting-started' },
|
||||
{ text: 'Example', link: 'en/example' },
|
||||
],
|
||||
de: [
|
||||
{ text: 'Einstieg', header: true },
|
||||
{ text: 'Einführung', link: 'de/introduction' },
|
||||
{ text: 'Einstieg', link: 'de/getting-started' },
|
||||
{ text: 'Beispiel', link: 'de/example' },
|
||||
],
|
||||
};
|
||||
|
||||
// ...
|
||||
```
|
||||
|
||||
> _**Note**: make sure the sidebar links point to the proper language folder_
|
||||
|
||||
<!-- , but if you are unable to properly support multiple languages, you can disable multiple languages, you set the `DISABLE_MULTIPLE_LANGUAGES` variable in the [`config.ts`](../../config.ts) file to `true`, but you still need to change and tweak a couple more things.
|
||||
|
||||
After settings `DISABLE_MULTIPLE_LANGUAGES` you can now move the pages from the language folder you wish to use, e.g. I speak english, so, I would delete every other folders and files in the [`pages/`](../) folder except for the [`en/`](./) folder, I would then move the files from the [`en/`](./) folder to the [`pages/`](../) folder, delete all `index.astro` files, and finally delete the [`en/`](./) folder.
|
||||
|
||||
The file structure will look like this once you are done,
|
||||
|
||||
```
|
||||
📦src
|
||||
┣ 📂components
|
||||
┃ ┣ ...
|
||||
┣ 📂layouts
|
||||
┃ ┗ 📜MainLayout.astro
|
||||
┣ 📂pages
|
||||
┃ ┣ 📜example.md
|
||||
┃ ┣ 📜getting-started.md
|
||||
┃ ┗ 📜introduction.md
|
||||
┣ 📜config.ts
|
||||
┗ 📜languages.ts
|
||||
```
|
||||
|
||||
You will then need to rename `introductions.md` to `index.md`, and reorganize the `SIDEBAR` variable in the [`config.ts`](../../config.ts) file to resemble something like this (remember to change the links, since the `en/` folder has been deleted),
|
||||
|
||||
```ts
|
||||
export const SIDEBAR = [
|
||||
// index.md is the homepage, so, you don't need to set a sidebar link
|
||||
{ text: 'Introduction', header: true },
|
||||
{ text: 'Getting Started', link: 'getting-started' },
|
||||
{ text: 'Example', link: 'example' },
|
||||
]
|
||||
```
|
||||
|
||||
and that's it. -->
|
||||
|
||||
## Algolia DocSearch
|
||||
|
||||
[Algolia](https://www.algolia.com/) offers [DocSearch](https://docsearch.algolia.com/), a _"State-of-the-art search for technical documentation"_. We use DocSearch for the Astro docs as it's a great documentation search engine, to make things setting up docs easier we built it into the docs template, you can setup DocSearch for your site by following these instructions, ...
|
||||
|
||||
### 🛠 Configuration
|
||||
|
||||
...
|
||||
|
||||
## Documentation
|
||||
|
||||
For more information on how to use Astro components, check the documentation pages:
|
||||
|
||||
- [Quick Start](https://docs.astro.build/quick-start)
|
||||
- [astro.config.mjs](https://docs.astro.build/reference/configuration-reference)
|
||||
- [API](https://docs.astro.build/reference/api-reference)
|
||||
- [Command Line Interface](https://docs.astro.build/reference/cli-reference)
|
||||
- [Collections](https://docs.astro.build/core-concepts/collections)
|
||||
- [Development Server](https://docs.astro.build/reference/dev/)
|
||||
- [Markdown](https://docs.astro.build/guides/markdown-content)
|
||||
- [Publishing Astro components](https://docs.astro.build/guides/publish-to-npm)
|
||||
- [Renderers](https://docs.astro.build/reference/renderer-reference)
|
||||
- [Styling](https://docs.astro.build/guides/styling)
|
||||
- [.astro Syntax](https://docs.astro.build/core-concepts/astro-components)
|
|
@ -1,5 +0,0 @@
|
|||
---
|
||||
import REDIRECT from "../index.astro";
|
||||
---
|
||||
|
||||
<REDIRECT />
|
|
@ -1,62 +1,17 @@
|
|||
---
|
||||
title: Hello, Documentation!
|
||||
title: Introduction
|
||||
layout: ~/layouts/MainLayout.astro
|
||||
---
|
||||
|
||||
<img src="https://github.com/snowpackjs/astro/blob/main/assets/social/banner.png?raw=true" alt="Astro" width="638" height="320" >
|
||||
**Welcome to Astro!**
|
||||
|
||||
## What is Astro?
|
||||
This is the `docs` starter template. It contains all of the features that you need to build a Markdown-powered documentation site, including:
|
||||
|
||||
**Astro** is a _fresh but familiar_ approach to building websites. Astro combines decades of proven performance best practices with the DX improvements of the component-oriented era.
|
||||
- ✅ **Sidebar navigation**
|
||||
- ✅ **Search (powered by Algolia)**
|
||||
- ✅ **Multi-language i18n**
|
||||
- ✅ (and, best of all) **dark mode**
|
||||
|
||||
With Astro, you can use your favorite JavaScript framework and automatically ship the bare-minimum amount of JavaScript—by default, it's none at all!
|
||||
To get started, check out the project `README.md` that the template came with. It provides documentation on how to use and customize this template for your own project, which you can always refer back to as you build.
|
||||
|
||||
## Project Status
|
||||
|
||||
⚠️ **Astro is still an early beta, missing features and bugs are to be expected!** If you can stomach it, then Astro-built sites are production ready and several production websites built with Astro already exist in the wild. We will update this note once we get closer to a stable, v1.0 release.
|
||||
|
||||
## 🔧 Quick Start
|
||||
|
||||
> **Important**: Astro is built with [ESM modules](https://nodejs.org/api/esm.html) which are not supported in older version of Node.js. The minimum supported version is **14.16.1**.
|
||||
|
||||
```bash
|
||||
# create your project
|
||||
mkdir new-project-directory
|
||||
cd new-project-directory
|
||||
npm init astro
|
||||
|
||||
# install your dependencies
|
||||
npm install
|
||||
|
||||
# start the dev server and open your browser
|
||||
npm run dev
|
||||
```
|
||||
|
||||
### 🚀 Build & Deployment
|
||||
|
||||
The default Astro project has the following `scripts` in the `/package.json` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"scripts": {
|
||||
"start": "astro dev",
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
For local development, run:
|
||||
|
||||
```
|
||||
npm run dev
|
||||
```
|
||||
|
||||
To build for production, run the following command:
|
||||
|
||||
```
|
||||
npm run build
|
||||
```
|
||||
|
||||
To deploy your Astro site to production, upload the contents of `/dist` to your favorite static site host.
|
||||
Found a missing feature that you can't live without? Please suggest it and even consider adding it yourself to the Astro repo! We're an open source project and contributions from developers like you are how we grow! 💙
|
||||
|
|
50
examples/docs/src/pages/en/page-2.md
Normal file
50
examples/docs/src/pages/en/page-2.md
Normal file
|
@ -0,0 +1,50 @@
|
|||
---
|
||||
title: Page 2
|
||||
layout: ~/layouts/MainLayout.astro
|
||||
---
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
||||
|
||||
Sed flavum. Stridore nato, Alcandrumque desint ostendit derat, longoque, eadem
|
||||
iunxit miserum pedum pectora. Liberat sine pignus cupit, ferit mihi venias
|
||||
amores, et quod, maduere haec _gravi_ contentusque heros. Qui suae attonitas.
|
||||
|
||||
_Acta caelo_ ego, hoc illi ferroque, qui fluitque Achillis deiecerat erat
|
||||
inhospita arasque ad sume et aquis summo. Fugerat ipse iam. Funeris Iuno Danaos
|
||||
est inroravere aurum foret nati aeque tetigisset! Esse ad tibi queritur [Sol sub
|
||||
est](http://iusserat.net/) pugno solitoque movet coercuit solent caput te?
|
||||
|
||||
Crescit sint petit gemellos gemino, et _gemma deus sub_ Surrentino frena
|
||||
principiis statione. Soporiferam secunda nulli Tereus is _Aeolidae cepit_, tua
|
||||
peregrinosque illam parvis, deerit sub et times sedant.
|
||||
|
||||
## Apium haec candida mea movebo obsuntque descendat
|
||||
|
||||
Furti lucos cum iussa quid temptanti gravitate animus: vocat
|
||||
[ira](http://rediere.com/): illa. Primis aeternus, illi cinguntur ad mugitus
|
||||
aevo repentinos nec.
|
||||
|
||||
Transcurrere tenens in _litore_ tuti plebe circumspicit viventi quoque mox
|
||||
troades medio mea locuta gradus perque sic unguibus
|
||||
[gramen](http://quantoque.io/). Effetus celerique nomina quoque. Ire gemino est.
|
||||
Eurus quaerenti: et lacus, tibi ignorant tertia omnes subscribi ducentem sedit
|
||||
experientia sine ludunt multae. Ponderis memor purasque, ut armenta corpora
|
||||
efferre: praeterea infantem in virgam verso.
|
||||
|
||||
- Revellit quoniam vulnerat dique respicit
|
||||
- Modo illis
|
||||
- Nec victoria quodque
|
||||
- Spectans si vitis iussorum corpora quas
|
||||
|
||||
Tibi igni, iamque, sum arsuro patet et Talibus cecidere: levati Atlas villosa
|
||||
dubium conparentis litem volentem nec? Iuga tenent, passi cumque generosior
|
||||
luminis, quique mea aequora ingens bracchia furor, respiramen eram: in. Caelebs
|
||||
et passu Phaethonta alumna orbem rapuit inplet [adfusaeque
|
||||
oculis](http://www.virum.net/ille-miserae.html) paene. Casus mea cingebant idque
|
||||
suis nymphe ut arae potuit et non, inmota erat foret, facta manu arvum.
|
||||
|
||||
Fugam nec stridentemque undis te solet mentemque Phrygibus fulvae adhuc quam
|
||||
cernimus est! Aper iube dederat adsere iamque mortale ita cornua si fundamina
|
||||
quem caperet, iubeas stolidae pedesque intrarunt navigat triformis. Undas terque
|
||||
digitos satis in nautae sternuntur curam, iaculum ignoscere _pianda dominique
|
||||
nostra_ vivacemque teneraque!
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
title: Markdown Example
|
||||
title: Page 3
|
||||
layout: ~/layouts/MainLayout.astro
|
||||
---
|
||||
|
36
examples/docs/src/pages/en/page-4.md
Normal file
36
examples/docs/src/pages/en/page-4.md
Normal file
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
title: Page 4
|
||||
layout: ~/layouts/MainLayout.astro
|
||||
---
|
||||
|
||||
This is a fully-featured page, written in Markdown!
|
||||
|
||||
## Section A
|
||||
|
||||
Lorem ipsum dolor sit amet, **consectetur adipiscing elit**. Sed ut tortor _suscipit_, posuere ante id, vulputate urna. Pellentesque molestie aliquam dui sagittis aliquet. Sed sed felis convallis, lacinia lorem sit amet, fermentum ex. Etiam hendrerit mauris at elementum egestas. Vivamus id gravida ante. Praesent consectetur fermentum turpis, quis blandit tortor feugiat in. Aliquam erat volutpat. In elementum purus et tristique ornare. Suspendisse sollicitudin dignissim est a ultrices. Pellentesque sed ipsum finibus, condimentum metus eget, sagittis elit. Sed id lorem justo. Vivamus in sem ac mi molestie ornare.
|
||||
|
||||
## Section B
|
||||
|
||||
Nam quam dolor, pellentesque sed odio euismod, feugiat tempus tellus. Quisque arcu velit, ultricies in faucibus sed, ultrices ac enim. Nunc eget dictum est. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ex nisi, egestas mollis ultricies ut, laoreet suscipit libero. Nam condimentum molestie turpis. Sed vestibulum sagittis congue. Maecenas tristique enim et tincidunt tempor. Curabitur ac scelerisque nulla, in malesuada libero. Praesent eu tempus odio. Pellentesque aliquam ullamcorper quam at gravida. Sed non fringilla mauris. Aenean sit amet ultrices erat. Vestibulum congue venenatis tortor, nec suscipit tortor. Aenean pellentesque mauris eget tortor tincidunt pharetra.
|
||||
|
||||
## Section C
|
||||
|
||||
```markdown
|
||||
---
|
||||
title: Markdown Page!
|
||||
lang: en
|
||||
layout: ~/layouts/MainLayout.astro
|
||||
---
|
||||
|
||||
# Markdown example
|
||||
|
||||
This is a fully-featured page, written in Markdown!
|
||||
|
||||
## Section A
|
||||
|
||||
Lorem ipsum dolor sit amet, **consectetur adipiscing elit**. Sed ut tortor _suscipit_, posuere ante id, vulputate urna. Pellentesque molestie aliquam dui sagittis aliquet. Sed sed felis convallis, lacinia lorem sit amet, fermentum ex. Etiam hendrerit mauris at elementum egestas. Vivamus id gravida ante. Praesent consectetur fermentum turpis, quis blandit tortor feugiat in. Aliquam erat volutpat. In elementum purus et tristique ornare. Suspendisse sollicitudin dignissim est a ultrices. Pellentesque sed ipsum finibus, condimentum metus eget, sagittis elit. Sed id lorem justo. Vivamus in sem ac mi molestie ornare.
|
||||
|
||||
## Section B
|
||||
|
||||
Nam quam dolor, pellentesque sed odio euismod, feugiat tempus tellus. Quisque arcu velit, ultricies in faucibus sed, ultrices ac enim. Nunc eget dictum est. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam ex nisi, egestas mollis ultricies ut, laoreet suscipit libero. Nam condimentum molestie turpis. Sed vestibulum sagittis congue. Maecenas tristique enim et tincidunt tempor. Curabitur ac scelerisque nulla, in malesuada libero. Praesent eu tempus odio. Pellentesque aliquam ullamcorper quam at gravida. Sed non fringilla mauris. Aenean sit amet ultrices erat. Vestibulum congue venenatis tortor, nec suscipit tortor. Aenean pellentesque mauris eget tortor tincidunt pharetra.
|
||||
```
|
|
@ -1,24 +1,5 @@
|
|||
---
|
||||
import Layout from '../layouts/MainLayout.astro';
|
||||
import { KNOWN_LANGUAGES } from "../languages";
|
||||
---
|
||||
<div id="known_languages" hidden>{KNOWN_LANGUAGES.join(",")}</div>
|
||||
<script>
|
||||
// WIP: trigger a client-side redirect based on the browser language.
|
||||
// A vercel.json redirect is enforced in production, so no user should ever see this page.
|
||||
// Remove the vercel.json redirect when this is ready.
|
||||
const KNOWN_LANGUAGES = document.querySelector("#known_languages")?.textContent?.split(",") ?? ['bg', 'de','en','es','fi','nl','pt-br','zh-CN','zh-TW', 'fr'];
|
||||
let newLangWithRegion = (window.navigator.userLanguage || window.navigator.language || 'en-US').substr(0, 5);
|
||||
let newLang = newLangWithRegion.substr(0, 2);
|
||||
|
||||
let langPathRegex = new RegExp(`\/(${KNOWN_LANGUAGES.join("|")})\/`);
|
||||
let actualDest = window.location.pathname.replace(langPathRegex, "/");
|
||||
if (actualDest == "/") actualDest = `/introduction`;
|
||||
if (KNOWN_LANGUAGES.includes(newLangWithRegion)) {
|
||||
window.location.pathname = '/' + newLangWithRegion + actualDest;
|
||||
} else if (KNOWN_LANGUAGES.includes(newLang)) {
|
||||
window.location.pathname = '/' + newLang + actualDest;
|
||||
} else {
|
||||
window.location.pathname = actualDest;
|
||||
}
|
||||
// Redirect your homepage to the first page of documentation.
|
||||
// If you have a landing page, remove this script and add it here!
|
||||
window.location.pathname = `/en/introduction`;
|
||||
</script>
|
||||
|
|
Loading…
Reference in a new issue