Skip to content

Commit c281c98

Browse files
committed
Continue astro site build out
1 parent dd104e1 commit c281c98

86 files changed

Lines changed: 2966 additions & 829 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.astro/content-assets.mjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

.astro/content-modules.mjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

.astro/content.d.ts

Lines changed: 0 additions & 210 deletions
This file was deleted.

.astro/data-store.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

.astro/settings.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

.astro/types.d.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ _site
123123
/public/styles/**
124124
node_modules
125125
public/data/credits.json
126+
public/data/workshop.json
126127

127128
# Astro
128129
_data/assetPaths.json
129-
.astro/types.d.ts
130+
.astro/*

README.md

Lines changed: 88 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,102 @@
1-
# Astro Starter Kit: Basics
1+
# Cloud.gov Public Website
22

3-
```sh
4-
npm create astro@latest -- --template basics
5-
```
3+
This repo uses Astro to build a static site, ready to be hosted on [Cloud.gov Pages](https://cloud.gov/pages/).
4+
5+
## Local Development
6+
7+
`npm i` to install packages (use the LTS version of NodeJS)
8+
9+
`npm run dev` to copy USWDS assets and start a dev server
10+
11+
View the website at <http://localhost:4321>
12+
13+
`npm run build` to build all assets locally
614

7-
[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
8-
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics)
9-
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json)
15+
`npm run federalist` to approximate the build that happens on Pages.
1016

11-
> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!
17+
Please review the [Astro developer documentation](https://docs.astro.build/en/getting-started/) if you're going to make code changes.
1218

13-
![just-the-basics](https://github.com/withastro/astro/assets/2244813/a0a5533c-a856-4198-8470-2d67b1d7c554)
19+
### Env variables & baseurl
20+
Because Pages preview links deploy to subdirectory paths and not root-level domains, it's important to make sure there's a `FEDERALIST_URL` environment variable provided for production builds other than the final live domain. To build absolute asset paths correctly (like the sitemap and canonical URLs), the build process must provide the entire domain, including protocol (`"https://federalist-12345.sites.pages.cloud.gov/"`) and any containing directories. In production, the build process automatically prefixes relative urls automatically build for federalist previews of any branch other than `main`, using the ENV variables provided by Pages. See https://docs.cloud.gov/pages/developers/env-vars-on-pages-builds
1421

15-
## 🚀 Project Structure
22+
In order to keep links easy whether we're building the site at the root level or within a folder, this layout makes use of the rarely-seen `<base>` [element](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/base) to prefix all non-absolute links. This means that page links which direct to `[this website]/foo` are defined without the first slash (`link: 'foo'`) in YAML and output without the first slash in HTML (`<a href="foo"`).
1623

17-
Inside of your Astro project, you'll see the following folders and files:
24+
## Editing Content
1825

19-
```text
20-
/
21-
├── public/
22-
│ └── favicon.svg
23-
├── src/
24-
│ ├── layouts/
25-
│ │ └── Layout.astro
26-
│ └── pages/
27-
│ └── index.astro
28-
└── package.json
26+
The site's content is in YAML or JSON data so that it can be easily edited from the GitHub web interface if you're not running the site locally.
27+
28+
In `/src/data/`, you'll see some data files and a folder titled `pages`. All of the page-specific content is in a `page/[name].yaml` file. Sitewide content is in `sitewide.yaml`. You can edit the link in the header and footer in `header.ts` or `footer.ts`
29+
30+
The order of the page sections in the HTML is controlled elsewhere. If you need to re-order the sections on a given page, or if you've renamed a key in your page's YAML file, check the `src/pages/` folder for the `.astro` page, and update the order of the components or key name in that file.
31+
32+
```js
33+
<Hero {...content.hero} />
34+
<Tiles {...content.g2g} />
35+
<CTA {...sitewide.freeSandbox} />
2936
```
3037

31-
To learn more about the folder structure of an Astro project, refer to [our guide on project structure](https://docs.astro.build/en/basics/project-structure/).
38+
The content sections all accept:
39+
- a `heading` field
40+
- an `intro` field (parsed as markdown)
41+
- a `content` field (parsed as markdown)
42+
- an `outro` field (parsed as markdown)
43+
- a string of extra `classes` for the containing element
44+
- an `art` field which adds a pre-defined background illustration
45+
- a `color` field which applies a pre-defined color theme to this section
46+
- an `id` field which allows you to specify a unique anchor to this section for in-page linking
47+
- a `buttons` list, which can show zero, one, or more large buttons, each expecting:
48+
- a `label` which is the button text in sentence case
49+
- a `url` which should follow the conventions above (omit the first slash for relative links)
50+
- a `variant` if you wish to specify a color(`accent-warm`) or style (`outline`)
51+
52+
All of the above are optional, so if you don't want something, just omit it.
53+
54+
Some sections also use lists to show content in colums, lists, or cards. These all follow the same structure as well, within an `items` array:
55+
- a `heading` field
56+
- a `text` field (parsed as markdown)
57+
- an `icon` field which will choose from one of the [USWDS icons](https://designsystem.digital.gov/components/icon/) by name (`add_circle`)
58+
- a `button` element which has the same `label`, `url`, and `variant` button options above.
59+
The Tiles component allow you to specify whether the whole item is clickable, and to what url, using `link`. Do not use both of these together.
60+
The Topics component will style this "button" as a text link.
61+
62+
### Adding new pages
63+
64+
Add a new `src/pages/[page].astro` file and its corresponding `src/data/pages[page].yaml`. Make sure your new astro file points to the content at your new YAML file. Match your YAML keys to the objects you're passing into the components.
65+
66+
### Changing URLs
67+
68+
Rename the [page].astro filename to change the path. (Really, it's ok) This is not controlled by the page YAML file. **AND THEN:**
69+
70+
### Deleting pages / Redirects
71+
72+
Please add redirects to `redirects.ts` in the format:
73+
74+
```'/old': '/new',```
75+
76+
**whenever** you delete or rename a page url. (Images and other assets can 404).
77+
78+
### Adding images
79+
80+
There are two places for images:
81+
`src/assets/` is home to the images that are dynamically accessed and inserted into the page HTML at build time. These are minified and hashed by Astro, and their actual paths on the website are not stable. You cannot safely link directly to these assets using `src` or `href`, or in Markdown.
82+
83+
`public/assets/img` is the place for any images that are loaded by the CSS, like background images. These are also assets that do not change (or change infrequently), so their URLs are stable.
84+
85+
86+
## Contributing
3287

33-
## 🧞 Commands
88+
See [CONTRIBUTING](CONTRIBUTING.md) for additional information.
3489

35-
All commands are run from the root of the project, from a terminal:
90+
## Public domain
3691

37-
| Command | Action |
38-
| :------------------------ | :----------------------------------------------- |
39-
| `npm install` | Installs dependencies |
40-
| `npm run dev` | Starts local dev server at `localhost:4321` |
41-
| `npm run build` | Build your production site to `./dist/` |
42-
| `npm run preview` | Preview your build locally, before deploying |
43-
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
44-
| `npm run astro -- --help` | Get help using the Astro CLI |
92+
This project is in the worldwide [public domain](LICENSE.md). As stated in [CONTRIBUTING](CONTRIBUTING.md):
4593

46-
## 👀 Want to learn more?
94+
> This project is in the public domain within the United States, and copyright
95+
> and related rights in the work worldwide are waived through the [CC0 1.0
96+
> Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/).
97+
>
98+
> All contributions to this project will be released under the CC0 dedication.
99+
> By submitting a pull request, you are agreeing to comply with this waiver of
100+
> copyright interest.
47101
48-
Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
102+
See [CONTRIBUTING](CONTRIBUTING.md) for additional information.

0 commit comments

Comments
 (0)