diff --git a/.changeset/two-birds-jog.md b/.changeset/two-birds-jog.md new file mode 100644 index 000000000..67469f174 --- /dev/null +++ b/.changeset/two-birds-jog.md @@ -0,0 +1,6 @@ +--- +'@astrojs/example-blog': minor +'@astrojs/example-blog-multiple-authors': minor +--- + +Update blog example template diff --git a/examples/blog-multiple-authors/.gitignore b/examples/blog-multiple-authors/.gitignore new file mode 100644 index 000000000..d436c6dad --- /dev/null +++ b/examples/blog-multiple-authors/.gitignore @@ -0,0 +1,18 @@ +# build output +dist + +# dependencies +node_modules/ +.snowpack/ + +# logs +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# environment variables +.env +.env.production + +# macOS-specific files +.DS_Store diff --git a/examples/blog-multiple-authors/.npmrc b/examples/blog-multiple-authors/.npmrc new file mode 100644 index 000000000..0cc653b2c --- /dev/null +++ b/examples/blog-multiple-authors/.npmrc @@ -0,0 +1,2 @@ +## force pnpm to hoist +shamefully-hoist = true \ No newline at end of file diff --git a/examples/blog/CHANGELOG.md b/examples/blog-multiple-authors/CHANGELOG.md similarity index 100% rename from examples/blog/CHANGELOG.md rename to examples/blog-multiple-authors/CHANGELOG.md diff --git a/examples/blog-multiple-authors/README.md b/examples/blog-multiple-authors/README.md new file mode 100644 index 000000000..59df007d1 --- /dev/null +++ b/examples/blog-multiple-authors/README.md @@ -0,0 +1,47 @@ +# Astro Blog Example + +> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun! + +Features: + +- ✅ SEO-friendly setup with canonical URLs and OpenGraph data +- ✅ Full Markdown support +- ✅ RSS 2.0 generation +- ✅ Sitemap.xml generation + +## 🚀 Project Structure + +Inside of your Astro project, you'll see the following folders and files: + +``` +/ +├── public/ +│ ├── robots.txt +│ └── favicon.ico +├── src/ +│ ├── components/ +│ │ └── Tour.astro +│ └── pages/ +│ └── index.astro +└── package.json +``` + +Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name. + +There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components. + +Any static assets, like images, can be placed in the `public/` directory. + +## 🧞 Commands + +All commands are run from the root of the project, from a terminal: + +| Command | Action | +|:----------------|:--------------------------------------------| +| `npm install` | Installs dependencies | +| `npm run start` | Starts local dev server at `localhost:3000` | +| `npm run build` | Build your production site to `./dist/` | + +## 👀 Want to learn more? + +Feel free to check [our documentation](https://github.com/snowpackjs/astro) or jump into our [Discord server](https://astro.build/chat). diff --git a/examples/blog-multiple-authors/astro.config.mjs b/examples/blog-multiple-authors/astro.config.mjs new file mode 100644 index 000000000..d72db6491 --- /dev/null +++ b/examples/blog-multiple-authors/astro.config.mjs @@ -0,0 +1,14 @@ +export default { + // projectRoot: '.', // Where to resolve all URLs relative to. Useful if you have a monorepo project. + // pages: './src/pages', // Path to Astro components, pages, and data + // dist: './dist', // When running `astro build`, path to final static output + // public: './public', // A folder of static files Astro will copy to the root. Useful for favicons, images, and other files that don’t need processing. + buildOptions: { + site: 'http://example.com', // Your public domain, e.g.: https://my-site.dev/. Used to generate sitemaps and canonical URLs. + // sitemap: true, // Generate sitemap (set to "false" to disable) + }, + devOptions: { + // port: 3000, // The port to run the dev server on. + // tailwindConfig: '', // Path to tailwind.config.js if used, e.g. './tailwind.config.js' + }, +}; diff --git a/examples/blog-multiple-authors/package.json b/examples/blog-multiple-authors/package.json new file mode 100644 index 000000000..81e145a3f --- /dev/null +++ b/examples/blog-multiple-authors/package.json @@ -0,0 +1,15 @@ +{ + "name": "@astrojs/example-blog-multiple-authors", + "version": "0.0.2", + "private": true, + "scripts": { + "start": "astro dev", + "build": "astro build" + }, + "devDependencies": { + "astro": "^0.15.0" + }, + "snowpack": { + "workspaceRoot": "../.." + } +} diff --git a/examples/blog/public/authors/don.jpg b/examples/blog-multiple-authors/public/authors/don.jpg similarity index 100% rename from examples/blog/public/authors/don.jpg rename to examples/blog-multiple-authors/public/authors/don.jpg diff --git a/examples/blog/public/authors/sancho.jpg b/examples/blog-multiple-authors/public/authors/sancho.jpg similarity index 100% rename from examples/blog/public/authors/sancho.jpg rename to examples/blog-multiple-authors/public/authors/sancho.jpg diff --git a/examples/blog-multiple-authors/public/favicon.svg b/examples/blog-multiple-authors/public/favicon.svg new file mode 100644 index 000000000..542f90aec --- /dev/null +++ b/examples/blog-multiple-authors/public/favicon.svg @@ -0,0 +1,11 @@ + + + + + diff --git a/examples/blog-multiple-authors/public/global.scss b/examples/blog-multiple-authors/public/global.scss new file mode 100644 index 000000000..d5891f6b4 --- /dev/null +++ b/examples/blog-multiple-authors/public/global.scss @@ -0,0 +1,25 @@ +body { + font-family: 'Spectral', serif; + line-height: 1.4; +} + +p { + line-height: 2; +} + +a { + color: crimson; +} + +img { + max-width: 100%; + height: auto; +} + +.wrapper { + max-width: 60rem; + margin-left: auto; + margin-right: auto; + padding-left: 2rem; + padding-right: 2rem; +} diff --git a/examples/blog/public/images/chapter-01.jpg b/examples/blog-multiple-authors/public/images/chapter-01.jpg similarity index 100% rename from examples/blog/public/images/chapter-01.jpg rename to examples/blog-multiple-authors/public/images/chapter-01.jpg diff --git a/examples/blog/public/images/chapter-02.jpg b/examples/blog-multiple-authors/public/images/chapter-02.jpg similarity index 100% rename from examples/blog/public/images/chapter-02.jpg rename to examples/blog-multiple-authors/public/images/chapter-02.jpg diff --git a/examples/blog/public/images/chapter-03.jpg b/examples/blog-multiple-authors/public/images/chapter-03.jpg similarity index 100% rename from examples/blog/public/images/chapter-03.jpg rename to examples/blog-multiple-authors/public/images/chapter-03.jpg diff --git a/examples/blog/src/components/MainHead.astro b/examples/blog-multiple-authors/src/components/MainHead.astro similarity index 100% rename from examples/blog/src/components/MainHead.astro rename to examples/blog-multiple-authors/src/components/MainHead.astro diff --git a/examples/blog/src/components/Nav.astro b/examples/blog-multiple-authors/src/components/Nav.astro similarity index 100% rename from examples/blog/src/components/Nav.astro rename to examples/blog-multiple-authors/src/components/Nav.astro diff --git a/examples/blog/src/components/Pagination.astro b/examples/blog-multiple-authors/src/components/Pagination.astro similarity index 100% rename from examples/blog/src/components/Pagination.astro rename to examples/blog-multiple-authors/src/components/Pagination.astro diff --git a/examples/blog/src/components/PostPreview.astro b/examples/blog-multiple-authors/src/components/PostPreview.astro similarity index 100% rename from examples/blog/src/components/PostPreview.astro rename to examples/blog-multiple-authors/src/components/PostPreview.astro diff --git a/examples/blog/src/data/authors.json b/examples/blog-multiple-authors/src/data/authors.json similarity index 100% rename from examples/blog/src/data/authors.json rename to examples/blog-multiple-authors/src/data/authors.json diff --git a/examples/blog/src/layouts/post.astro b/examples/blog-multiple-authors/src/layouts/post.astro similarity index 100% rename from examples/blog/src/layouts/post.astro rename to examples/blog-multiple-authors/src/layouts/post.astro diff --git a/examples/blog/src/pages/$author.astro b/examples/blog-multiple-authors/src/pages/$author.astro similarity index 100% rename from examples/blog/src/pages/$author.astro rename to examples/blog-multiple-authors/src/pages/$author.astro diff --git a/examples/blog/src/pages/$posts.astro b/examples/blog-multiple-authors/src/pages/$posts.astro similarity index 100% rename from examples/blog/src/pages/$posts.astro rename to examples/blog-multiple-authors/src/pages/$posts.astro diff --git a/examples/blog/src/pages/about.astro b/examples/blog-multiple-authors/src/pages/about.astro similarity index 100% rename from examples/blog/src/pages/about.astro rename to examples/blog-multiple-authors/src/pages/about.astro diff --git a/examples/blog-multiple-authors/src/pages/index.astro b/examples/blog-multiple-authors/src/pages/index.astro new file mode 100644 index 000000000..a4407378c --- /dev/null +++ b/examples/blog-multiple-authors/src/pages/index.astro @@ -0,0 +1,43 @@ +--- +import MainHead from '../components/MainHead.astro'; +import Nav from '../components/Nav.astro'; +import PostPreview from '../components/PostPreview.astro'; +import Pagination from '../components/Pagination.astro'; + +// page +let title = 'Don’s Blog'; +let description = 'An example blog on Astro'; + +// collection +// note: we want to show first 3 posts here, but we don’t want to paginate at /1, /2, /3, etc. +// so we show a preview of posts here, but actually paginate from $posts.astro +import authorData from '../data/authors.json'; + +let allPosts = Astro.fetchContent('./post/*.md'); +allPosts.sort((a, b) => new Date(b.date) - new Date(a.date)); +let firstPage = allPosts.slice(0, 2); +--- + + + + {title} + + + + +