From 0bf3dd819df52046f3f673e63aa9e1735bebf6aa Mon Sep 17 00:00:00 2001 From: Diego Ripley Date: Mon, 23 Jun 2025 08:54:14 -0400 Subject: [PATCH] Initial commit --- .devcontainer/devcontainer.json | 23 +++++++++++ .gitignore | 6 +++ LICENSE | 21 ++++++++++ README.md | 29 ++++++++++++++ content/_index.md | 6 +++ content/blog/_index.md | 10 +++++ content/contact/_index.md | 7 ++++ go.mod | 5 +++ go.sum | 2 + hugo.yaml | 71 +++++++++++++++++++++++++++++++++ static/site.webmanifest | 20 ++++++++++ worker/package-lock.json | 30 ++++++++++++++ worker/package.json | 5 +++ worker/pnpm-lock.yaml | 30 ++++++++++++++ worker/src/index.js | 7 ++++ worker/wrangler.toml | 62 ++++++++++++++++++++++++++++ 16 files changed, 334 insertions(+) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 README.md create mode 100644 content/_index.md create mode 100644 content/blog/_index.md create mode 100644 content/contact/_index.md create mode 100644 go.mod create mode 100644 go.sum create mode 100644 hugo.yaml create mode 100644 static/site.webmanifest create mode 100644 worker/package-lock.json create mode 100644 worker/package.json create mode 100644 worker/pnpm-lock.yaml create mode 100644 worker/src/index.js create mode 100644 worker/wrangler.toml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..365c079 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,23 @@ +{ + "image": "mcr.microsoft.com/devcontainers/go:1", + "features": { + "ghcr.io/devcontainers/features/hugo:1": { + "extended": true, + "version": "0.147.7" + }, + "ghcr.io/devcontainers/features/node:1": {} + }, + "customizations": { + "vscode": { + "extensions": [ + "mhutchie.git-graph", + "esbenp.prettier-vscode", + "tamasfe.even-better-toml", + "budparr.language-hugo-vscode" + ] + } + }, + "forwardPorts": [ + 1313 + ] +} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..791ac6b --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +# Hugo output +public/ +resources/ +.hugo_build.lock +# Worker +node_modules/ \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5fc675f --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Data for Canada + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e0a6da2 --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ +## Table of Contents +- [About](#about) +- [How to Run Locally](#how-to-run-locally) +- [License](#license) + +## About +[![Deploy Hugo site to R2](https://github.com/dataforcanada/www.dataforcanada.org/actions/workflows/deploy_website.yaml/badge.svg)](https://github.com/dataforcanada/www.dataforcanada.org/actions/workflows/deploy_website.yaml) +[![Deploy Worker](https://github.com/dataforcanada/www.dataforcanada.org/actions/workflows/deploy_worker.yaml/badge.svg)](https://github.com/dataforcanada/www.dataforcanada.org/actions/workflows/deploy_worker.yaml) + +This repo has the code for my personal website, [www.dataforcanada.org](https://www.dataforcanada.org). The website is generated as a static website with Hugo and is served via a Cloudflare worker that reads a Cloudflare R2 bucket. + +## How to Run Locally + +```shell +# Clone the repository +git clone git@github.com:dataforcanada/www.dataforcanada.org.git + +# Navigate to the project directory +cd www.dataforcanada.org + +# In Dev Container +hugo server --logLevel debug --disableFastRender -p 1313 +``` + +## License + +My website and code are distributed under an MIT license. + +[Back to top](#top) \ No newline at end of file diff --git a/content/_index.md b/content/_index.md new file mode 100644 index 0000000..cd6a354 --- /dev/null +++ b/content/_index.md @@ -0,0 +1,6 @@ +--- +title: Welcome to Data for Canada +toc: false +--- + +Datasets diff --git a/content/blog/_index.md b/content/blog/_index.md new file mode 100644 index 0000000..05448ab --- /dev/null +++ b/content/blog/_index.md @@ -0,0 +1,10 @@ +--- +title: "Blog" +--- + +
+{{< hextra/hero-badge link="index.xml" >}} + RSS Feed + {{< icon name="rss" attributes="height=14" >}} +{{< /hextra/hero-badge >}} +
\ No newline at end of file diff --git a/content/contact/_index.md b/content/contact/_index.md new file mode 100644 index 0000000..22b284d --- /dev/null +++ b/content/contact/_index.md @@ -0,0 +1,7 @@ +--- +title: Contact +toc: false +comments: false +--- + +Feel free to get in touch with us at info@dataforcanada.org \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..672362a --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module github.com/imfing/hextra-starter-template + +go 1.21 + +require github.com/imfing/hextra v0.9.7 // indirect diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..8501da6 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/imfing/hextra v0.9.7 h1:Zg5n24us36Bn/S/5mEUPkRW6uwE6vHHEqWSgN0bPXaM= +github.com/imfing/hextra v0.9.7/go.mod h1:cEfel3lU/bSx7lTE/+uuR4GJaphyOyiwNR3PTqFTXpI= diff --git a/hugo.yaml b/hugo.yaml new file mode 100644 index 0000000..2c9f4b4 --- /dev/null +++ b/hugo.yaml @@ -0,0 +1,71 @@ +# Hugo configuration file +title: Data for Canada + +# import hextra as module +module: + imports: + - path: github.com/imfing/hextra + +markup: + # allow raw html + goldmark: + renderer: + unsafe: true + + # enable hextra syntax highlight + highlight: + noClasses: false + +# Do not inject generator meta tag on homepage +disableHugoGeneratorInject: true + +# Parse Git commit +enableGitInfo: true + +enableInlineShortcodes: true +enableEmoji: true + +menu: + main: + - name: Blog + url: /blog/ + weight: 1 + - name: Contact + url: /contact/ + weight: 2 + - name: Search + weight: 3 + params: + type: search + - name: GitHub + weight: 4 + url: "https://github.com/dataforcanada" + params: + icon: github + +params: + navbar: + displayTitle: true + displayLogo: true + + page: + # full (100%), wide (90rem), normal (1280px) + width: wide + + footer: + displayCopyright: True + displayPoweredBy: True + + comments: + enable: true + type: giscus + + giscus: + repo: dataforcanada/www.dataforcanada.org + repoId: R_kgDOPAaEeA + category: General + categoryId: DIC_kwDOPAaEeM4Cr4dH + + editURL: + enable: true + base: "https://github.com/dataforcanada/www.dataforcanada.org/edit/main/content" \ No newline at end of file diff --git a/static/site.webmanifest b/static/site.webmanifest new file mode 100644 index 0000000..7b5700e --- /dev/null +++ b/static/site.webmanifest @@ -0,0 +1,20 @@ +{ + "name": "Data for Canada Website", + "short_name": "Data for Canada", + "start_url": "index.html", + "icons": [ + { + "src": "android-chrome-192x192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "android-chrome-512x512.png", + "sizes": "512x512", + "type": "image/png" + } + ], + "theme_color": "#000000", + "background_color": "#000000", + "display": "standalone" +} diff --git a/worker/package-lock.json b/worker/package-lock.json new file mode 100644 index 0000000..1fc7b5a --- /dev/null +++ b/worker/package-lock.json @@ -0,0 +1,30 @@ +{ + "name": "worker", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "render2": "^1.5.0" + } + }, + "node_modules/range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/render2": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/render2/-/render2-1.5.0.tgz", + "integrity": "sha512-q60V+O193o4bevaWgMHoN9II5BsH4purEemu+NJnx0bBZ3x4Hxfkq9t0puOKemRnOhYhwc39HPVLaKgmAehFBQ==", + "license": "MIT", + "dependencies": { + "range-parser": "^1.2.1" + } + } + } +} diff --git a/worker/package.json b/worker/package.json new file mode 100644 index 0000000..d697bf9 --- /dev/null +++ b/worker/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "render2": "^1.5.0" + } +} diff --git a/worker/pnpm-lock.yaml b/worker/pnpm-lock.yaml new file mode 100644 index 0000000..ad1012b --- /dev/null +++ b/worker/pnpm-lock.yaml @@ -0,0 +1,30 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + render2: + specifier: ^1.5.0 + version: 1.5.0 + +packages: + + range-parser@1.2.1: + resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==} + engines: {node: '>= 0.6'} + + render2@1.5.0: + resolution: {integrity: sha512-q60V+O193o4bevaWgMHoN9II5BsH4purEemu+NJnx0bBZ3x4Hxfkq9t0puOKemRnOhYhwc39HPVLaKgmAehFBQ==} + +snapshots: + + range-parser@1.2.1: {} + + render2@1.5.0: + dependencies: + range-parser: 1.2.1 diff --git a/worker/src/index.js b/worker/src/index.js new file mode 100644 index 0000000..ee76766 --- /dev/null +++ b/worker/src/index.js @@ -0,0 +1,7 @@ +import render from 'render2' + +export default { + async fetch(request, env, ctx) { + return render.fetch(request, env, ctx) + } +} \ No newline at end of file diff --git a/worker/wrangler.toml b/worker/wrangler.toml new file mode 100644 index 0000000..b49cfff --- /dev/null +++ b/worker/wrangler.toml @@ -0,0 +1,62 @@ +name = "dataforcanada-website" +main = "src/index.js" +compatibility_date = "2022-05-15" +# Set this to false if you don't want to use the default *.workers.dev route. +# Note that *.workers.dev routes don't support native worker-level caching: https://developers.cloudflare.com/workers/runtime-apis/cache/ +workers_dev = true +routes = [ + { pattern = "www.dataforcanada.org", custom_domain = true } +] + +[vars] +# The `access-control-allow-origin` header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Allow-Origin +# Optional, the `access-control-allow-origin` header is omitted if unset, which blocks all cross-origin requests. +ALLOWED_ORIGINS = "https://www.dataforcanada.org" + +# The `cache-control` header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control. +# Optional, the `cache-control` header is omitted if unset, which would NOT disable caching: https://developers.cloudflare.com/workers/runtime-apis/cache/#headers +# For example, you can disable all cache by setting this to `no-store`. +CACHE_CONTROL = "max-age=86400, public" + +# The string to prepend to each file path. Optional, nothing is prepended to the path if unset. +PATH_PREFIX = "" + +# Index file to search for on directory requests, set to "" to disable indexes +# Relative to the directory of the request. +#INDEX_FILE = "" +INDEX_FILE = "index.html" + +# File to fall back to when the requested path is not found in the bucket. +# Incurs an additional read operation for 404 requests. +# Set to "" to disable custom 404 fallbacks. +# Relative to the root of the bucket. +NOTFOUND_FILE = "404.html" + +# Enable to show a directory listing fallback on paths ending in / +# If INDEX_FILE is also provided, it will be used instead if the file exists. +DIRECTORY_LISTING = true + +# The number of items to show per page in directory listings. +# Listings may also return less if the listing API call reaches a size limit. +# Maximum of 1000. +ITEMS_PER_PAGE = 1000 + +# Enable to hide files or directories beginning with . from directory listings. +HIDE_HIDDEN_FILES = false + +# Set a cache header here, e.g. "max-age=86400", if you want to cache directory listings. +DIRECTORY_CACHE_CONTROL = "max-age=86400, public" + +# Set debugging log enabled. +LOGGING = false + +# Set the number of retries allowed for each R2 operation (-1 for unlimited). +R2_RETRIES = 0 + +[observability] +enabled = false + +[[r2_buckets]] +binding = "R2_BUCKET" +bucket_name = "dataforcanada-www" # Set this to your R2 bucket name. Required +preview_bucket_name = "dataforcanada-www" # Set this to your preview R2 bucket name. Can be equal to bucket_name. Optional