diff --git a/functions/api/auth.js b/functions/api/auth.js new file mode 100644 index 0000000..aa8f6bc --- /dev/null +++ b/functions/api/auth.js @@ -0,0 +1,27 @@ +export async function onRequest(context) { + const { + request, // same as existing Worker API + env, // same as existing Worker API + params, // if filename includes [id] or [[path]] + waitUntil, // same as ctx.waitUntil in existing Worker API + next, // used for middleware or to fetch assets + data // arbitrary space for passing data between middlewares + } = context; + + const client_id = env.GITHUB_CLIENT_ID; + + try { + const url = new URL(request.url); + const redirectUrl = new URL('https://github.com/login/oauth/authorize'); + redirectUrl.searchParams.set('client_id', client_id); + redirectUrl.searchParams.set('redirect_uri', url.origin + '/api/callback'); + redirectUrl.searchParams.set('scope', 'repo user'); + redirectUrl.searchParams.set('state', crypto.getRandomValues(new Uint8Array(12)).join('')); + return Response.redirect(redirectUrl.href, 301); + } catch (error) { + console.error(error); + return new Response(error.message, { + status: 500 + }); + } +} diff --git a/functions/api/callback.js b/functions/api/callback.js new file mode 100644 index 0000000..5ae252c --- /dev/null +++ b/functions/api/callback.js @@ -0,0 +1,74 @@ +function renderBody(status, content) { + const html = ` + + `; + const blob = new Blob([html]); + return blob; +} + +export async function onRequest(context) { + const { + request, // same as existing Worker API + env, // same as existing Worker API + params, // if filename includes [id] or [[path]] + waitUntil, // same as ctx.waitUntil in existing Worker API + next, // used for middleware or to fetch assets + data // arbitrary space for passing data between middlewares + } = context; + + const client_id = env.GITHUB_CLIENT_ID; + const client_secret = env.GITHUB_CLIENT_SECRET; + + try { + const url = new URL(request.url); + const code = url.searchParams.get('code'); + const response = await fetch('https://github.com/login/oauth/access_token', { + method: 'POST', + headers: { + 'content-type': 'application/json', + 'user-agent': 'cloudflare-functions-github-oauth-login-demo', + accept: 'application/json' + }, + body: JSON.stringify({ client_id, client_secret, code }) + }); + const result = await response.json(); + if (result.error) { + return new Response(renderBody('error', result), { + headers: { + 'content-type': 'text/html;charset=UTF-8' + }, + status: 401 + }); + } + const token = result.access_token; + const provider = 'github'; + const responseBody = renderBody('success', { + token, + provider + }); + return new Response(responseBody, { + headers: { + 'content-type': 'text/html;charset=UTF-8' + }, + status: 200 + }); + } catch (error) { + console.error(error); + return new Response(error.message, { + headers: { + 'content-type': 'text/html;charset=UTF-8' + }, + status: 500 + }); + } +} diff --git a/src/lib/content/boise/about.json b/src/lib/content/boise/about.json index cf9caad..a8c4e97 100644 --- a/src/lib/content/boise/about.json +++ b/src/lib/content/boise/about.json @@ -1,12 +1,6 @@ { - "body": "# About Cowgill\n\n![Group photo on the grass before Thirsty Seconds](/media/replace-me.png \"cornicellophoto\")\n\nCowgill Trail Collective began holding group runs in the spring of 2021. We noticed there wasn’t a trail running-focused group in Seattle, and we wanted to create a platform to connect the trail running community.  We started with a weekly Thursday morning trail run and now have four weekly runs, in addition to camping opportunities with unique routes every weekend.  \n\nWe strive to foster interactions, help runners achieve, increase trail stewardship, make the sport more inclusive and accessible, and put on unique events. Our members do not pay dues, all our events are free and open to the public, and we have a diverse range of runners, from beginner trail runners to professional athletes.", + "body": "# About Cowgill\n\n![Group photo on the grass during a Wyld Half](/media/img_6511.jpeg \"Wyld Half Hydration Stop\")\n\nCowgill Trail Collective began holding group runs in the winter of 2023. We noticed there wasn’t a trail running-focused group in Boise, and we wanted to create a platform to connect the trail running community.  We started with a weekly Thursday evening trail run and now put on a variety of other events throughout the year.\n\nWe strive to foster interactions, help runners achieve, increase trail stewardship, make the sport more inclusive and accessible, and put on unique events. Our members do not pay dues, all our events are free and open to the public, and we have a diverse range of runners, from beginner trail runners to professional athletes.", "metaDescription": "Cowgill brings together trail runners of all levels near Seattle, WA to achieve goals, steward local trails, and make running inclusive and accessible through community events.", - "articles": [ - { - "title": "Territory Run Co.", - "link": "https://territoryrun.co/blogs/news/building-a-trail-community-with-cowgill-trail-collective", - "photo": "/media/replace-me.png" - } - ], + "articles": [], "sponsorships": "## Sponsorships/Partnerships\n\n* [HOKA](https://www.hoka.com/en/us/)\n* [Janji ](https://janji.com/?utm_source=google&utm_medium=cpc&utm_campaign=google-ads-brand-exact&utm_source=google&utm_medium=cpc&gad_source=1&gclid=CjwKCAiA3aeqBhBzEiwAxFiOBnTl9jexk3T6K5lYqBPeA4QNzlN4zrGVHQE2DeEm93vcqWL_jnKDRRoCH_8QAvD_BwE)\n* [Gnarly Nutrition](https://gognarly.com/?utm_source=google&utm_medium=paid&utm_campaign=20679179687&utm_content=&utm_term=&gadid=&gad_source=1&gclid=CjwKCAiA3aeqBhBzEiwAxFiOBt6N0393UV1h_K4Mu8H3f-Kk3xt-9UeiYwALfkN2Jai4yVGwHnzLKhoC0JUQAvD_BwE)\n* [Best Day Brewing](https://bestdaybrewing.com/collections/core-beers?gad_source=1&gclid=CjwKCAiA3aeqBhBzEiwAxFiOBlaJeu7gOm-C6i1z8z497uAVdd6ZEsQCegEHxw9mHPYbNSegObs10RoCjigQAvD_BwE)\n* [Wonderland Running](https://www.wonderlandrunning.com/)" } \ No newline at end of file diff --git a/src/lib/content/boise/contact.json b/src/lib/content/boise/contact.json index 2c8f9ef..3023902 100644 --- a/src/lib/content/boise/contact.json +++ b/src/lib/content/boise/contact.json @@ -1,8 +1,8 @@ { - "body": "Reach out with any questions about the group or for potential collaborations.", - "formTitle": "Contact Cowgill!", - "successMessage": "### Thank you for contacting Cowgill!\n\nWe will get back to you as soon as we are back in service!", - "metaDescription": "Get in touch with Cowgill Trail Collective for questions about membership, upcoming events, and potential partnerships or collaborations.", - "customHeaderPhoto": "/media/replace-me.png", - "customHeaderPhotoAltText": "Runners preparing to run in Rainier National Park" -} + "body": "Reach out with any questions about the group or for potential collaborations. We're fun, upbeat, out-and-about, excellent ambassadors and trail stewards. ", + "formTitle": "Contact Cowgill!", + "successMessage": "### Thank you for contacting Cowgill!\n\nWe will get back to you as soon as we are back in service!", + "metaDescription": "Get in touch with Cowgill Trail Collective for questions about membership, upcoming events, and potential partnerships or collaborations.", + "customHeaderPhoto": "/media/img_8605.jpeg", + "customHeaderPhotoAltText": "Cowgill hat on a trail post in the boise trail system" +} \ No newline at end of file diff --git a/src/lib/content/boise/events.json b/src/lib/content/boise/events.json index 510a39d..c776ccb 100644 --- a/src/lib/content/boise/events.json +++ b/src/lib/content/boise/events.json @@ -1,5 +1,5 @@ { - "body": "**Weekdays** (usual locations)\n\n* **M:** Womxn Run The Herd 6:00pm (Brooks Trailhead)\n* **T:** Graze & Chill- run & potluck 6:00pm- monthly\n* Womxn Run the Herd morning edition (urban trails) 6:30am bi-weekly\n* Tuesday Trail Turn Up 6:30pm women-trans-femme-nonbinary trail run with social (Issaquah)- bi-weekly\n* **W:** Werkout Wednesday 6:30am (Lower Woodland Park track)\n* **Th:** Thirsty Thursday 6:30am trail run (Issaquah)\n* Thirsty Seconds 6:30pm roads with social (North Transfer Station Playground)\n\n**Weekends**\n\n* Smooth Mooves - trail adventures usually with camping- monthly\n* Womxn Run the Herd weekend edition - trail adventures usually with camping - monthly\n* Silky & Filthy - run with folding saws and clear trails\n* Volunteering - aid stations at races - frequently\n\n ![A group of trail runners at the trailhead before a Smooth Mooves group run.](/media/replace-me.png)\n*\n*", + "body": "**Thursdays**\n\nDry Season (May -> Oct)\n* 5:30pm\n* Boise North End\n* We run the Camelsback area\n\nWet Season (Nov -> April)\n* 5:30pm\n* Boise East End\n* We run the military reserve trails\n\nOther ad-hoc events happen throughout the year. Follow us on Strava for up to date stuff.", "metaDescription": "View the weekly schedule of fun running events hosted by Cowgill. Join group runs on Thursdays, workouts on Wednesdays, and longer weekend trail runs.", "title": "Cowgill Events" } \ No newline at end of file diff --git a/src/lib/content/boise/home.json b/src/lib/content/boise/home.json index 773793d..1bf696d 100644 --- a/src/lib/content/boise/home.json +++ b/src/lib/content/boise/home.json @@ -1,6 +1,6 @@ { - "body": "Cowgill Trail Collective is a trail running group based in Boise, Idaho. We host a variety of events both on and off trails, all of which are free and open to the public. Bringing together the trail running community and making the sport more inclusive and accessible is at the core of everything we do. \n\n![Runners before a run in the Teanaways ](/media/replace-me.png \"jonathan.foster\")", - "metaDescription": "Cowgill Trail Collective aims to explore the beautiful Pacific Northwest trails near Seattle, WA. Runners of all experience levels are welcome in our fun, supportive community.", - "headerImage": "/media/replace-me.png", - "headerImageAltText": "Photo of runners on a climb in Olympic National Park" + "body": "Cowgill Trail Collective is a trail running group based in Boise, Idaho. We host a variety of events both on and off trails, all of which are free and open to the public. Bringing together the trail running community and making the sport more inclusive and accessible is at the core of everything we do.\n\n![Runners during camping trip](/media/img_0798.png \"herd camping trip\")", + "metaDescription": "Cowgill Trail Collective aims to explore the beautiful trails in and around Boise. Runners of all experience levels are welcome in our fun, supportive community.", + "headerImage": "/media/img_0799.png", + "headerImageAltText": "Group photo before a run during a camping trip at Bogus. " } \ No newline at end of file diff --git a/src/lib/content/boise/media/cowgill-boise-square-black.png b/src/lib/content/boise/media/cowgill-boise-square-black.png new file mode 100644 index 0000000..ad257ce Binary files /dev/null and b/src/lib/content/boise/media/cowgill-boise-square-black.png differ diff --git a/src/lib/content/boise/media/cowgill_boise_black-copy.png b/src/lib/content/boise/media/cowgill_boise_black-copy.png new file mode 100644 index 0000000..f11eab9 Binary files /dev/null and b/src/lib/content/boise/media/cowgill_boise_black-copy.png differ diff --git a/src/lib/content/boise/media/img_0798.png b/src/lib/content/boise/media/img_0798.png new file mode 100644 index 0000000..5bbebb2 Binary files /dev/null and b/src/lib/content/boise/media/img_0798.png differ diff --git a/src/lib/content/boise/media/img_0799.png b/src/lib/content/boise/media/img_0799.png new file mode 100644 index 0000000..9b1afc8 Binary files /dev/null and b/src/lib/content/boise/media/img_0799.png differ diff --git a/src/lib/content/boise/media/img_1875.jpeg b/src/lib/content/boise/media/img_1875.jpeg new file mode 100644 index 0000000..127b62c Binary files /dev/null and b/src/lib/content/boise/media/img_1875.jpeg differ diff --git a/src/lib/content/boise/media/img_6511.jpeg b/src/lib/content/boise/media/img_6511.jpeg new file mode 100644 index 0000000..a2b0646 Binary files /dev/null and b/src/lib/content/boise/media/img_6511.jpeg differ diff --git a/src/lib/content/boise/media/img_8605.jpeg b/src/lib/content/boise/media/img_8605.jpeg new file mode 100644 index 0000000..6574475 Binary files /dev/null and b/src/lib/content/boise/media/img_8605.jpeg differ diff --git a/src/lib/content/boise/media/replace-me.png b/src/lib/content/boise/media/replace-me.png deleted file mode 100644 index 27fb85e..0000000 Binary files a/src/lib/content/boise/media/replace-me.png and /dev/null differ diff --git a/src/lib/content/boise/meta.json b/src/lib/content/boise/meta.json index f43a7cb..ad631ec 100644 --- a/src/lib/content/boise/meta.json +++ b/src/lib/content/boise/meta.json @@ -1,10 +1,11 @@ { - "headerPhotoAltText": "Runners at the start of a run in the Olympic National Forest", - "instagramHandle": "cowgilltrailcollective", - "stravaLink": "https://www.strava.com/clubs/470714", + "headerPhotoAltText": "Runners at the start of a run in the Boise trail system", + "instagramHandle": "cowgillboise", + "stravaLink": "https://www.strava.com/clubs/1205423", "cityState": "Boise, ID", - "email": "cowgill.trail@gmail.com", - "calendarLink": "https://calendar.google.com/calendar/u/0/embed?src=cowgill.trail@gmail.com&ctz=America/Los_Angeles", - "logo": "/media/replace-me.png", - "headerPhoto": "/media/replace-me.png" + "email": "cowgillboise@gmail.com", + "calendarLink": "https://calendar.google.com/calendar/u/0?cid=ZWY3MjM3OGUyZGYxOWJlYTAzZDRhMzUzMWU0ZDQ4MzEwN2VhYTRiZDg1NTJhZTg0ODljMjBkMzYxOTViOWNkM0Bncm91cC5jYWxlbmRhci5nb29nbGUuY29t", + "calendarSubscribeLink": "https://calendar.google.com/calendar/u/0?cid=ZWY3MjM3OGUyZGYxOWJlYTAzZDRhMzUzMWU0ZDQ4MzEwN2VhYTRiZDg1NTJhZTg0ODljMjBkMzYxOTViOWNkM0Bncm91cC5jYWxlbmRhci5nb29nbGUuY29t", + "logo": "/media/cowgill_boise_black-copy.png", + "headerPhoto": "/media/img_1875.jpeg" } \ No newline at end of file diff --git a/src/lib/content/portland/home.json b/src/lib/content/portland/home.json index 773793d..914ca2c 100644 --- a/src/lib/content/portland/home.json +++ b/src/lib/content/portland/home.json @@ -1,5 +1,5 @@ { - "body": "Cowgill Trail Collective is a trail running group based in Boise, Idaho. We host a variety of events both on and off trails, all of which are free and open to the public. Bringing together the trail running community and making the sport more inclusive and accessible is at the core of everything we do. \n\n![Runners before a run in the Teanaways ](/media/replace-me.png \"jonathan.foster\")", + "body": "**Here is a scaffold of content to get you started. All of the content here is copied from the Seattle site, so edit it and make it your own!**\n\nCowgill Trail Collective is a trail running group based in Portland, Oregon. We host a variety of events both on and off trails, all of which are free and open to the public. Bringing together the trail running community and making the sport more inclusive and accessible is at the core of everything we do. \n\n![Runners before a run in the Teanaways ](/media/replace-me.png \"jonathan.foster\")", "metaDescription": "Cowgill Trail Collective aims to explore the beautiful Pacific Northwest trails near Seattle, WA. Runners of all experience levels are welcome in our fun, supportive community.", "headerImage": "/media/replace-me.png", "headerImageAltText": "Photo of runners on a climb in Olympic National Park" diff --git a/src/lib/content/portland/meta.json b/src/lib/content/portland/meta.json index f43a7cb..7f2ec8c 100644 --- a/src/lib/content/portland/meta.json +++ b/src/lib/content/portland/meta.json @@ -2,9 +2,10 @@ "headerPhotoAltText": "Runners at the start of a run in the Olympic National Forest", "instagramHandle": "cowgilltrailcollective", "stravaLink": "https://www.strava.com/clubs/470714", - "cityState": "Boise, ID", + "cityState": "Portland, OR", "email": "cowgill.trail@gmail.com", "calendarLink": "https://calendar.google.com/calendar/u/0/embed?src=cowgill.trail@gmail.com&ctz=America/Los_Angeles", + "calendarSubscribeLink": "https://calendar.google.com/calendar/u/0?cid=Y293Z2lsbC50cmFpbEBnbWFpbC5jb20", "logo": "/media/replace-me.png", "headerPhoto": "/media/replace-me.png" } \ No newline at end of file diff --git a/src/lib/content/seattle/meta.json b/src/lib/content/seattle/meta.json index 17cba1b..c7036ea 100644 --- a/src/lib/content/seattle/meta.json +++ b/src/lib/content/seattle/meta.json @@ -6,5 +6,6 @@ "cityState": "Seattle, WA", "email": "cowgill.trail@gmail.com", "calendarLink": "https://calendar.google.com/calendar/u/0/embed?src=cowgill.trail@gmail.com&ctz=America/Los_Angeles", + "calendarSubscribeLink": "https://calendar.google.com/calendar/u/0?cid=Y293Z2lsbC50cmFpbEBnbWFpbC5jb20", "logo": "/media/cowgill_white_logo.png" } \ No newline at end of file diff --git a/src/lib/content/template/meta.json b/src/lib/content/template/meta.json index f43a7cb..1e0e126 100644 --- a/src/lib/content/template/meta.json +++ b/src/lib/content/template/meta.json @@ -5,6 +5,7 @@ "cityState": "Boise, ID", "email": "cowgill.trail@gmail.com", "calendarLink": "https://calendar.google.com/calendar/u/0/embed?src=cowgill.trail@gmail.com&ctz=America/Los_Angeles", + "calendarSubscribeLink": "https://calendar.google.com/calendar/u/0?cid=Y293Z2lsbC50cmFpbEBnbWFpbC5jb20", "logo": "/media/replace-me.png", "headerPhoto": "/media/replace-me.png" } \ No newline at end of file diff --git a/src/routes/about/+page.svelte b/src/routes/about/+page.svelte index 36226d7..222463c 100644 --- a/src/routes/about/+page.svelte +++ b/src/routes/about/+page.svelte @@ -12,26 +12,28 @@ -
-
-

Articles

-
-
- {#each aboutData.articles as { link, title, photo }} - - +
+{/if} diff --git a/src/routes/contact/+page.svelte b/src/routes/contact/+page.svelte index 777d431..87f4e62 100644 --- a/src/routes/contact/+page.svelte +++ b/src/routes/contact/+page.svelte @@ -5,6 +5,7 @@ let modal; const contactData = getCMSData('contact'); + const metaData = getCMSData('meta'); const handleSubmit = (event) => { event.preventDefault(); @@ -20,6 +21,8 @@ .then(() => modal.show()) .catch((error) => alert(error)); }; + + const contentKey = import.meta.env.VITE_CONTENT_KEY; @@ -32,51 +35,58 @@
-
-

{contactData.formTitle}

-
- -
+ +{#if contentKey === 'seattle'} +
+

{contactData.formTitle}

+ + +
+
+ + +
+
+ + +
+
- - + +
- - + +