Skip to content

Commit

Permalink
Draft pages
Browse files Browse the repository at this point in the history
Created a wrapper function for getCollection which does not return any draft pages when in production. This allows us to incrementally migrate the legacy API reference
  • Loading branch information
AndyClifford committed Oct 2, 2023
1 parent 10ea7d2 commit d5203a0
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
with:
node-version: 18
- run: yarn install --frozen-lock-file
- run: ./build.sh http://centrapay-docs.dev.s3-website-ap-southeast-1.amazonaws.com
- run: ./build.sh http://centrapay-docs.dev.s3-website-ap-southeast-1.amazonaws.com development
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
Expand Down
5 changes: 3 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -euo pipefail

url="${1:-}"
mode="${2:-production}"

cd legacy

Expand All @@ -12,9 +13,9 @@ bundle exec jekyll build
cd ../

if [[ -n "$url" ]]; then
yarn build --site "$url"
yarn build --mode "$mode" --site "$url"
else
yarn build
yarn build --mode "$mode"
fi

rsync -a dist/* _site/
Expand Down
1 change: 1 addition & 0 deletions src/content/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const guidesCollection = defineCollection({
title: z.string(),
description: z.string(),
img: z.string().optional(),
draft: z.boolean().optional().default(false),
nav: z.object({
title: z.string().optional(),
path: z.string(),
Expand Down
10 changes: 10 additions & 0 deletions src/content/guides/draft.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Draft
description: Draft guide that is not published in production
draft: true
nav:
path: Reference/Centrapay Experiences
order: 2
---

Setting `draft: true` in the front matter of the guide means this page will not be published in production. This allows us to incrementally migrate the legacy API reference.
2 changes: 1 addition & 1 deletion src/layouts/BaseLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import MessagesBubbleDouble from '../components/icons/MessagesBubbleDouble.vue';
import Footer from '../components/Footer.vue';
import '../assets/css/tailwind.css';
import '@fontsource/inter';
import { getCollection } from 'astro:content';
import { getCollection } from '../utils/getCollection';
import Navigation from '../navigation/Navigation';
import sideNavConfig from '../navigation/sideNavConfig'
Expand Down
2 changes: 1 addition & 1 deletion src/pages/connections/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { getCollection } from 'astro:content';
import { getCollection } from '../../utils/getCollection';
import customComponents from '../../utils/customComponents';
export async function getStaticPaths() {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/guides/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
import { getCollection } from 'astro:content';
import { getCollection } from '../../utils/getCollection';
import Prose from '../../components/Prose.vue';
import TocNav from '../../components/TocNav.vue';
import BaseLayout from '../../layouts/BaseLayout.astro';
Expand Down
2 changes: 1 addition & 1 deletion src/pages/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import BaseLayout from '../layouts/BaseLayout.astro';
import FeaturedGuideCard from '../components/FeaturedGuideCard.astro';
import FeaturedContentCard from '../components/FeaturedContentCard.astro';
import { getCollection } from 'astro:content';
import { getCollection } from '../utils/getCollection';
import Prose from '../components/Prose.vue';
export async function getStaticPaths() {
Expand Down
7 changes: 7 additions & 0 deletions src/utils/getCollection.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { getCollection as get } from 'astro:content';

export async function getCollection(collection) {
return await get(collection, ({ data }) => {
return import.meta.env.MODE === 'production' ? data.draft !== true : true;
});
}

0 comments on commit d5203a0

Please sign in to comment.