├── src
├── env.d.ts
├── assets
│ └── base.css
├── pages
│ ├── index.astro
│ └── dinos
│ │ └── [slug].astro
├── layouts
│ └── Layout.astro
└── components
│ ├── Card.astro
│ └── Footer.astro
├── .vscode
├── extensions.json
└── launch.json
├── git-push.sh
├── astro.config.mjs
├── .gitignore
├── tsconfig.json
├── lib
└── api.js
├── package.json
├── tailwind.config.cjs
├── README.md
└── public
└── favicon.svg
/src/env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": ["astro-build.astro-vscode"],
3 | "unwantedRecommendations": []
4 | }
5 |
--------------------------------------------------------------------------------
/git-push.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Enter the commit message: "
4 | read commit_message
5 |
6 | git add .
7 | git commit -am "$commit_message"
8 | git push origin main
9 |
10 | clear
11 | figlet "Done!"
12 | sleep 3
13 | clear
14 |
--------------------------------------------------------------------------------
/.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 |
--------------------------------------------------------------------------------
/astro.config.mjs:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'astro/config';
2 |
3 | // https://astro.build/config
4 | import tailwind from '@astrojs/tailwind';
5 |
6 | // https://astro.build/config
7 | export default defineConfig({
8 | integrations: [tailwind()],
9 | output: 'static',
10 | });
11 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # build output
2 | dist/
3 | .output/
4 |
5 | # dependencies
6 | node_modules/
7 |
8 | # logs
9 | npm-debug.log*
10 | yarn-debug.log*
11 | yarn-error.log*
12 | pnpm-debug.log*
13 |
14 |
15 | # environment variables
16 | .env
17 | .env.production
18 |
19 | # macOS-specific files
20 | .DS_Store
21 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "astro/tsconfigs/base",
3 | "compilerOptions": {
4 | // Needed for TypeScript intellisense in the template inside Vue files
5 | "jsx": "preserve",
6 | "baseUrl": ".",
7 | "allowJs": true,
8 | "types": ["astro/client"],
9 | "paths": {
10 | "~/*": ["src/*"],
11 | "lib/*": ["lib/*"]
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/lib/api.js:
--------------------------------------------------------------------------------
1 | import dotenv from 'dotenv';
2 | dotenv.config();
3 |
4 | const API_URL = process.env.API_URL;
5 |
6 | // Gets post by API URL and given path
7 | export async function fetchAPI(path) {
8 | const res = await fetch(`${API_URL}${path}`);
9 | const json = await res.json();
10 |
11 | return json;
12 | }
13 |
14 | export async function getPosts() {
15 | let posts = await fetchAPI('dinos?per_page=50&_embed');
16 | return posts;
17 | }
18 |
--------------------------------------------------------------------------------
/src/assets/base.css:
--------------------------------------------------------------------------------
1 | @tailwind base;
2 | @tailwind components;
3 | @tailwind utilities;
4 |
5 | h2 {
6 | @apply text-3xl font-extrabold;
7 | }
8 |
9 | p {
10 | @apply mt-2;
11 | }
12 |
13 | /* Scroll bar */
14 | ::-webkit-scrollbar {
15 | width: 12px;
16 | }
17 | ::-webkit-scrollbar-thumb {
18 | background: #42536b;
19 | }
20 | ::-webkit-scrollbar-thumb:hover {
21 | background: #34445a;
22 | }
23 | ::-webkit-scrollbar-track {
24 | background-color: #1f2937;
25 | }
26 |
--------------------------------------------------------------------------------
/src/pages/index.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import Layout from '../layouts/Layout.astro';
3 | import Card from '~/components/Card.astro';
4 | import { getPosts } from '../../lib/api';
5 |
6 | let posts = await getPosts();
7 | ---
8 |
9 |
10 |
13 | {
14 | posts.map((post) => (
15 | <>
16 |
17 | >
18 | ))
19 | }
20 |
21 |
22 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@and249/astro-wordpress",
3 | "type": "module",
4 | "version": "0.0.1",
5 | "private": true,
6 | "scripts": {
7 | "dev": "astro dev",
8 | "start": "astro dev",
9 | "build": "astro build",
10 | "preview": "astro preview",
11 | "astro": "astro"
12 | },
13 | "dependencies": {
14 | "@astrojs/tailwind": "^2.1.3",
15 | "astro": "^1.6.11",
16 | "astro-icon": "^0.8.0",
17 | "daisyui": "^2.42.1",
18 | "dotenv": "^16.0.3",
19 | "tailwindcss": "^3.2.4"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/tailwind.config.cjs:
--------------------------------------------------------------------------------
1 | /** @type {import('tailwindcss').Config} */
2 | module.exports = {
3 | content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
4 | theme: {
5 | extend: {},
6 | },
7 | plugins: [require('daisyui')],
8 | daisyui: {
9 | themes: [
10 | {
11 | mytheme: {
12 | primary: '#d94948',
13 | secondary: '#4959ed',
14 | accent: '#38077c',
15 | neutral: '#1F2228',
16 | 'base-100': '#1f2937',
17 | info: '#5eead4',
18 | success: '#126E52',
19 | warning: '#C49B08',
20 | error: '#FA1E29',
21 | },
22 | },
23 | ],
24 | },
25 | };
26 |
--------------------------------------------------------------------------------
/src/layouts/Layout.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import '~/assets/base.css';
3 | import Footer from '~/components/Footer.astro';
4 | export interface Props {
5 | title: string;
6 | }
7 |
8 | const { title } = Astro.props;
9 | ---
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | {title}
19 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/components/Card.astro:
--------------------------------------------------------------------------------
1 | ---
2 | export interface Props {
3 | post: {};
4 | }
5 |
6 | let postExcerpt = (post) => {
7 | let content = post.content.rendered.split('.');
8 | return `${content[0]}. ${content[1]}...`;
9 | };
10 | const { post } = Astro.props;
11 | ---
12 |
13 |
14 |
15 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/src/components/Footer.astro:
--------------------------------------------------------------------------------
1 | ---
2 | import { Icon } from 'astro-icon';
3 | ---
4 |
5 |
51 |
--------------------------------------------------------------------------------
/src/pages/dinos/[slug].astro:
--------------------------------------------------------------------------------
1 | ---
2 | import { getPosts } from '../../../lib/api';
3 |
4 | const { slug } = Astro.params;
5 |
6 | import Layout from '~/layouts/Layout.astro';
7 |
8 | export async function getStaticPaths() {
9 | let dinos = await getPosts();
10 |
11 | return dinos.map((post) => {
12 | return {
13 | params: { slug: post.slug },
14 | props: {
15 | title: post.title.rendered,
16 | content: post.content.rendered,
17 | image: post._embedded['wp:featuredmedia']['0'].source_url,
18 |
19 | // Spreading the Custom Fields into a meta object
20 | meta: {
21 | ...post.acf,
22 | },
23 | },
24 | };
25 | });
26 | }
27 |
28 | const { title, content, image, meta } = Astro.props;
29 | ---
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
{title}
39 |
40 |
41 |
42 |
43 |
44 | Size:
45 | {meta.size.replace('.', ' with a')}
46 |
47 |
Weight: {meta.weight}
48 |
Habitat: {meta.habitat}
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Welcome to [Astro](https://astro.build)
2 |
3 | [](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
4 | [](https://codesandbox.io/s/github/withastro/astro/tree/latest/examples/basics)
5 |
6 | > 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
7 |
8 | 
9 |
10 |
11 | ## 🚀 Project Structure
12 |
13 | Inside of your Astro project, you'll see the following folders and files:
14 |
15 | ```
16 | /
17 | ├── public/
18 | │ └── favicon.svg
19 | ├── src/
20 | │ ├── components/
21 | │ │ └── Card.astro
22 | │ ├── layouts/
23 | │ │ └── Layout.astro
24 | │ └── pages/
25 | │ └── index.astro
26 | └── package.json
27 | ```
28 |
29 | Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
30 |
31 | There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
32 |
33 | Any static assets, like images, can be placed in the `public/` directory.
34 |
35 | ## 🧞 Commands
36 |
37 | All commands are run from the root of the project, from a terminal:
38 |
39 | | Command | Action |
40 | | :--------------------- | :------------------------------------------------- |
41 | | `npm install` | Installs dependencies |
42 | | `npm run dev` | Starts local dev server at `localhost:3000` |
43 | | `npm run build` | Build your production site to `./dist/` |
44 | | `npm run preview` | Preview your build locally, before deploying |
45 | | `npm run astro ...` | Run CLI commands like `astro add`, `astro preview` |
46 | | `npm run astro --help` | Get help using the Astro CLI |
47 |
48 | ## 👀 Want to learn more?
49 |
50 | Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
51 |
--------------------------------------------------------------------------------
/public/favicon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------