├── tsconfig.json
├── src
├── env.d.ts
├── templates
│ ├── NotFoundPage.astro
│ ├── DefaultPage.astro
│ ├── BlogShowPage.astro
│ ├── index.js
│ ├── BlogIndexPage.astro
│ └── HomePage.astro
├── widgets
│ ├── RichTextWidget.astro
│ ├── ImageWidget.astro
│ ├── index.js
│ ├── TwoColumnWidget.astro
│ └── VideoWidget.astro
└── pages
│ └── [...slug].astro
├── .vscode
├── extensions.json
└── launch.json
├── public
├── images
│ └── image-widget-placeholder.jpg
└── favicon.svg
├── README.md
├── .gitignore
├── package.json
└── astro.config.mjs
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "astro/tsconfigs/base"
3 | }
4 |
--------------------------------------------------------------------------------
/src/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": ["astro-build.astro-vscode"],
3 | "unwantedRecommendations": []
4 | }
5 |
--------------------------------------------------------------------------------
/public/images/image-widget-placeholder.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/apostrophecms/astro-frontend/main/public/images/image-widget-placeholder.jpg
--------------------------------------------------------------------------------
/src/templates/NotFoundPage.astro:
--------------------------------------------------------------------------------
1 | ---
2 | ---
3 |
4 | Not Found
5 | Sorry, that page was not found.
6 |
7 |
--------------------------------------------------------------------------------
/src/widgets/RichTextWidget.astro:
--------------------------------------------------------------------------------
1 | ---
2 | const { widget } = Astro.props;
3 | const { content } = widget;
4 | ---
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "command": "./node_modules/.bin/astro dev",
6 | "name": "Development server",
7 | "request": "launch",
8 | "type": "node-terminal"
9 | }
10 | ]
11 | }
12 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # apostrophecms/astro-frontend
2 |
3 | > ⚠️ This legacy project is no longer maintained. You should use our [ApostropheCMS + Astro Essentials Starter Kit](https://github.com/apostrophecms/starter-kit-astro-essentials) instead. That project is actively maintained with our latest techniques for Astro integration.
4 |
5 |
--------------------------------------------------------------------------------
/src/templates/DefaultPage.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import AposArea from '@apostrophecms/apostrophe-astro/components/AposArea.astro';
3 | const { page, user, query } = Astro.props.aposData;
4 | const { main } = page;
5 | ---
6 |
7 |
8 | { page.title }
9 |
10 |
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # build output
2 | dist/
3 | # generated types
4 | .astro/
5 |
6 | # dependencies
7 | node_modules/
8 |
9 | # logs
10 | npm-debug.log*
11 | yarn-debug.log*
12 | yarn-error.log*
13 | pnpm-debug.log*
14 |
15 |
16 | # environment variables
17 | .env
18 | .env.production
19 |
20 | # macOS-specific files
21 | .DS_Store
22 |
--------------------------------------------------------------------------------
/src/widgets/ImageWidget.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import placeholderImg from '../../public/images/image-widget-placeholder.jpg';
3 |
4 | const { widget } = Astro.props;
5 | const placeholder = widget?.aposPlaceholder;
6 |
7 | const src = placeholder ?
8 | placeholderImg.src :
9 | widget?._image[0]?.attachment?._urls['full'];
10 | ---
11 |
16 |
17 |
--------------------------------------------------------------------------------
/src/templates/BlogShowPage.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import AposArea from '@apostrophecms/apostrophe-astro/components/AposArea.astro';
3 | import dayjs from 'dayjs';
4 |
5 | const { page, piece, user, query } = Astro.props.aposData;
6 | const { main } = piece;
7 | ---
8 |
9 |
10 | { piece.title }
11 |
12 | Released On { dayjs(piece.publishedAt).format('MMMM D, YYYY') }
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/widgets/index.js:
--------------------------------------------------------------------------------
1 | import RichTextWidget from './RichTextWidget.astro';
2 | import ImageWidget from './ImageWidget.astro';
3 | import VideoWidget from './VideoWidget.astro';
4 | import TwoColumnWidget from './TwoColumnWidget.astro';
5 |
6 | const widgetComponents = {
7 | '@apostrophecms/rich-text': RichTextWidget,
8 | '@apostrophecms/image': ImageWidget,
9 | '@apostrophecms/video': VideoWidget,
10 | 'two-column': TwoColumnWidget
11 | };
12 |
13 | export default widgetComponents;
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "astro-frontend",
3 | "type": "module",
4 | "version": "1.0.0",
5 | "scripts": {
6 | "dev": "astro dev",
7 | "start": "astro dev",
8 | "build": "astro build",
9 | "serve": "node ./dist/server/entry.mjs",
10 | "preview": "astro preview",
11 | "astro": "astro"
12 | },
13 | "dependencies": {
14 | "@apostrophecms/apostrophe-astro": "^1.0.0",
15 | "@astrojs/node": "^8.3.4",
16 | "astro": "^4.0.0",
17 | "dayjs": "^1.11.10",
18 | "vite": "^5.0.7"
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/widgets/TwoColumnWidget.astro:
--------------------------------------------------------------------------------
1 | ---
2 | const { widget, options } = Astro.props;
3 | import AposArea from '@apostrophecms/apostrophe-astro/components/AposArea.astro';
4 | ---
5 |
13 |
21 |
--------------------------------------------------------------------------------
/src/templates/index.js:
--------------------------------------------------------------------------------
1 | import HomePage from './HomePage.astro';
2 | import DefaultPage from './DefaultPage.astro';
3 | import BlogIndexPage from './BlogIndexPage.astro';
4 | import BlogShowPage from './BlogShowPage.astro';
5 | import NotFoundPage from './NotFoundPage.astro';
6 |
7 | const templateComponents = {
8 | '@apostrophecms/home-page': HomePage,
9 | 'default-page': DefaultPage,
10 | '@apostrophecms/blog-page:index': BlogIndexPage,
11 | '@apostrophecms/blog-page:show': BlogShowPage,
12 | '@apostrophecms/page:notFound': NotFoundPage
13 | };
14 |
15 | export default templateComponents;
16 |
--------------------------------------------------------------------------------
/public/favicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
9 |
10 |
--------------------------------------------------------------------------------
/src/pages/[...slug].astro:
--------------------------------------------------------------------------------
1 | ---
2 | import aposPageFetch from '@apostrophecms/apostrophe-astro/lib/aposPageFetch.js';
3 | import AposLayout from '@apostrophecms/apostrophe-astro/components/layouts/AposLayout.astro';
4 | import AposTemplate from '@apostrophecms/apostrophe-astro/components/AposTemplate.astro';
5 |
6 | const aposData = await aposPageFetch(Astro.request);
7 | const bodyClass = `myclass`;
8 |
9 | if (aposData.redirect) {
10 | return Astro.redirect(aposData.url, aposData.status);
11 | }
12 | if (aposData.notFound) {
13 | Astro.response.status = 404;
14 | }
15 | ---
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/src/templates/BlogIndexPage.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import dayjs from 'dayjs';
3 | import setParameter from '@apostrophecms/apostrophe-astro/lib/aposSetQueryParameter.js';
4 |
5 | const {
6 | page,
7 | user,
8 | query,
9 | piecesFilters,
10 | pieces,
11 | currentPage,
12 | totalPages
13 | } = Astro.props.aposData;
14 |
15 | const pages = [];
16 | for (let i = 1; (i <= totalPages); i++) {
17 | pages.push({
18 | number: i,
19 | current: page === currentPage,
20 | url: setParameter(Astro.url, 'page', i)
21 | });
22 | }
23 | ---
24 |
25 |
26 | { page.title }
27 |
28 | Blog Posts
29 |
30 | {pieces.map(piece => (
31 |
32 | Released On { dayjs(piece.publishedAt).format('MMMM D, YYYY') }
33 |
34 |
37 | ))}
38 |
39 | {pages.map(page => (
40 | {page.number}
43 |
44 | ))}
45 |
--------------------------------------------------------------------------------
/astro.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'astro/config';
2 | import node from '@astrojs/node';
3 | import apostrophe from '@apostrophecms/apostrophe-astro';
4 |
5 | export default defineConfig({
6 | output: 'server',
7 | adapter: node({
8 | mode: 'standalone'
9 | }),
10 | integrations: [
11 | apostrophe({
12 | aposHost: 'http://localhost:3000',
13 | widgetsMapping: './src/widgets',
14 | templatesMapping: './src/templates',
15 | forwardHeaders: [
16 | 'content-security-policy',
17 | 'strict-transport-security',
18 | 'x-frame-options',
19 | 'referrer-policy',
20 | 'cache-control',
21 | // Should only be passed in multisite projects, and only if Apostrophe and Astro are hosted together
22 | // 'host'
23 | ]
24 | })
25 | ],
26 | vite: {
27 | ssr: {
28 | // Do not externalize the @apostrophecms/apostrophe-astro plugin, we need
29 | // to be able to use virtual: URLs there
30 | noExternal: [ '@apostrophecms/apostrophe-astro' ],
31 | }
32 | }
33 | });
34 |
--------------------------------------------------------------------------------
/src/templates/HomePage.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import AposArea from '@apostrophecms/apostrophe-astro/components/AposArea.astro';
3 | const { page, user, query } = Astro.props.aposData;
4 | const { main } = page;
5 | ---
6 |
7 |
8 |
9 | Welcome to Apostrophe 3
10 |
11 | { user ? '' :
12 |
13 |
First time spinning up the Apostrophe Astro combined project?
14 |
15 | Use the credentials created during setup with the Apostrophe CLI or create a new user with this command
16 | in your apostrophe project folder (not Astro):
17 |
18 |
19 | Command Line
20 |
21 | node app @apostrophecms/user:add myUsername admin
22 |
23 |
24 |
25 | Then log in here.
26 |
27 |
28 |
29 | }
30 |
31 | For a guide on how to configure and customize this project, please check out the apostrophe-astro documentation .
32 |
33 |
34 | { (user && !query?.['apos-edit']) ?
35 |
36 | Enter Edit mode from the admin bar 👆 to begin.
37 |
38 | :
39 |
40 | Add and edit content below in the content area. 👇
41 |
42 | }
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/src/widgets/VideoWidget.astro:
--------------------------------------------------------------------------------
1 | ---
2 | const { widget } = Astro.props;
3 | const placeholder = widget?.aposPlaceholder ? 'true' : '';
4 | const url = widget?.video?.url;
5 | ---
6 |
11 |
14 |
15 |
--------------------------------------------------------------------------------