Skip to content

Commit

Permalink
Merge pull request #16 from cloud-gov/chore-config-and-libs
Browse files Browse the repository at this point in the history
MERGE NEXT: Chore config and libs
  • Loading branch information
jamesthebrooks authored Oct 28, 2024
2 parents 6d5e9ad + 36f532c commit 8db0293
Show file tree
Hide file tree
Showing 22 changed files with 2,869 additions and 763 deletions.
101 changes: 84 additions & 17 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
const { DateTime } = require('luxon');
const {DateTime} = require('luxon');
const fs = require('fs');
const pluginRss = require('@11ty/eleventy-plugin-rss');
const pluginNavigation = require('@11ty/eleventy-navigation');
const markdownIt = require('markdown-it');
const markdownItAnchor = require('markdown-it-anchor');
const {markdownItTable} = require('markdown-it-table');
const yaml = require("js-yaml");
const svgSprite = require("eleventy-plugin-svg-sprite");
const { imageShortcode, imageWithClassShortcode } = require('./config');
const {imageShortcode, imageWithClassShortcode} = require('./config');
const pluginTOC = require('eleventy-plugin-toc')
const pluginMermaid = require("@kevingimbel/eleventy-plugin-mermaid");
const syntaxHighlight = require("@11ty/eleventy-plugin-syntaxhighlight");
const inspect = require("util").inspect;
const striptags = require("striptags");

module.exports = function (config) {
// Set pathPrefix for site
let pathPrefix = '/';

// Copy the `admin` folders to the output
config.addPassthroughCopy('admin');

// Copy USWDS init JS so we can load it in HEAD to prevent banner flashing
config.addPassthroughCopy({'./node_modules/@uswds/uswds/dist/js/uswds-init.js': 'assets/js/uswds-init.js'});
config.addPassthroughCopy({
'admin': 'admin',
'_assets': 'assets',
'_img': 'img',
'resources': 'resources',
'favicon.ico': 'favicon.ico',
'./node_modules/PrismJS/themes/prism-coldark-dark.css': 'assets/styles/prism-atom-dark.css',
'./node_modules/@uswds/uswds/dist/js/uswds-init.js': 'assets/js/uswds-init.js',
'./node_modules/@uswds/uswds/dist/img/sprite.svg': 'img/sprite.svg',
'./node_modules/anchor-js/anchor.min.js': 'assets/js/anchor.min.js'
});

// Add plugins
config.addFilter("striptags", (content) => {
return striptags(content);
});

// Add plugins.html
config.addPlugin(pluginRss);
config.addPlugin(pluginNavigation);

Expand All @@ -36,18 +53,24 @@ module.exports = function (config) {
svgShortcode: 'usa_icons'
});

config.addPlugin(pluginTOC, {
tags: ['h2']
});

// Allow yaml to be used in the _data dir
config.addDataExtension("yaml", contents => yaml.load(contents));

config.addFilter("debug", (content) => `<pre><code>${inspect(content)}</code></pre>`)

config.addFilter('readableDate', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat(
'dd LLL yyyy'
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat(
'LLLL d, yyyy'
);
});

// https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#valid-date-string
config.addFilter('htmlDateString', (dateObj) => {
return DateTime.fromJSDate(dateObj, { zone: 'utc' }).toFormat('yyyy-LL-dd');
return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd');
});

// Get the first `n` elements of a collection.
Expand Down Expand Up @@ -81,24 +104,67 @@ module.exports = function (config) {
collection.getAll().forEach((item) => {
(item.data.tags || []).forEach((tag) => tagSet.add(tag));
});

return filterTagList([...tagSet]);
});

config.addPlugin(syntaxHighlight, {
highlight: function (str, lang) {
if (lang === "mermaid") {
// Bypass syntax highlighting for mermaid code blocks
return `<pre class="mermaid cg-diagrams">${str}</pre>`;
}

// Use the default syntax highlighting for other languages
const hljs = require("highlight.js");
if (hljs.getLanguage(lang)) {
return `<pre><code class="language-${lang}">${hljs.highlight(str, {language: lang}).value}</code></pre>`;
}

// Fallback: Return the code without highlighting if no valid language
return `<pre><code>${str}</code></pre>`;
}
});
config.addPlugin(pluginMermaid, {
html_tag: 'div',
extra_classes: 'cg-diagrams',
mermaid_config: {
theme: 'base'
}
});

function htmlEntities(str) {
return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}

// Customize Markdown library and settings:
let markdownLibrary = markdownIt({
html: true,
breaks: true,
linkify: true,
linkify: true
}).use(markdownItAnchor, {
permalink: markdownItAnchor.permalink.ariaHidden({
placement: 'after',
class: 'direct-link',
symbol: '#',
symbol: '',
level: [1, 2, 3, 4],
}),
slugify: config.getFilter('slug'),
}).use(markdownItTable);
config.addFilter("markdown", (content) => {
return markdownLibrary.render(content);
});
markdownLibrary.renderer.rules.link_open = function (tokens, idx, options, env, self) {
const href = tokens[idx].attrGet("href");
if (href && href.startsWith("http")) {
tokens[idx].attrPush(["target", "_blank"]);
tokens[idx].attrPush(["rel", "noopener noreferrer"]);
}
return self.renderToken(tokens, idx, options);
};
markdownLibrary.renderer.rules.code_inline = (tokens, idx, {langPrefix = ''}) => {
const token = tokens[idx];
return `<code class="${langPrefix}plaintext">${htmlEntities(token.content)}</code>&nbsp;`;
};
config.setLibrary('md', markdownLibrary);

// Override Browsersync defaults (used only with --serve)
Expand All @@ -109,7 +175,7 @@ module.exports = function (config) {

browserSync.addMiddleware('*', (req, res) => {
// Provides the 404 content without redirect.
res.writeHead(404, { 'Content-Type': 'text/html; charset=UTF-8' });
res.writeHead(404, {'Content-Type': 'text/html; charset=UTF-8'});
res.write(content_404);
res.end();
});
Expand Down Expand Up @@ -165,9 +231,10 @@ module.exports = function (config) {

// These are all optional (defaults are shown):
dir: {
input: '.',
includes: '_includes',
data: '_data',
input: 'content',
pathPrefix: '/',
includes: '../_includes',
data: '../_data',
output: '_site',
},
};
Expand Down
2 changes: 2 additions & 0 deletions _data/assetPaths.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"admin.js": "/assets/js/admin-OYJBR6FH.js",
"admin.map": "/assets/js/admin-OYJBR6FH.js.map",
"anchor.mi.js": "/assets/js/anchor.min.js",
"app.js": "/assets/js/app-ZQYILJ3O.js",
"app.map": "/assets/js/app-ZQYILJ3O.js.map",
"uswds.js": "/assets/js/uswds-init.js",
"prism-atom.css": "/assets/styles/prism-atom-dark.css",
"styles.css": "/assets/styles/styles-BBYPEDQ2.css",
"styles.map": "/assets/styles/styles-BBYPEDQ2.css.map"
}
125 changes: 125 additions & 0 deletions _data/pages/navigation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
primary:
- name: Features
url: /pages/features/
- name: Success Stories
url: /pages/success-stories/
- name: Documentation
url: /pages/documentation/
- name: Pricing
url: /pages/pricing/
- name: Knowledge Base
url: /pages/knowledge-base/
- name: Contact
url: /pages/contact/
# Look inside assets/js/index.js to see that how this url changes depending on enviroment
secondary:
- name: Platform Status
url: https://cloudgov.statuspage.io/
- name: Login
url: https://pages.cloud.gov
external: true
class: usa-button usa-button-secondary nav-button

footer:
- text: Home
href: /pages/
- text: Features
href: /pages/features/
- text: Success Stories
href: /pages/success-stories/
- text: Documentation
href: /pages/documentation/
- text: Pricing
href: /pages/pricing/
- text: Knowledge Base
href: /pages/knowledge-base/
- text: Contact
href: /pages/contact/
- text: Manage Sites
href: https://pages.cloud.gov
external: true

sidenav:
- text: Using Pages
href: /pages/documentation/
subfolderitems:
- text: Why use Pages?
href: /pages/documentation/why-use-pages/
- text: Access and permissions
href: /pages/documentation/access-permissions/
- text: Adding a user to an Organization
href: /pages/documentation/adding-users/
- text: Before you launch
href: /pages/documentation/before-you-launch/
- text: Getting started with a sandbox
href: /pages/documentation/sandbox/
- text: "21st Century IDEA"
href: /pages/documentation/21st-century-idea/
- text: Getting started with Decap CMS
href: /pages/documentation/getting-started-with-decap-cms/
- text: Included with Pages
href: /pages/documentation/included-with-pages/
- text: Instructional demos
href: /pages/documentation/instructional-demos/
- text: Builds and previews
href: /pages/documentation/previews/
- text: Custom domains
href: /pages/documentation/custom-domains/
- text: Migration guide
href: /pages/documentation/migration-guide/
- text: Adding forms
href: /pages/documentation/forms/
- text: Adding search
href: /pages/documentation/search/
- text: Site templates
href: /pages/documentation/templates/
- text: Customizing your site
href: /pages/documentation/customization/
- text: Using the markup languages
href: /pages/documentation/resources/
- text: Content guide
href: /pages/documentation/content-guide/
- text: Custom headers
href: /pages/documentation/custom-headers/
- text: Federalist.json
href: /pages/documentation/federalist-json/
- text: For security and compliance
href: /pages/documentation/
subfolderitems:
- text: Security and Compliance
href: /pages/documentation/security-and-compliance
- text: Customer responsibilities
href: /pages/documentation/customer-responsibilities/
- text: FedRAMP Tracker
href: /docs/overview/fedramp-tracker/
- text: Automated Site Reports
href: /pages/documentation/automated-site-reports/
- text: For developers
href: /pages/documentation/
subfolderitems:
- text: How builds work
href: /pages/documentation/how-builds-work/
- text: Specific build errors
href: /pages/documentation/build-errors/
- text: Environment variables on builds
href: /pages/documentation/env-vars-on-pages-builds/
- text: Pages and cloud.gov
href: /pages/documentation/cloud-gov/
- text: Node on Pages
href: /pages/documentation/node-on-pages/
- text: RVM on Pages
href: /pages/documentation/rvm-on-pages/
- text: Bundler on Pages
href: /pages/documentation/bundler-on-pages/
- text: Caching Build Dependencies
href: /pages/documentation/cache-dependencies/
- text: Supported site engines
href: /pages/documentation/supported-site-engines/
- text: Large file handling
href: /pages/documentation/large-file-handling/
- text: Renaming your site's repository
href: /pages/documentation/renaming-site-repository/
- text: Monorepos on Pages
href: /pages/documentation/monorepos-on-pages/
- text: External tools and resources
href: /pages/documentation/external-tools-and-resources/
14 changes: 14 additions & 0 deletions _data/pages/templates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

items:
- title: Eleventy (11ty) - U.S. Web Design System v3.0
docs_url: https://github.com/cloud-gov/pages-uswds-11ty
preview_url: https://uswds-11ty.pages.cloud.gov/
img: https://pages.cloud.gov/images/pages-uswds-v3-11ty-thumbnail.png
order: 2
summary: ""
- title: Gatsby - U.S. Web Design System v2.0
docs_url: https://github.com/cloud-gov/pages-uswds-gatsby
preview_url: https://uswds-gatsby.pages.cloud.gov/
img: https://pages.cloud.gov/images/pages-uswds-v2-gatsby-thumbnail.png
order: 3
summary: ""
36 changes: 36 additions & 0 deletions _data/pricing.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
- package_name: Sandbox
description: A sandbox environment to run experiments to see if cloud.gov works for your team.
price: <h3>Free</h3>
memory: Limited to 1GB memory
production: Non-production systems<br /> systems cleared every 90 days
number_of_systems: Single environment
domain_names: Non-production domain names
sign_up: <a href="https://www.cloud.gov/sign-up/" class="usa-button">Get started</a><br/><a href="/docs/pricing/free-limited-sandbox/" class="small-link">About Sandbox packages &rarr;</a>
image: pricing-sandbox.svg
- package_name: Prototyping
description: Self-service workspaces for your organization to build non-production systems.
price: <h3><sup>$</sup>1780 &#47; month</h3><span>for entire organization</span>
memory: <sup>$</sup>130 &#47; GB memory per month
image: pricing-prototype.svg
production: Non-production systems
number_of_systems: An environment for each of your teams
domain_names: Non-production domain names
sign_up: <a href="mailto:inquiries@cloud.gov?subject=Purchasing%20Prototyping%20Package" class="usa-button" id="Prototyping-cta">Contact us</a><br/>
- package_name: FISMA Low
description: Production environment ideal for hosting public information.
price: <h3><sup>$</sup>2380 &#47; month</h3><span>FISMA Low system</span>
memory: <sup>$</sup>130 &#47; GB memory per month
production: One system
number_of_systems: Multiple environments (e.g. dev, stage, prod) supporting one system
domain_names: Support for your agency domain name
sign_up: <a href="mailto:inquiries@cloud.gov?subject=Purchasing%20FISMA%20Low%20Package" class="usa-button" id="FISMA-cta">Contact us</a><br/>
image: pricing-fisma-moderate.svg
- package_name: FISMA Moderate
description: Production environment for systems that need assurances in confidentiality, integrity, and availability.
price: <h3><sup>$</sup>10700 &#47; month</h3>FISMA Moderate <br /><span>DoD Impact Level 2 system</span>
memory: <sup>$</sup>130 &#47; GB memory per month
production: One system
number_of_systems: Multiple environments (e.g. dev, stage, prod) supporting one system
domain_names: Support for your agency domain name
sign_up: <a href="mailto:inquiries@cloud.gov?subject=Purchasing%20FISMA%20Package" class="usa-button" id="FISMA-cta">Contact us</a><br/>
image: pricing-fisma-moderate.svg
35 changes: 35 additions & 0 deletions _data/services.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
- name: aws-rds
page-name: relational-database
description: "Persistent, relational databases using Amazon RDS"
status: "Production"
source-code: https://github.com/cloud-gov/aws-broker
- name: aws-elasticache
description: AWS ElastiCache Redis 5.0.6 as a service
status: Production
- name: aws-elasticsearch
description: AWS Elasticsearch 7.4 as a service
status: Production
- name: cdn-route
description: "Custom domains, CDN caching, and TLS certificates with automatic renewal"
status: "Deprecated"
source-code: https://github.com/cloud-gov/cf-cdn-service-broker
- name: external-domain-service
description: "Custom domains and TLS certificates with automatic renewal"
status: "Production"
source-code: https://github.com/cloud-gov/external-domain-broker
- name: cloud-gov-identity-provider
description: "Authenticate cloud.gov users in your app"
status: "Production"
source-code: https://github.com/cloudfoundry-community/uaa-credentials-broker
- name: cloud-gov-service-account
description: "cloud.gov service accounts for automated access by programs"
status: "Production"
source-code: https://github.com/cloudfoundry-community/uaa-credentials-broker
- name: custom-domains
description: "Custom domains and TLS certificates with automatic renewal"
status: "Deprecated"
source-code: https://github.com/cloud-gov/cf-domain-broker-alb
- name: s3
description: "Amazon S3 provides developers with secure, durable, highly-scalable object storage"
status: "Production"
source-code: https://github.com/cloudfoundry-community/s3-broker
Loading

0 comments on commit 8db0293

Please sign in to comment.