Skip to content

Commit

Permalink
[WIP] Begin migrating data
Browse files Browse the repository at this point in the history
- Consolidates partner agency data
  - Removes _data/featured_agencies.yml
  - Adds `featured` boolean to _data/agencies.yml
  - Fixes HHS full name so it's findable
- Simplifies partner agency logo info, from paths -> filenames.
- Renames collections.{collection name} from singular to plural, e.g. to collections.posts
- Replaces site.baseurl for simple links. Image sources and breadcrumbs were left as-is for later.
- Adds back featured projects/agencies to homepage.
- Improves footer of blog post show page
  - Simplifies featured-posts partial, to limit entries by default
  - Adds back the next/prev blog post links
- RISKY: Removes the reference to styles.css. It doesn't seem to have affected styles, since the built styles are loaded elsewhere, but now link checks are passing.
- Adds `npm run precommit` command to run a full rebuild and run html and link tests

Todos:
- It would be nice to have an {% agency_logo %} shortcode, so we don't have the path to the agency logo folder as literals in multiple places.
  • Loading branch information
beechnut committed Jun 5, 2024
1 parent 51b9d8d commit 0f5796f
Show file tree
Hide file tree
Showing 21 changed files with 232 additions and 179 deletions.
4 changes: 2 additions & 2 deletions .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ module.exports = function (config) {
return filterTagList([...tagSet]);
});

config.addCollection('post', (collection) => collection.getFilteredByGlob('content/posts/*.md'));
config.addCollection('service', (collection) => collection.getFilteredByGlob('content/pages/projects/services/*.md'));
config.addCollection('posts', (collection) => collection.getFilteredByGlob('content/posts/*.md'));
config.addCollection('services', (collection) => collection.getFilteredByGlob('content/pages/projects/services/*.md'));

// Customize Markdown library and settings
const markdownLibrary = markdownIt({
Expand Down
198 changes: 124 additions & 74 deletions _data/agencies.yml
Original file line number Diff line number Diff line change
@@ -1,94 +1,144 @@
- name: U.S. Air Force
logo: /assets/img/logos/agencies/usaf.png
- name: U.S. Army
logo: /assets/img/logos/agencies/us-army.png
- name: U.S. Marine Corps
-
name: U.S. Air Force
acronym: USAF
logo: usaf.png
featured: true
-
name: U.S. Army
logo: us-army.png
-
name: U.S. Marine Corps
acronym: USMC
logo: /assets/img/logos/agencies/usmc.png
- name: U.S. Navy
logo: /assets/img/logos/agencies/us-navy.png
- name: Centers for Medicare and Medicaid Services
logo: /assets/img/logos/agencies/centers-for-medicare-and-medicaid.png
- name: Consumer Financial Protection Bureau
logo: usmc.png
-
name: U.S. Navy
logo: us-navy.png
-
name: Centers for Medicare and Medicaid Services
logo: centers-for-medicare-and-medicaid.png
-
name: Consumer Financial Protection Bureau
acronym: CFPB
logo: /assets/img/logos/agencies/cfpb.png
- name: Department of Agriculture
logo: cfpb.png
-
name: Department of Agriculture
acronym: USDA
logo: /assets/img/logos/agencies/USDA.svg
- name: Department of Education
logo: /assets/img/logos/agencies/USDE.png
- name: Department of Health and Human Services
logo: /assets/img/logos/agencies/USDHHS.png
- name: Department of the Interior
logo: /assets/img/logos/agencies/USDOI.svg
- name: Department of Justice
logo: /assets/img/logos/agencies/USDOJ.png
- name: Department of State
logo: /assets/img/logos/agencies/USDS.png
- name: Department of the Treasury
logo: /assets/img/logos/agencies/USDT.png
- name: Federal Bureau of Investigation
logo: USDA.svg
-
name: Department of Education
logo: USDE.png
-
name: Department of Health and Human Services
acronym: HHS
logo: USDHHS.png
featured: true
-
name: Department of the Interior
acronym: DOI
logo: USDOI.svg
featured: true
-
name: Department of Justice
acronym: DOJ
logo: USDOJ.png
featured: true
-
name: Department of State
logo: USDS.png
-
name: Department of the Treasury
logo: USDT.png
-
name: Federal Bureau of Investigation
acronym: FBI
logo: /assets/img/logos/agencies/fbi.png
- name: Federal Election Commission
logo: fbi.png
-
name: Federal Election Commission
acronym: FEC
logo: /assets/img/logos/agencies/fec.svg
- name: Federal Emergency Management Agency
logo: fec.svg
-
name: Federal Emergency Management Agency
acronym: FEMA
logo: /assets/img/logos/agencies/fema.png
- name: Federal Retirement Thrift Investment Board
logo: /assets/img/logos/agencies/frtib.png
- name: General Services Administration
logo: fema.png
-
name: Federal Retirement Thrift Investment Board
logo: frtib.png
-
name: General Services Administration
acronym: GSA
logo: /assets/img/logos/gsa-logo.svg
- name: National Geospatial-Intelligence Agency
logo: gsa-logo.svg
-
name: National Geospatial-Intelligence Agency
acronym: NGA
logo: /assets/img/logos/agencies/nga.png
- name: National Institute of Standards and Technology
logo: nga.png
-
name: National Institute of Standards and Technology
acronym: NIST
logo: /assets/img/logos/agencies/nist.png
- name: National Oceanic and Atmospheric Administration
logo: nist.png
-
name: National Oceanic and Atmospheric Administration
acronym: NOAA
logo: /assets/img/logos/agencies/noaa.png
- name: National Science Foundation
logo: noaa.png
-
name: National Science Foundation
acronym: NSF
logo: /assets/img/logos/agencies/nsf.png
- name: The Library of Congress
logo: /assets/img/logos/agencies/loc.png
- name: U.S. Tax Court
logo: /assets/img/logos/agencies/tax-court.png
- name: Environmental Protection Agency
logo: nsf.png
-
name: The Library of Congress
logo: loc.png
-
name: U.S. Tax Court
logo: tax-court.png
-
name: Environmental Protection Agency
acronym: EPA
logo: /assets/img/logos/agencies/EPA.png
- name: National Aeronautics and Space Administration
logo: EPA.png
-
name: National Aeronautics and Space Administration
acronym: NASA
logo: /assets/img/logos/agencies/NASA.svg
- name: National Archives and Records Administration
logo: NASA.svg
-
name: National Archives and Records Administration
acronym: NARA
logo: /assets/img/logos/agencies/NARA.png
- name: Nuclear Regulatory Commission
logo: /assets/img/logos/agencies/NRC.svg
- name: Office of Management and Budget
logo: NARA.png
-
name: Nuclear Regulatory Commission
logo: NRC.svg
-
name: Office of Management and Budget
acronym: OMB
logo: /assets/img/logos/agencies/OMB.svg
- name: Office of Personnel Management
logo: OMB.svg
featured: true
-
name: Office of Personnel Management
acronym: OPM
logo: /assets/img/logos/agencies/OPM.svg
- name: Alaska Department of Health and Social Services
logo: /assets/img/logos/agencies/alaska-dhss.png
- name: California Child Welfare Digital Services
logo: OPM.svg
-
name: Alaska Department of Health and Social Services
logo: alaska-dhss.png
-
name: California Child Welfare Digital Services
acronym: CWDS
logo: /assets/img/logos/agencies/cwds.png
- name: State of Vermont Agency of Human Services
logo: /assets/img/logos/agencies/vermont.png
- name: Securities and Exchange Commission
logo: cwds.png
-
name: State of Vermont Agency of Human Services
logo: vermont.png
-
name: Securities and Exchange Commission
acronym: SEC
logo: /assets/img/logos/agencies/SEC.svg
- name: Small Business Administration
logo: SEC.svg
-
name: Small Business Administration
acronym: SBA
logo: /assets/img/logos/agencies/SBA.svg
- name: Social Security Administration
logo: /assets/img/logos/agencies/SSA.png
- name: U.S. Postal Service
logo: SBA.svg
-
name: Social Security Administration
logo: SSA.png
-
name: State of Wisconsin
logo: wisconsin.svg
featured: true
-
name: U.S. Postal Service
acronym: USPS
logo: /assets/img/logos/agencies/USPS.svg
logo: USPS.svg
17 changes: 0 additions & 17 deletions _data/featured_agencies.yml

This file was deleted.

2 changes: 1 addition & 1 deletion _includes/banner-cta.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="grid-row">
<div class="grid-col">
<p class="font-sans-lg text-white">Work with us to plan successful projects, choose better vendors, build custom software, or learn how to work in new ways.</p>
<a class="usa-button an18f-button--accent" href="{{ site.baseurl }}/contact/">Contact us</a>
<a class="usa-button an18f-button--accent" href="{{ "/contact/" | url }}">Contact us</a>
</div>
</div>
</div>
Expand Down
39 changes: 19 additions & 20 deletions _includes/card-project.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,37 @@
This partial outputs a card that displays a project title, the associated agency logo, and an excerpt. The expected argument for this partial is the markdown file name for the project, which is in the "_services_projects" directory.
{% endcomment %}

{% assign project = site | find_collection: 'services_projects' | where: 'slug', include.project | first %}
{% assign card_link = project.permalink | prepend: site.baseurl %}

{% assign project = collections.services | where: 'fileSlug', project_id | first %}

<div class="usa-card__container">
<header class="usa-card__header">
{% if project.agency %}
<div class="display-flex flex-align-center">
{% assign agency = site.data.agencies | where: "name", project.agency | first %}
{% assign agency_logo = agency.logo %}
{% unless agency_logo %}
{% if project.agency_logo %}
{% assign agency_logo = project.agency_logo %}
{% endif %}
{% endunless %}
{% if agency_logo %}
<img src= "{{ site.baseurl }}{{ agency_logo }}"
{% comment %}
code smell: nil checks / timid code
This template is uncertain about the presence of project.data.agency, agency.logo, project.url, and project.data.title. If any of those are missing, this template doesn't work or look good.

A better way to handle would be to enforce some data guarantees in a pre-build stage, or have the
template error out.
{% endcomment %}
{% if project.data.agency %}
<div class="display-flex flex-align-center">
{% assign agency = agencies | where: "name", project.data.agency | first %}
{% if agency.logo %}
<img src="/assets/img/logos/agencies/{{ agency.logo }}"
class="maxw-8 margin-right-2"
alt=""
>
{% endif %}
<p class="line-height-sans-2 text-bold margin-top-0">{{ project.agency }}</p>
<p class="line-height-sans-2 text-bold margin-top-0">{{ agency.name }}</p>
</div>
{% endif %}
{% if card_link and project.title %}
<a href="{{ card_link }}">
<h3 class="margin-top-3 text-bold">{{ project.title }}</h3>
{% if project.url and project.data.title %}
<a href="{{ project.url }}">
<h3 class="margin-top-3 text-bold">{{ project.data.title }}</h3>
</a>
{% endif %}
{% endif %}
</header>

<div class="usa-card__body">
<p class="margin-top-2">{{ project.excerpt }}</p>
<p class="margin-top-2">{{ project.data.excerpt }}</p>
</div>
</div>
19 changes: 9 additions & 10 deletions _includes/featured-posts.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% assign featured_posts = include.related_posts %}

{% if featured_posts.size > 0 %}
{% if include.color_mode == "dark"%}
{% assign border_color = "border-primary-lightest" %}
Expand All @@ -10,19 +9,19 @@
{% assign hover_color = "hover-primary-dark" %}
{% endif %}
<ul class="grid-row grid-gap usa-list--unstyled">
{% for post in featured_posts %}
{% if include.max_num_posts and forloop.index > include.max_num_posts %}
{% break %}
{% endif %}
<li class="grid-col-12 tablet:grid-col-6 tablet-lg:grid-col-4 margin-bottom-5 ">
<a href="{{ site.baseurl }}{{ post.url }}" class="text-no-underline">
<h3 class="border-top-05 {{border_color}} {{ hover_color }} padding-top-3 margin-bottom-3 text-bold {{ text_color }}">
{% comment %}
Default behavior is to limit to 9 posts. (As of this writing, site usually uses 3 or 6.)
{% endcomment %}
{% for post in featured_posts limit: 9 %}
<li class="grid-col-12 tablet:grid-col-6 tablet-lg:grid-col-4 margin-bottom-5 ">
<a href="{{ post.url | url }}" class="text-no-underline">
<h3 class="border-top-05 {{ border_color }} {{ hover_color }} padding-top-3 margin-bottom-3 text-bold {{ text_color }}">
{{ post.title }}
</h3>
</a>
{% if include.show_excerpt %}
{% if include.show_excerpt %}
{{ post.excerpt }}
{% endif %}
{% endif %}
</li>
{% endfor %}
</ul>
Expand Down
5 changes: 2 additions & 3 deletions _includes/layouts/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
Layout for author page with their blog posts
{% endcomment %}

{% assign matching_posts = collections.post | matching: author.id | sort: 'date' | reverse %}

<section class="usa-section section-padding-sm">
<div class="grid-container">
<header>
Expand All @@ -20,6 +18,7 @@ <h1>Blog posts by {{ display_name }}</h1>
<section class="padding-sm page-tag-results">
<div class="grid-container">
<hr class="hr-1-dark margin-y-0">
{% include "post-previews.html", posts: matching_posts, tags: tags %}
{% assign matching_posts = collections.posts | matching: author.id | sort: 'date' | reverse %}
{% include "post-previews.html", posts: matching_posts %}
</div>
</section>
Loading

0 comments on commit 0f5796f

Please sign in to comment.