Skip to content

Commit

Permalink
Merge branch 'main' into patch-0222
Browse files Browse the repository at this point in the history
  • Loading branch information
sarah11918 authored Feb 24, 2023
2 parents 62ade04 + 6912114 commit 6a25734
Show file tree
Hide file tree
Showing 32 changed files with 458 additions and 241 deletions.
1 change: 1 addition & 0 deletions public/logos/tina-cms.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion src/components/CodeSnippet/CodeSnippet.astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
import rangeParser from 'parse-numeric-range';
import { useTranslations } from '~/i18n/util';
import { ShikiBlock } from './shiki-block';
import {
InlineMarkingDefinition,
Expand All @@ -26,6 +27,8 @@ const {
inlineMarkings = '',
} = Astro.props as Props;
const t = useTranslations(Astro);
const isTerminal = ['shellscript', 'shell', 'bash', 'sh', 'zsh'].includes(lang);
const intRemovedLineIndex = parseInt(removedLineIndex) || 0;
const intRemovedLineCount = parseInt(removedLineCount) || 0;
Expand Down Expand Up @@ -315,6 +318,14 @@ function parseMarkingDefinition(serializedArr: string, parts: RegExp, parseError
`lang-${lang}`,
]}
>
<figcaption class="header">{titleHtml && <span class="title" set:html={titleHtml} />}</figcaption>
<figcaption class="header">
{
titleHtml ? (
<span class="title" set:html={titleHtml} />
) : (
isTerminal && <span class="sr-only">{t('codeSnippet.terminalCaption')}</span>
)
}
</figcaption>
<Fragment set:html={codeSnippetHtml} />
</figure>
4 changes: 3 additions & 1 deletion src/components/Header/Header.astro
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const t = useTranslations(Astro);
height="102"
viewBox="0 0 363 102"
fill="none"
aria-hidden="true"
>
<style>
.text {
Expand Down Expand Up @@ -62,6 +63,7 @@ const t = useTranslations(Astro);
height="102"
viewBox="0 0 226 102"
fill="none"
aria-hidden="true"
>
<path
class="docs-path"
Expand All @@ -78,7 +80,7 @@ const t = useTranslations(Astro);
labels={{ useLight: t('themeToggle.useLight'), useDark: t('themeToggle.useDark') }}
isInsideHeader={true}
/>
{lang && <LanguageSelect lang={lang} client:idle />}
{lang && <LanguageSelect lang={lang} label={t('languageSelect.label')} client:idle />}
<Search {lang} labels={docsearchStrings} />
<SidebarToggle client:idle />
</nav>
Expand Down
8 changes: 4 additions & 4 deletions src/components/Header/LanguageSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import languages from '../../i18n/languages';
import './HeaderButton.css';
import './LanguageSelect.css';

const LanguageSelect = ({ lang }: { lang: string }) => {
const LanguageSelect = ({ lang, label }: { lang: string; label: string }) => {
return (
<div className="language-select-wrapper">
<label className="language-select-wrapper">
<span className="sr-only">{label}</span>
<svg
width="1.25em"
height="1.25em"
Expand All @@ -26,7 +27,6 @@ const LanguageSelect = ({ lang }: { lang: string }) => {
<select
className="header-button language-select"
value={lang}
aria-label="Select language"
onChange={(e: ChangeEvent<HTMLSelectElement>) => {
const newLang = e.currentTarget.value;
const [_leadingSlash, _oldLang, ...rest] = window.location.pathname.split('/');
Expand All @@ -40,7 +40,7 @@ const LanguageSelect = ({ lang }: { lang: string }) => {
</option>
))}
</select>
</div>
</label>
);
};

Expand Down
6 changes: 2 additions & 4 deletions src/components/Header/SkipToContent.astro
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ import UIString from '../UIString.astro';
z-index: 9;
display: block;
text-align: center;
background-color: var(--theme-accent);
color: white;
border-radius: 0.25em;
outline: var(--theme-bg) solid 1px;
background-color: var(--theme-bg-gradient-bottom);
outline: 2px solid currentColor;
outline-offset: 0;
}
</style>
2 changes: 2 additions & 0 deletions src/components/Header/ThemeToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const icons = [
height="20"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path
fillRule="evenodd"
Expand All @@ -33,6 +34,7 @@ const icons = [
height="20"
viewBox="0 0 20 20"
fill="currentColor"
aria-hidden="true"
>
<path d="M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z" />
</svg>,
Expand Down
6 changes: 3 additions & 3 deletions src/components/LeftSidebar/Sponsors.astro
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import UIString from '../UIString.astro';
<div dir="ltr" lang="en" class="sponsors">
<h2 class="sponsors-title"><UIString key="leftSidebar.sponsoredBy" /></h2>
<a href="https://www.netlify.com/" aria-label="Netlify">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 147 40" width="90"
><radialGradient
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 147 40" width="90" aria-hidden="true">
<radialGradient
id="a"
cx="-779.1"
cy="1839.7"
Expand All @@ -24,7 +24,7 @@ import UIString from '../UIString.astro';
</svg>
</a>
<a href="https://www.storyblok.com/" aria-label="Storyblok">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 251 53" width="125">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 251 53" width="125" aria-hidden="true">
<g>
<path
d="M73 37c-2 0-3.7-.2-5.5-.7-1.6-.6-3.2-1.5-4.5-2.7l2.4-4c1.3 1 2.5 1.6 3.8 2.1 1.2.6 2.4.8 3.6.8a4 4 0 0 0 2-.5c.4-.3.6-.7.6-1.3 0-.5-.2-1-.9-1.4-1-.4-2-.8-3-1L67.7 27a13 13 0 0 1-2.4-1.3c-.6-.4-1.1-1-1.4-1.6a5 5 0 0 1-.4-2c0-2.2.9-4.1 2.5-5.4a9.3 9.3 0 0 1 6.1-2c1.6 0 3.1.2 4.5.6 1.4.5 2.8 1.3 4.1 2.4l-2.6 4c-1-.8-2-1.4-3.2-1.9a7 7 0 0 0-2.8-.6c-.7 0-1.3.1-1.8.5-.5.2-.7.7-.7 1.3 0 .6.2 1 .8 1.4.5.3 1.5.6 3 1l3.8 1.2L80 26c1.3 1 2 2.5 1.8 4.1a6 6 0 0 1-2.4 5.1 10 10 0 0 1-6.4 1.9Zm25.8-1.4-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6 3Zm15-24.8h6.6V29c0 1.7.7 2.5 2.1 2.5a5 5 0 0 0 2.1-.5l1 4.8a15 15 0 0 1-5.9 1.3c-1.9 0-3.3-.5-4.3-1.5s-1.6-2.4-1.6-4.3V6.8Zm24 30.3c-1.6 0-3.2-.3-4.8-.9-2.7-1-4.9-3.3-5.9-6a12 12 0 0 1 2.2-12 11.3 11.3 0 0 1 8.5-3.4 11 11 0 0 1 10.7 6.9c1.6 4.1.8 8.7-2.2 12a10 10 0 0 1-3.6 2.5c-1.6.6-3.2 1-4.9.9ZM210.2 26c0 1.7.4 3 1.3 4 1 1 2.1 1.6 3.5 1.6 1.3 0 2.5-.6 3.4-1.6a6.4 6.4 0 0 0 1.4-4 6 6 0 0 0-1.4-4.1c-1-1-2-1.6-3.4-1.6-1.3 0-2.6.6-3.4 1.6a6 6 0 0 0-1 1.8c-.3.7-.4 1.4-.4 2.3Zm34 10.7-5.6-8.7-2.3 2.4v6.3h-6.6v-30h6.6v17.4l7.2-8.9h7l-7.8 9.3 8.4 12.2h-7Z"
Expand Down
2 changes: 2 additions & 0 deletions src/components/PageContent/ArticleNavigationButton.astro
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const { item, rel } = Astro.props as Props;
height="32"
width="32"
fill="currentColor"
aria-hidden="true"
>
<path d="M447.1 256C447.1 273.7 433.7 288 416 288H109.3l105.4 105.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448s-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L109.3 224H416C433.7 224 447.1 238.3 447.1 256z" />
</svg>
Expand All @@ -31,6 +32,7 @@ const { item, rel } = Astro.props as Props;
height="32"
width="32"
fill="currentColor"
aria-hidden="true"
>
<path d="M438.6 278.6l-160 160C272.4 444.9 264.2 448 256 448s-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L338.8 288H32C14.33 288 .0016 273.7 .0016 256S14.33 224 32 224h306.8l-105.4-105.4c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160C451.1 245.9 451.1 266.1 438.6 278.6z" />
</svg>
Expand Down
2 changes: 1 addition & 1 deletion src/components/internal/rehype-file-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const fileTreeProcessor = rehype().use(function fileTree() {
const icon = h('span', isDirectory ? FolderIcon : FileIcon(firstChildTextContent));
if (!icon.properties) icon.properties = {};
if (isDirectory) {
icon.properties['aria-label'] = directoryLabel;
icon.children.unshift(h('span', { class: 'sr-only' }, directoryLabel));
}

node.properties.class = isDirectory ? 'directory' : 'file';
Expand Down
4 changes: 2 additions & 2 deletions src/content/docs/en/core-concepts/routing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -374,9 +374,9 @@ const params = Astro.params;

## Excluding pages

You can exclude pages, or even whole directories from being built by prefixing their names with an underscore (`_`).
You can exclude pages or directories from being built by prefixing their names with an underscore (`_`). Files with the `_` prefix won't be recognized by the router and won't be placed into the `dist/` directory.

This allows you to create private pages, and also to co-locate tests, utilities, and components with their related pages, preventing them from being built into `.html` files and placed into the `dist/` directory.
You can use this to temporarily disable pages, and also to put tests, utilities, and components in the same folder as their related pages.

In this example, only `src/pages/index.astro` and `src/pages/posts/post1.md` will be built as page routes and HTML files.

Expand Down
14 changes: 9 additions & 5 deletions src/content/docs/en/guides/cms/storyblok.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -367,24 +367,28 @@ export default defineConfig({

### Generating pages

To create a route for a specific `page`, you can fetch its content directly from the Storyblok API and pass it to the `Page` component. Create an `index.astro` file in `src/pages/` to render the `home` page:
To create a route for a specific `page`, you can fetch its content directly from the Storyblok API and pass it to the `StoryblokComponent` component. Remember to make sure you have added the `Page` component to your astro.config.mjs.

```astro title="src/pages/index.astro" {7,8,15}
Create an `index.astro` file in `src/pages/` to render the `home` page:

```astro title="src/pages/index.astro" {3,7,8,9,17}
---
import { useStoryblokApi } from '@storyblok/astro'
import StoryblokComponent from '@storyblok/astro/StoryblokComponent.astro'
import BaseLayout from '../layouts/BaseLayout.astro'
import Page from '../storyblok/Page.astro';
const storyblokApi = useStoryblokApi();
const { data } = await storyblokApi.get('cdn/stories/home');
const { data } = await storyblokApi.get('cdn/stories/home', {
version: import.meta.env.DEV ? "draft" : "published",
});
const content = data.story.content;
---
<html lang="en">
<head>
<title>Storyblok & Astro</title>
</head>
<body>
<Page blok={content} />
<StoryblokComponent blok={content} />
</body>
</html>
```
Expand Down
144 changes: 144 additions & 0 deletions src/content/docs/en/guides/cms/tina-cms.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
---
title: Tina CMS & Astro
description: Add content to your Astro project using Tina as a CMS
type: cms
stub: false
service: Tina CMS
---
import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro'

[Tina CMS](https://www.tina.io/) is a Git-backed headless content management system.

## Integrating with Astro

To get started, you'll need an existing Astro project.

1. Run the following command to install Tina into your Astro project.

<PackageManagerTabs>
<Fragment slot="npm">
```shell
npx @tinacms/cli@latest init
```
</Fragment>
<Fragment slot="pnpm">
```shell
pnpx @tinacms/cli@latest init
```
</Fragment>
<Fragment slot="yarn">
```shell
yarn dlx @tinacms/cli@latest init
```
</Fragment>
</PackageManagerTabs>

- When prompted for a Cloud ID, press <kbd>Enter</kbd> to skip. You'll generate one later if you want to use Tina Cloud.
- When prompted "What framework are you using", choose **Other**.
- When asked where public assets are stored, press <kbd>Enter</kbd>.

After this has finished, you should now have a `.tina` folder in the root of your project and an `admin` folder in your public directory. It will also create a Markdown file at `content/posts/hello-world.md`.

2. Change the `dev` script in `package.json`:

<PackageManagerTabs>
<Fragment slot="npm">
```json del={4} ins={5}
// package.json
{
"scripts": {
"dev": "astro dev",
"dev": "npm tinacms dev -c 'astro dev'"
}
}
```
</Fragment>
<Fragment slot="pnpm">
```json del={4} ins={5}
// package.json
{
"scripts": {
"dev": "astro dev",
"dev": "pnpm tinacms dev -c 'astro dev'"
}
}
```
</Fragment>
<Fragment slot="yarn">
```json del={4} ins={5}
// package.json
{
"scripts": {
"dev": "astro dev",
"dev": "yarn tinacms dev -c 'astro dev'"
}
}
```
</Fragment>
</PackageManagerTabs>

3. TinaCMS is now set up in local mode. Test this by running the `dev` script, then navigating to `/admin/index.html#/collections/post`.

Editing the “Hello, World!” post will update the `content/posts/hello-world.md` file in your project directory.

4. Set up your Tina collections by editing the `schema.collections` property in `.tina/config.ts`.

For example, you can add a required "date posted" frontmatter property to our posts:

```js title=".tina/config.ts" ins={35-40}
import { defineConfig } from "tinacms";

// Your hosting provider likely exposes this as an environment variable
const branch = process.env.HEAD || process.env.VERCEL_GIT_COMMIT_REF || "main";

export default defineConfig({
branch,
clientId: null, // Get this from tina.io
token: null, // Get this from tina.io
build: {
outputFolder: "admin",
publicFolder: "public",
},
media: {
tina: {
mediaRoot: "images",
publicFolder: "public",
},
},
schema: {
collections: [
{
name: "posts",
label: "Posts",
path: "src/content/posts",
format: 'mdx',
fields: [
{
type: "string",
name: "title",
label: "Title",
isTitle: true,
required: true,
},
{
type: "datetime",
name: "posted",
label: "Date Posted",
required: true,
},
{
type: "rich-text",
name: "body",
label: "Body",
isBody: true,
},
],
},
],
},
});
```

Learn more about Tina collections [in the Tina docs](https://tina.io/docs/reference/collections/).

5. In production, TinaCMS can commit changes directly to your GitHub repository. To set up TinaCMS for production, you can choose to use [Tina Cloud](https://tina.io/docs/tina-cloud/) or self-host the [Tina Data Layer](https://tina.io/docs/self-hosted/overview/). You can [read more about registering for Tina Cloud](https://app.tina.io/register) in the Tina Docs.
11 changes: 8 additions & 3 deletions src/content/docs/en/guides/markdown-content.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Don't forget to include a `client:directive` on your UI framework components, if

See more examples of using import and export statements in the [MDX docs](https://mdxjs.com/docs/what-is-mdx/#esm).

```astro title="src/pages/about.mdx" {5-6} /<.+\/>/
```mdx title="src/pages/about.mdx" {5-6} /<.+\/>/
---
layout: ../layouts/BaseLayout.astro
title: About me
Expand Down Expand Up @@ -469,6 +469,8 @@ export default defineConfig({
});
```

Note that by default, `remarkToc` requires a "ToC" or "Table of Contents" [heading](https://github.com/remarkjs/remark-toc#optionsheading) (case-insensitive) on the page to show the table of contents.

#### Heading IDs and plugins

Astro injects an `id` attribute into all heading elements (`<h1>` to `<h6>`) in Markdown and MDX files and provides a `getHeadings()` utility for retrieving these IDs in [Markdown exported properties](#exported-properties).
Expand All @@ -494,16 +496,19 @@ export default defineConfig({

#### Customizing a plugin

In order to customize a plugin, provide an options object after it in a nested array. The example below adds the [`behavior` option to the `rehype-autolink-headings` plugin](https://github.com/rehypejs/rehype-autolink-headings#optionsbehavior) in order to add the anchor tag after the headline text.
In order to customize a plugin, provide an options object after it in a nested array.

The example below adds the [heading option to the `remarkToc` plugin](https://github.com/remarkjs/remark-toc#optionsheading) to change where the table of contents is placed, and the [`behavior` option to the `rehype-autolink-headings` plugin](https://github.com/rehypejs/rehype-autolink-headings#optionsbehavior) in order to add the anchor tag after the headline text.

```js title="astro.config.mjs"
import remarkToc from 'remark-toc';
import { rehypeHeadingIds } from '@astrojs/markdown-remark';
import rehypeSlug from 'rehype-slug';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';

export default {
markdown: {
remarkPlugins: [],
remarkPlugins: [ [remarkToc, { heading: "contents"} ] ],
rehypePlugins: [rehypeSlug, [rehypeAutolinkHeadings, { behavior: 'append' }]],
},
}
Expand Down
Loading

0 comments on commit 6a25734

Please sign in to comment.