Skip to content

caragolfoundation/caragolfoundation.org

Repository files navigation

caragolfoundation.org 🌍

deploy ci lint CodeQL

The public caragolfoundation.org website and source code.

Config Files

The core way this template is different from the original is that it heavily uses .js config files to configure data and content for its site.

Here are a few common config directories and what you will find there:

Project structure

Inside AstroWind template, you'll see the following folders and files:

/
β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ robots.txt
β”‚   └── favicon.ico
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/
β”‚   β”‚   β”œβ”€β”€ images/
β”‚   β”‚   └── styles/
β”‚   β”‚       └── base.css
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ blog/
β”‚   β”‚   β”œβ”€β”€ common/
β”‚   β”‚   β”œβ”€β”€ widgets/
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.astro
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ CustomStyles.astro
β”‚   β”‚   └── Logo.astro
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ components/
|   |   |   β”œβ”€β”€ announcement.js
|   |   |   β”œβ”€β”€ call-to-action.js
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ home/
|   |   |   β”œβ”€β”€ content.js
|   |   |   β”œβ”€β”€ faqs.js
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ site/
β”‚   β”‚   β”‚   β”œβ”€β”€ blog.js
|   |   |   β”œβ”€β”€ config.js
β”‚   β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ content/
β”‚   β”‚   β”œβ”€β”€ post/
β”‚   β”‚   β”‚   β”œβ”€β”€ post-slug-1.md
β”‚   β”‚   β”‚   β”œβ”€β”€ post-slug-2.mdx
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β””-- config.ts
β”‚   β”œβ”€β”€ layouts/
β”‚   β”‚   β”œβ”€β”€ BaseLayout.astro
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ [...blog]/
β”‚   β”‚   β”‚   β”œβ”€β”€ [category]/
β”‚   β”‚   β”‚   β”œβ”€β”€ [tag]/
β”‚   β”‚   β”‚   β”œβ”€β”€ [...page].astro
β”‚   β”‚   β”‚   └── index.astro
β”‚   β”‚   β”œβ”€β”€ index.astro
β”‚   β”‚   β”œβ”€β”€ about.md
β”‚   β”‚   β”œβ”€β”€ 404.astro
β”‚   β”‚   β”œ-- rss.xml.ts
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ config.mjs
β”‚   └── data.js
β”œβ”€β”€ package.json
β”œβ”€β”€ astro.config.mjs
└── ...

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 if they do not require any transformation or in the assets/ directory if they are imported directly.

General Edits πŸ“

Brief documentation section around general website edits

Images πŸ–ΌοΈ

Images for .md files that are not blog posts are stored in the public/assets/ directory.

Images for .md|.mdx blog posts, and other .astro files are stored in the src/assets/images/ directory.

Creating a New Page πŸ“„

If you wish to create a new page, you have two options: advanced or simple.

Simple Pages πŸ“„

Create a new .md in the src/pages/ directory. This will create a new page with the same name as the file. For example, if you create a file called example.md, you will have a page at /example with the contents of example.md.

If you want to link out to this page from a .astro file, you can use the getPermalink function like so:

<a href={getPermalink('/example')}>Example Page</a>

You can also link out to this page from .js files where the getPermalink function is available. For example, in the src/data.js file:

href: getPermalink('/example');

Advanced Pages πŸ“„

If you want, you can also fully construct pages by using .astro files. This is useful if you want to use Astro components or other advanced features.

You best place is the official Astro documentation

Blog Posts πŸ“”

Blog posts are written in markdown and stored in the src/content/post directory.

To create a new blog post, follow the general steps below:

  1. Create a new markdown file (<name>.md) in the src/content/post directory (ensure the filename is unique)

  2. Add a header section to your blog post with some details (example below)

    ---
    publishDate: 2023-01-06T00:00:00Z
    title: Example Post 1
    excerpt: Sint sit cillum pariatur eiusmod nulla pariatur ipsum. Sit laborum anim qui mollit tempor pariatur.
    image: ~/assets/images/colors.jpg
    tags:
      - project
      - blog
      - environment
    canonical: https://caragolfoundation.org/post-1
    draft: false
    ---

    This section is called "frontmatter" in Astro. You can read more about it here

  3. Now that you have a header section, you can start writing your blog post in markdown!

  4. When you are done, commit your changes and open a pull request

If you need help with formatting markdown, check out this guide for help

It should be noted that you you can use a more advanced version of markdown with .mdx extensions. You can do all sorts of wild things with .mdx and an example can be found here

Commands

All commands are run from the root of the project, from a terminal:

Command Action
npm install Installs dependencies
npm run dev Starts local dev server at localhost:3000
npm run build Build your production site to ./dist/
npm run preview Preview your build locally, before deploying
npm run format Format codes with Prettier
npm run lint:eslint Run Eslint
npm run astro ... Run CLI commands like astro add, astro preview

Development

Here are some basic commands to get you up and running to develop with this template:

  1. Install npm dependencies

    npm i
  2. Start the development server

    npm run dev
  3. View your site at localhost:3000

Live reload is enabled by default, so any changes you make will be reflected in the browser.

Deployment

Deployment docs for GitHub Pages

When you push changes to this repository, GitHub will automatically build and deploy your site through GitHub Actions + GitHub Pages.

Branch Deploy

This repository also comes bundled with the branch-deploy Action. Please ensure you view the branch-deploy.yml file for reference.

The branch-deploy Action will allow you to trigger branch deployments from pull requests by using comments such as .deploy.

Build Cache

This templates also uses a custom GitHub Actions build cache to help speed things up in CI when processing images. If you make any changes to images when working on a project using this template, please ensure to run npm run build before deploying to ensure your cache.json file is updated.

Making Changes

This section goes into details on how you can make changes to the template.

Live Commit Examples

Actual examples in the form of commits to this repository:

Acknowledgements

This theme is based off the template by onwidget