chore: updated examples to v0.26.0 (#2977)

* New script behavior

* Astro.request

* Reverted `deno` to `node`

* Updated subpath
This commit is contained in:
Juan Martín Seery 2022-04-03 16:02:57 -03:00 committed by GitHub
parent dff89a0fa3
commit dc6e89f0a3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 17 additions and 17 deletions

View file

@ -11,19 +11,18 @@ export async function getStaticPaths() {
} }
const { allPosts } = Astro.props; const { allPosts } = Astro.props;
const { params, canonicalURL } = Astro.request;
const title = 'Dons Blog'; const title = 'Dons Blog';
const description = 'An example blog on Astro'; const description = 'An example blog on Astro';
/** filter posts by author, sort by date */ /** filter posts by author, sort by date */
const posts = allPosts.filter((post) => post.frontmatter.author === params.author).sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf()); const posts = allPosts.filter((post) => post.frontmatter.author === Astro.params.author).sort((a, b) => new Date(b.frontmatter.date).valueOf() - new Date(a.frontmatter.date).valueOf());
const author = authorData[posts[0].frontmatter.author]; const author = authorData[posts[0].frontmatter.author];
--- ---
<html lang="en"> <html lang="en">
<head> <head>
<title>{title}</title> <title>{title}</title>
<MainHead {title} {description} image={posts[0].frontmatter.image} canonicalURL={canonicalURL.toString()} /> <MainHead {title} {description} image={posts[0].frontmatter.image} canonicalURL={Astro.canonicalURL.toString()} />
<style lang="scss"> <style lang="scss">
.title { .title {

View file

@ -18,10 +18,10 @@ import '../styles/index.css';
<link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital@0;1&display=swap" rel="stylesheet" /> <link href="https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:ital@0;1&display=swap" rel="stylesheet" />
<!-- Scrollable a11y code helper --> <!-- Scrollable a11y code helper -->
<script type="module" src="/make-scrollable-code-focusable.js"></script> <script src="/make-scrollable-code-focusable.js" is:inline></script>
<!-- This is intentionally inlined to avoid FOUC --> <!-- This is intentionally inlined to avoid FOUC -->
<script> <script is:inline>
const root = document.documentElement; const root = document.documentElement;
const theme = localStorage.getItem('theme'); const theme = localStorage.getItem('theme');
if (theme === 'dark' || (!theme && window.matchMedia('(prefers-color-scheme: dark)').matches)) { if (theme === 'dark' || (!theme && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
@ -32,7 +32,7 @@ import '../styles/index.css';
</script> </script>
<!-- Global site tag (gtag.js) - Google Analytics --> <!-- Global site tag (gtag.js) - Google Analytics -->
<!-- <script async src="https://www.googletagmanager.com/gtag/js?id=G-TEL60V1WM9"></script> <!-- <script async src="https://www.googletagmanager.com/gtag/js?id=G-TEL60V1WM9" is:inline></script>
<script> <script>
window.dataLayer = window.dataLayer || []; window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);} function gtag(){dataLayer.push(arguments);}

View file

@ -43,7 +43,7 @@ const sidebarSections = SIDEBAR[langCode].reduce((col, item, i) => {
</ul> </ul>
</nav> </nav>
<script> <script is:inline>
window.addEventListener('DOMContentLoaded', (event) => { window.addEventListener('DOMContentLoaded', (event) => {
var target = document.querySelector('[aria-current="page"]'); var target = document.querySelector('[aria-current="page"]');
if (target && target.offsetTop > window.innerHeight - 100) { if (target && target.offsetTop > window.innerHeight - 100) {

View file

@ -9,7 +9,7 @@ import RightSidebar from '../components/RightSidebar/RightSidebar.astro';
import * as CONFIG from '../config'; import * as CONFIG from '../config';
const { content = {} } = Astro.props; const { content = {} } = Astro.props;
const currentPage = Astro.request.url.pathname; const currentPage = new URL(Astro.request.url).pathname;
const currentFile = `src/pages${currentPage.replace(/\/$/, '')}.md`; const currentFile = `src/pages${currentPage.replace(/\/$/, '')}.md`;
const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + currentFile; const githubEditUrl = CONFIG.GITHUB_EDIT_URL && CONFIG.GITHUB_EDIT_URL + currentFile;
--- ---

View file

@ -1,4 +1,4 @@
<script> <script is:inline>
// Redirect your homepage to the first page of documentation. // Redirect your homepage to the first page of documentation.
// If you have a landing page, remove this script and add it here! // If you have a landing page, remove this script and add it here!
window.location.pathname = `/en/introduction`; window.location.pathname = `/en/introduction`;

View file

@ -16,6 +16,6 @@ console.log({ SSR, PUBLIC_SOME_KEY });
</head> </head>
<body> <body>
<h1>Hello, Environment Variables!</h1> <h1>Hello, Environment Variables!</h1>
<script type="module" src="/src/scripts/client.ts"></script> <script src="/src/scripts/client.ts"></script>
</body> </body>
</html> </html>

View file

@ -23,7 +23,7 @@ import Counter from '../components/Counter.astro';
</style> </style>
<!-- Be sure to include AlpineJS --> <!-- Be sure to include AlpineJS -->
<script src="//unpkg.com/alpinejs" defer></script> <script src="//unpkg.com/alpinejs" defer is:inline></script>
</head> </head>
<body> <body>
<main> <main>

View file

@ -38,7 +38,7 @@ import '../components/Counter.js';
console.log('end partytown blocking script') console.log('end partytown blocking script')
</script> </script>
<script> <script is:inline>
setInterval(() => { setInterval(() => {
const randomColor = Math.floor(Math.random()*16777215).toString(16); const randomColor = Math.floor(Math.random()*16777215).toString(16);
document.querySelector('.partytown-status').style.color = "#" + randomColor; document.querySelector('.partytown-status').style.color = "#" + randomColor;

View file

@ -7,7 +7,7 @@
</head> </head>
<body> <body>
<h1 id="result">Loading...</h1> <h1 id="result">Loading...</h1>
<script type="module"> <script>
// Non-HTML files will be included in your final build, so you // Non-HTML files will be included in your final build, so you
// can fetch them directly in the browser. // can fetch them directly in the browser.
const response = await fetch(`/about.json`); const response = await fetch(`/about.json`);

View file

@ -1,9 +1,9 @@
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import svelte from '@astrojs/svelte'; import svelte from '@astrojs/svelte';
import deno from '@astrojs/deno'; import node from '@astrojs/node';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
adapter: deno(), adapter: node(),
integrations: [svelte()], integrations: [svelte()],
}); });

View file

@ -4,5 +4,6 @@ import react from '@astrojs/react';
// https://astro.build/config // https://astro.build/config
export default defineConfig({ export default defineConfig({
integrations: [react()], integrations: [react()],
site: 'http://example.com/blog', site: 'http://example.com',
base: '/blog',
}); });

View file

@ -11,6 +11,6 @@
<body> <body>
<h1>Welcome to <a href="https://astro.build/">Astro</a></h1> <h1>Welcome to <a href="https://astro.build/">Astro</a></h1>
<script src="/src/index.ts" type="module" hoist></script> <script src="/src/index.ts"></script>
</body> </body>
</html> </html>