From be31afa846e31fcb3948bba4fd78bbe1da51765f Mon Sep 17 00:00:00 2001 From: Mark Baggett Date: Tue, 5 Dec 2023 09:31:59 -0500 Subject: [PATCH] Initial commit --- .babelrc | 4 + .env | 2 + .eslintrc.json | 28 + .github/ISSUE_TEMPLATE/bug.md | 27 + .github/ISSUE_TEMPLATE/feature-enhancement.md | 14 + .github/pull_request_template.md | 15 + .github/workflows/build.yml | 29 + .github/workflows/gh-pages.deploy.yml | 43 + .gitignore | 41 + .prettierrc.json | 0 .stackblitzrc | 4 + LICENSE | 21 + README.md | 48 + canopy.ts | 32 + config/.default/canopy.default.json | 72 + config/.fixtures/canopy.customize-search.json | 44 + config/.fixtures/canopy.dev-collection.json | 4 + config/.fixtures/canopy.minimal.json | 3 + config/.fixtures/canopy.presentation-2.json | 8 + config/.fixtures/canopy.presentation-3.json | 7 + config/canopy.sample.json | 13 + config/locales/en.json | 12 + config/locales/nb.json | 12 + config/locales/nn.json | 12 + config/locales/no.json | 12 + config/locales/pt.json | 12 + content/404.mdx | 7 + content/_meta.json | 14 + content/about/_meta.json | 10 + content/about/example.mdx | 125 + content/about/index.mdx | 45 + content/index.mdx | 23 + global.d.ts | 2 + jest.config.next.ts | 36 + jest.config.ts | 26 + jest.setup.ts | 13 + next-env.d.ts | 5 + next-sitemap.config.js | 7 + next.config.js | 44 + package-lock.json | 13270 ++++++++++++++++ package.json | 80 + public/fixtures/iiif/collection/examples.json | 173 + public/images/marker-icon.png | Bin 0 -> 1466 bytes src/components/Card/Card.styled.ts | 57 + src/components/Card/Card.test.tsx | 36 + src/components/Card/Card.tsx | 54 + src/components/Facets/Activate.styled.ts | 27 + src/components/Facets/Activate.tsx | 32 + src/components/Facets/Facet.styled.ts | 56 + src/components/Facets/Facet.tsx | 83 + src/components/Facets/Facets.styled.ts | 7 + src/components/Facets/Facets.tsx | 56 + src/components/Facets/Modal.styled.ts | 144 + src/components/Facets/Modal.tsx | 80 + src/components/Facets/Option.styled.ts | 87 + src/components/Facets/Option.tsx | 57 + src/components/Figure/Figure.styled.ts | 32 + src/components/Figure/Figure.tsx | 56 + src/components/Footer/Footer.styled.ts | 32 + src/components/Footer/Footer.tsx | 27 + src/components/Footer/ThemeMode.tsx | 41 + src/components/Grid/Grid.styled.ts | 57 + src/components/Grid/Grid.tsx | 38 + src/components/Grid/Item.tsx | 19 + src/components/Header/Header.styled.tsx | 132 + src/components/Header/Header.tsx | 54 + src/components/Hero/Hero.styled.ts | 122 + src/components/Hero/Hero.tsx | 61 + src/components/Layouts/Basic.tsx | 69 + src/components/MDX/Card.tsx | 34 + src/components/MDX/ReferencedItems.tsx | 24 + src/components/MDX/Slider.tsx | 7 + src/components/MDX/Viewer.tsx | 22 + src/components/MDX/index.tsx | 55 + src/components/Map/Map.styled.tsx | 29 + src/components/Map/Map.tsx | 121 + src/components/Map/MarkerClusterGroup.tsx | 26 + src/components/Nav/Items.tsx | 25 + src/components/Nav/ItemsLink.tsx | 61 + src/components/Nav/Nav.styled.ts | 101 + src/components/Nav/Nav.tsx | 28 + src/components/Related/Related.styled.ts | 7 + src/components/Related/Related.tsx | 24 + src/components/SVG/IIIF.tsx | 48 + src/components/Search/Header.styled.ts | 61 + src/components/Search/Results.tsx | 51 + src/components/Search/Search.styled.ts | 101 + src/components/Search/Search.test.tsx | 47 + src/components/Search/Search.tsx | 56 + src/components/Shared/Button/Button.styled.ts | 78 + src/components/Shared/Button/Button.tsx | 33 + src/components/Shared/Code/Code.styled.ts | 34 + src/components/Shared/Code/Code.tsx | 53 + src/components/Shared/Code/prism-helpers.ts | 26 + src/components/Shared/Container.tsx | 89 + src/components/Shared/Content.styled.ts | 65 + .../Shared/DefinitionList.styled.ts | 19 + .../Shared/Heading/Heading.styled.ts | 60 + src/components/Shared/Heading/Heading.tsx | 26 + src/components/Shared/Locale/Locale.styled.ts | 23 + src/components/Shared/Locale/Locale.tsx | 39 + src/components/Shared/Main.tsx | 12 + src/components/Shared/Markdown/Blockquote.tsx | 19 + src/components/Viewer/Slider.styled.ts | 79 + src/components/Viewer/Slider.tsx | 59 + src/components/Viewer/Viewer.tsx | 64 + src/components/Work/Inner.styled.ts | 42 + src/components/Work/Inner.tsx | 99 + src/components/Work/ManifestId.tsx | 14 + src/components/Work/ReferencingContent.tsx | 50 + src/components/layout.tsx | 17 + src/context/canopy.tsx | 92 + src/context/facets.tsx | 56 + src/context/front-matter.tsx | 14 + src/customTypes/build/index.ts | 19 + src/customTypes/canopy.ts | 89 + src/customTypes/content.ts | 33 + src/customTypes/context/canopy.ts | 10 + src/customTypes/context/facets.ts | 3 + src/customTypes/index.ts | 10 + src/customTypes/navigation.ts | 4 + src/customTypes/search/search.ts | 20 + src/hooks/getLabel.ts | 28 + src/hooks/getResourceImage.ts | 22 + src/hooks/getValues.ts | 21 + src/hooks/sortItems.ts | 45 + src/hooks/useElementPosition.ts | 23 + src/hooks/useLocale.ts | 34 + src/hooks/useNavigation.ts | 56 + src/hooks/usePageResults.ts | 56 + src/lib/build/aggregate.js | 164 + src/lib/build/chunks.js | 44 + src/lib/build/config.test.ts | 44 + src/lib/build/config.ts | 53 + src/lib/build/facets.js | 185 + src/lib/build/log.js | 30 + src/lib/build/request.js | 28 + src/lib/build/search.js | 17 + src/lib/build/shape.js | 38 + src/lib/build/slug.js | 37 + src/lib/build/thumbnail.js | 43 + src/lib/constants/canopy.ts | 18 + src/lib/content/reference/server/index.ts | 58 + src/lib/contentHelpers.ts | 54 + src/lib/facet/facets.ts | 13 + src/lib/iiif/constructors/collection.js | 61 + src/lib/iiif/constructors/related.ts | 18 + src/lib/iiif/context.js | 40 + src/lib/iiif/homepage.js | 13 + src/lib/iiif/image.js | 14 + src/lib/iiif/label.js | 38 + src/lib/iiif/navPlace.ts | 29 + src/lib/option.ts | 5 + src/lib/search/documents.ts | 17 + src/lib/search/request.ts | 52 + src/lib/search/response.ts | 59 + src/lib/search/results.ts | 46 + src/lib/seo.ts | 68 + src/lib/utils.ts | 10 + src/mocks/next-font.ts | 12 + src/pages/404.tsx | 37 + src/pages/_app.tsx | 87 + src/pages/_document.tsx | 34 + src/pages/about/[slug].tsx | 54 + src/pages/about/index.tsx | 40 + src/pages/api/facet/[label]/[value].ts | 39 + src/pages/api/facet/[label]/index.ts | 34 + src/pages/api/info.ts | 38 + src/pages/api/search.ts | 26 + src/pages/index.tsx | 93 + src/pages/map.tsx | 51 + src/pages/metadata.tsx | 77 + src/pages/search.tsx | 94 + src/pages/works/[slug].tsx | 92 + src/pages/works/index.tsx | 8 + src/styles/global.ts | 58 + src/styles/helpers/goldenRatio.ts | 1 + src/styles/stitches.ts | 30 + src/styles/theme/colors.ts | 43 + src/styles/theme/containers.ts | 4 + src/styles/theme/fontSizes.ts | 15 + src/styles/theme/fonts.tsx | 27 + src/styles/theme/index.ts | 14 + src/styles/theme/media.ts | 20 + src/styles/theme/sizes.ts | 18 + src/styles/theme/transitions.ts | 12 + tsconfig.json | 42 + tsconfig.tsbuildinfo | 1 + vitest.config.ts | 25 + vitest.setup.ts | 10 + 190 files changed, 20910 insertions(+) create mode 100644 .babelrc create mode 100644 .env create mode 100644 .eslintrc.json create mode 100644 .github/ISSUE_TEMPLATE/bug.md create mode 100644 .github/ISSUE_TEMPLATE/feature-enhancement.md create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/gh-pages.deploy.yml create mode 100644 .gitignore create mode 100644 .prettierrc.json create mode 100644 .stackblitzrc create mode 100644 LICENSE create mode 100644 README.md create mode 100644 canopy.ts create mode 100644 config/.default/canopy.default.json create mode 100644 config/.fixtures/canopy.customize-search.json create mode 100644 config/.fixtures/canopy.dev-collection.json create mode 100644 config/.fixtures/canopy.minimal.json create mode 100644 config/.fixtures/canopy.presentation-2.json create mode 100644 config/.fixtures/canopy.presentation-3.json create mode 100644 config/canopy.sample.json create mode 100644 config/locales/en.json create mode 100644 config/locales/nb.json create mode 100644 config/locales/nn.json create mode 100644 config/locales/no.json create mode 100644 config/locales/pt.json create mode 100644 content/404.mdx create mode 100644 content/_meta.json create mode 100644 content/about/_meta.json create mode 100644 content/about/example.mdx create mode 100644 content/about/index.mdx create mode 100644 content/index.mdx create mode 100644 global.d.ts create mode 100644 jest.config.next.ts create mode 100644 jest.config.ts create mode 100644 jest.setup.ts create mode 100644 next-env.d.ts create mode 100644 next-sitemap.config.js create mode 100644 next.config.js create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 public/fixtures/iiif/collection/examples.json create mode 100644 public/images/marker-icon.png create mode 100644 src/components/Card/Card.styled.ts create mode 100644 src/components/Card/Card.test.tsx create mode 100644 src/components/Card/Card.tsx create mode 100644 src/components/Facets/Activate.styled.ts create mode 100644 src/components/Facets/Activate.tsx create mode 100644 src/components/Facets/Facet.styled.ts create mode 100644 src/components/Facets/Facet.tsx create mode 100644 src/components/Facets/Facets.styled.ts create mode 100644 src/components/Facets/Facets.tsx create mode 100644 src/components/Facets/Modal.styled.ts create mode 100644 src/components/Facets/Modal.tsx create mode 100644 src/components/Facets/Option.styled.ts create mode 100644 src/components/Facets/Option.tsx create mode 100644 src/components/Figure/Figure.styled.ts create mode 100644 src/components/Figure/Figure.tsx create mode 100644 src/components/Footer/Footer.styled.ts create mode 100644 src/components/Footer/Footer.tsx create mode 100644 src/components/Footer/ThemeMode.tsx create mode 100644 src/components/Grid/Grid.styled.ts create mode 100644 src/components/Grid/Grid.tsx create mode 100644 src/components/Grid/Item.tsx create mode 100644 src/components/Header/Header.styled.tsx create mode 100644 src/components/Header/Header.tsx create mode 100644 src/components/Hero/Hero.styled.ts create mode 100644 src/components/Hero/Hero.tsx create mode 100644 src/components/Layouts/Basic.tsx create mode 100644 src/components/MDX/Card.tsx create mode 100644 src/components/MDX/ReferencedItems.tsx create mode 100644 src/components/MDX/Slider.tsx create mode 100644 src/components/MDX/Viewer.tsx create mode 100644 src/components/MDX/index.tsx create mode 100644 src/components/Map/Map.styled.tsx create mode 100644 src/components/Map/Map.tsx create mode 100644 src/components/Map/MarkerClusterGroup.tsx create mode 100644 src/components/Nav/Items.tsx create mode 100644 src/components/Nav/ItemsLink.tsx create mode 100644 src/components/Nav/Nav.styled.ts create mode 100644 src/components/Nav/Nav.tsx create mode 100644 src/components/Related/Related.styled.ts create mode 100644 src/components/Related/Related.tsx create mode 100644 src/components/SVG/IIIF.tsx create mode 100644 src/components/Search/Header.styled.ts create mode 100644 src/components/Search/Results.tsx create mode 100644 src/components/Search/Search.styled.ts create mode 100644 src/components/Search/Search.test.tsx create mode 100644 src/components/Search/Search.tsx create mode 100644 src/components/Shared/Button/Button.styled.ts create mode 100644 src/components/Shared/Button/Button.tsx create mode 100644 src/components/Shared/Code/Code.styled.ts create mode 100644 src/components/Shared/Code/Code.tsx create mode 100644 src/components/Shared/Code/prism-helpers.ts create mode 100644 src/components/Shared/Container.tsx create mode 100644 src/components/Shared/Content.styled.ts create mode 100644 src/components/Shared/DefinitionList.styled.ts create mode 100644 src/components/Shared/Heading/Heading.styled.ts create mode 100644 src/components/Shared/Heading/Heading.tsx create mode 100644 src/components/Shared/Locale/Locale.styled.ts create mode 100644 src/components/Shared/Locale/Locale.tsx create mode 100644 src/components/Shared/Main.tsx create mode 100644 src/components/Shared/Markdown/Blockquote.tsx create mode 100644 src/components/Viewer/Slider.styled.ts create mode 100644 src/components/Viewer/Slider.tsx create mode 100644 src/components/Viewer/Viewer.tsx create mode 100644 src/components/Work/Inner.styled.ts create mode 100644 src/components/Work/Inner.tsx create mode 100644 src/components/Work/ManifestId.tsx create mode 100644 src/components/Work/ReferencingContent.tsx create mode 100644 src/components/layout.tsx create mode 100644 src/context/canopy.tsx create mode 100644 src/context/facets.tsx create mode 100644 src/context/front-matter.tsx create mode 100644 src/customTypes/build/index.ts create mode 100644 src/customTypes/canopy.ts create mode 100644 src/customTypes/content.ts create mode 100644 src/customTypes/context/canopy.ts create mode 100644 src/customTypes/context/facets.ts create mode 100644 src/customTypes/index.ts create mode 100644 src/customTypes/navigation.ts create mode 100644 src/customTypes/search/search.ts create mode 100644 src/hooks/getLabel.ts create mode 100644 src/hooks/getResourceImage.ts create mode 100644 src/hooks/getValues.ts create mode 100644 src/hooks/sortItems.ts create mode 100644 src/hooks/useElementPosition.ts create mode 100644 src/hooks/useLocale.ts create mode 100644 src/hooks/useNavigation.ts create mode 100644 src/hooks/usePageResults.ts create mode 100644 src/lib/build/aggregate.js create mode 100644 src/lib/build/chunks.js create mode 100644 src/lib/build/config.test.ts create mode 100644 src/lib/build/config.ts create mode 100644 src/lib/build/facets.js create mode 100644 src/lib/build/log.js create mode 100644 src/lib/build/request.js create mode 100644 src/lib/build/search.js create mode 100644 src/lib/build/shape.js create mode 100644 src/lib/build/slug.js create mode 100644 src/lib/build/thumbnail.js create mode 100644 src/lib/constants/canopy.ts create mode 100644 src/lib/content/reference/server/index.ts create mode 100644 src/lib/contentHelpers.ts create mode 100644 src/lib/facet/facets.ts create mode 100644 src/lib/iiif/constructors/collection.js create mode 100644 src/lib/iiif/constructors/related.ts create mode 100644 src/lib/iiif/context.js create mode 100644 src/lib/iiif/homepage.js create mode 100644 src/lib/iiif/image.js create mode 100644 src/lib/iiif/label.js create mode 100644 src/lib/iiif/navPlace.ts create mode 100644 src/lib/option.ts create mode 100644 src/lib/search/documents.ts create mode 100644 src/lib/search/request.ts create mode 100644 src/lib/search/response.ts create mode 100644 src/lib/search/results.ts create mode 100644 src/lib/seo.ts create mode 100644 src/lib/utils.ts create mode 100644 src/mocks/next-font.ts create mode 100644 src/pages/404.tsx create mode 100644 src/pages/_app.tsx create mode 100644 src/pages/_document.tsx create mode 100644 src/pages/about/[slug].tsx create mode 100644 src/pages/about/index.tsx create mode 100644 src/pages/api/facet/[label]/[value].ts create mode 100644 src/pages/api/facet/[label]/index.ts create mode 100644 src/pages/api/info.ts create mode 100644 src/pages/api/search.ts create mode 100644 src/pages/index.tsx create mode 100644 src/pages/map.tsx create mode 100644 src/pages/metadata.tsx create mode 100644 src/pages/search.tsx create mode 100644 src/pages/works/[slug].tsx create mode 100644 src/pages/works/index.tsx create mode 100644 src/styles/global.ts create mode 100644 src/styles/helpers/goldenRatio.ts create mode 100644 src/styles/stitches.ts create mode 100644 src/styles/theme/colors.ts create mode 100644 src/styles/theme/containers.ts create mode 100644 src/styles/theme/fontSizes.ts create mode 100644 src/styles/theme/fonts.tsx create mode 100644 src/styles/theme/index.ts create mode 100644 src/styles/theme/media.ts create mode 100644 src/styles/theme/sizes.ts create mode 100644 src/styles/theme/transitions.ts create mode 100644 tsconfig.json create mode 100644 tsconfig.tsbuildinfo create mode 100644 vitest.config.ts create mode 100644 vitest.setup.ts diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..ae36a5e --- /dev/null +++ b/.babelrc @@ -0,0 +1,4 @@ +{ + "presets": ["next/babel", "@babel/preset-typescript"], + "plugins": [] +} diff --git a/.env b/.env new file mode 100644 index 0000000..b4ae148 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +NEXT_PUBLIC_URL="https://canopy-iiif.github.io" +NEXT_PUBLIC_BASE_PATH="/canopy-iiif" \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..04e763f --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,28 @@ +{ + "plugins": ["@typescript-eslint", "testing-library"], + "extends": [ + "plugin:@typescript-eslint/recommended", + "next", + "next/core-web-vitals", + "prettier" + ], + "overrides": [ + // Only uses Testing Library lint rules in test files + { + "files": [ + "**/__tests__/**/*.[jt]s?(x)", + "**/?(*.)+(spec|test).[jt]s?(x)" + ], + "extends": ["plugin:testing-library/react"] + } + ], + "rules": { + // "sort-keys": "error", + // "sort-imports": "error", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-unused-vars": "error", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/sort-type-union-intersection-members": "error", + "@typescript-eslint/ban-ts-comment": "off" + } +} diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000..4ac104c --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,27 @@ +--- +name: Bug +about: Report an issue +title: '' +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature-enhancement.md b/.github/ISSUE_TEMPLATE/feature-enhancement.md new file mode 100644 index 0000000..c57d228 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-enhancement.md @@ -0,0 +1,14 @@ +--- +name: Feature/Enhancement +about: New feature or enhancement +title: '' +labels: enhancement +assignees: '' + +--- + +## Description + +## Done Looks Like +- [ ] to do 1 +- [ ] to do 2 diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..90442f6 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,15 @@ +# What does this do? + +_Please include a summary of the changes and the related issue. Please also include relevant motivation and context._ + +## What type of change is this? + +- [ ] 🐛 **Bug fix** (non-breaking change addressing an issue) +- [ ] ✨ **New feature or enhancement** (non-breaking change which adds functionality) +- [ ] 🧨 **Breaking change** (fix or feature that would cause existing functionality to not work as expected) +- [ ] 🚧 **Maintenance or refinement of codebase structur**e (ex: dependency updates) +- [ ] 📘 **Documentation update** + +## Additional Notes + +_Please include any extra notes here._ diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..62c0b86 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,29 @@ +name: Test IIIF Collection Build +on: push +jobs: + test-build: + runs-on: ubuntu-latest + # Only run if the repository is canopy-iiif/canopy-iiif + if: github.repository == 'canopy-iiif/canopy-iiif' + steps: + - uses: actions/checkout@v2 + - name: Install dependencies + run: npm install + - name: Unit testing + run: npm run test:ci + - name: 2.x Collection (Aggregation) + run: npm run prebuild -- --path=./config/.fixtures/canopy.presentation-2.json + - name: 2.x Collection (Build) + run: npm run test-build + - name: 3.0 Collection (Aggregation) + run: npm run prebuild -- --path=./config/.fixtures/canopy.presentation-3.json + - name: 3.0 Collection (Build) + run: npm run test-build + - name: Customize Search (Aggregation) + run: npm run prebuild -- --path=./config/.fixtures/canopy.customize-search.json + - name: Customize Search (Build) + run: npm run test-build + - name: Minimal Configuration (Aggregation) + run: npm run prebuild -- --path=./config/.fixtures/canopy.minimal.json + - name: Minimal Configuration (Build) + run: npm run test-build diff --git a/.github/workflows/gh-pages.deploy.yml b/.github/workflows/gh-pages.deploy.yml new file mode 100644 index 0000000..ccf8a78 --- /dev/null +++ b/.github/workflows/gh-pages.deploy.yml @@ -0,0 +1,43 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18.x] + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Load NEXT_PUBLIC_URL and NEXT_PUBLIC_BASE_PATH from .env + run: | + set -o allexport + source .env + set +o allexport + + - name: Install + run: npm ci + + - name: Build + run: npm run build:static + + - name: Bypass Jekyll + run: touch ./out/.nojekyll + + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + branch: gh-pages + folder: out diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7205ab1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel + +.canopy +.vscode + +public/api +public/robots.txt +public/sitemap* \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..e69de29 diff --git a/.stackblitzrc b/.stackblitzrc new file mode 100644 index 0000000..d98146f --- /dev/null +++ b/.stackblitzrc @@ -0,0 +1,4 @@ +{ + "installDependencies": true, + "startCommand": "npm run dev" +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aaeadbc --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 Mat Jordan + +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..f587fd6 --- /dev/null +++ b/README.md @@ -0,0 +1,48 @@ +# Canopy IIIF + +A purely IIIF sourced static site generator using Next.js. Canopy is an application that will build a browseable and searchable digital collections style static site entirely from a IIIF Collection and the items it contains. + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/fork/github/canopy-iiif/canopy-iiif) + +- [Demo (Static)](https://canopy-iiif.github.io/canopy-iiif/) +- [Demo (Vercel)](https://canopy-iiif.vercel.app/) +- [Documentation](https://canopy-iiif.github.io/docs/) + +## Setup + +### Install Dependencies + +```shell +# installation +npm i +``` + +### Running in Development + +```shell +# development +npm run dev +``` + +### Building in Production + +```shell +# build +npm run build +``` + +## Tests + +To run Jest unit tests: + +```shell +npm run test +``` + +## Configuration + +Canopy IIIF uses a default configuration `config/.default/canopy.default.json` for demonstration purposes if a custom one is not set. The build process will read from a custom configuration file at `config/canopy.json` if it exists. See the [Create a Canopy Project guide](https://canopy-iiif.github.io/docs/get-started) for detailed step-by-step instructions. + +## License + +This project is [licensed](https://github.com/canopy-iiif/canopy-iiif/blob/main/LICENSE) under the MIT License. diff --git a/canopy.ts b/canopy.ts new file mode 100644 index 0000000..48da09d --- /dev/null +++ b/canopy.ts @@ -0,0 +1,32 @@ +require("dotenv").config(); +const buildConfig = require("./src/lib/build/config"); +const aggregate = require("./src/lib/build/aggregate"); + +const args = process.argv; + +(() => { + const path = args + .find((value) => value.includes("--path=")) + ?.split("=") + ?.pop(); + + const isDev = args.includes("dev"); + const config = buildConfig.getConfig(path, isDev); + + const url = isDev ? `http://localhost:5001` : process.env.NEXT_PUBLIC_URL; + const basePath = isDev ? `` : process.env.NEXT_PUBLIC_BASE_PATH; + const baseUrl = basePath ? `${url}${basePath}` : url; + const assetPrefix = basePath; + + const env = { + CANOPY_CONFIG: { + ...config, + url, + assetPrefix, + basePath, + baseUrl, + }, + }; + + aggregate.build(env.CANOPY_CONFIG); +})(); diff --git a/config/.default/canopy.default.json b/config/.default/canopy.default.json new file mode 100644 index 0000000..b182c31 --- /dev/null +++ b/config/.default/canopy.default.json @@ -0,0 +1,72 @@ +{ + "collection": "https://api.dc.library.northwestern.edu/api/v2/search?query=%22nez%20perce%22&as=iiif&size=125", + "metadata": ["Subject", "Date", "Dimensions"], + "featured": [ + "https://api.dc.library.northwestern.edu/api/v2/works/cd5e1b9c-370b-40e5-b3d9-defc1d8e0777?as=iiif", + "https://api.dc.library.northwestern.edu/api/v2/works/14a6aa15-9e12-47a7-9617-91f430d4f47b?as=iiif" + ], + "locales": [ + { + "config": "locales/en.json", + "label": "English", + "lang": "en" + } + ], + "map": { + "defaultBounds": [[51.505, -0.09]], + "enabled": false, + "icon": { + "iconUrl": "images/marker-icon.png", + "iconSize": [24, 36], + "iconAnchor": [12, 36] + }, + "tileLayers": [ + { + "name": "OpenStreetMap", + "url": "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", + "attribution": "© OpenStreetMap contributors" + } + ] + }, + "search": { + "enabled": true, + "flexSearch": { + "charset": "latin:extra", + "optimize": true, + "tokenize": "strict", + "bidirectional": false, + "document": { + "index": [ + { + "field": "label", + "tokenize": "full", + "resolution": 9, + "depth": 3, + "bidirectional": true + }, + { + "field": "metadata", + "resolution": 2 + }, + { + "field": "summary", + "resolution": 1 + } + ] + } + }, + "index": { + "metadata": { + "enabled": true, + "all": false + }, + "summary": { + "enabled": false + } + } + }, + "theme": { + "defaultTheme": "light", + "toggleEnabled": false + } +} diff --git a/config/.fixtures/canopy.customize-search.json b/config/.fixtures/canopy.customize-search.json new file mode 100644 index 0000000..d24d535 --- /dev/null +++ b/config/.fixtures/canopy.customize-search.json @@ -0,0 +1,44 @@ +{ + "collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif", + "featured": [ + "https://api.dc.library.northwestern.edu/api/v2/works/2de0355c-8e48-4478-93af-8cbd1437bd16?as=iiif" + ], + "metadata": ["Date", "Subject"], + "search": { + "enabled": true, + "flexSearch": { + "charset": ["latin:extra"], + "optimize": true, + "tokenize": "strict", + "bidirectional": false, + "document": { + "index": [ + { + "field": "label", + "tokenize": "full", + "resolution": 9, + "depth": 3, + "bidirectional": true + }, + { + "field": "metadata", + "resolution": 2 + }, + { + "field": "summary", + "resolution": 1 + } + ] + } + }, + "index": { + "metadata": { + "enabled": true, + "all": true + }, + "summary": { + "enabled": true + } + } + } +} diff --git a/config/.fixtures/canopy.dev-collection.json b/config/.fixtures/canopy.dev-collection.json new file mode 100644 index 0000000..1ee1559 --- /dev/null +++ b/config/.fixtures/canopy.dev-collection.json @@ -0,0 +1,4 @@ +{ + "collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif", + "devCollection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif&size=5" +} diff --git a/config/.fixtures/canopy.minimal.json b/config/.fixtures/canopy.minimal.json new file mode 100644 index 0000000..f59689e --- /dev/null +++ b/config/.fixtures/canopy.minimal.json @@ -0,0 +1,3 @@ +{ + "collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif" +} diff --git a/config/.fixtures/canopy.presentation-2.json b/config/.fixtures/canopy.presentation-2.json new file mode 100644 index 0000000..0c515f4 --- /dev/null +++ b/config/.fixtures/canopy.presentation-2.json @@ -0,0 +1,8 @@ +{ + "collection": "https://iiif.bodleian.ox.ac.uk/iiif/collection/hobhouse", + "featured": [ + "https://iiif.bodleian.ox.ac.uk/iiif/manifest/8da97e8c-4e12-457d-aad8-3327b3aec183.json", + "https://iiif.bodleian.ox.ac.uk/iiif/manifest/2968d5c7-3718-44ef-92ea-ee4cc58cc677.json" + ], + "metadata": ["Extent", "Date Statement"] +} diff --git a/config/.fixtures/canopy.presentation-3.json b/config/.fixtures/canopy.presentation-3.json new file mode 100644 index 0000000..4a0e825 --- /dev/null +++ b/config/.fixtures/canopy.presentation-3.json @@ -0,0 +1,7 @@ +{ + "collection": "https://api.dc.library.northwestern.edu/api/v2/collections/c373ecd2-2c45-45f2-9f9e-52dc244870bd?as=iiif", + "featured": [ + "https://api.dc.library.northwestern.edu/api/v2/works/2de0355c-8e48-4478-93af-8cbd1437bd16?as=iiif" + ], + "metadata": ["Date", "Subject", "Genre", "Dimensions"] +} diff --git a/config/canopy.sample.json b/config/canopy.sample.json new file mode 100644 index 0000000..1b514b6 --- /dev/null +++ b/config/canopy.sample.json @@ -0,0 +1,13 @@ +{ + "collection": "https://example.org/iiif/collection.json", + "devCollection": "https://example.org/iiif/collection-small-sample.json", + "featured": [ + "https://example.org/manifest-1.json", + "https://example.org/manifest-2.json" + ], + "metadata": ["Date", "Subject"], + "label": { "none": ["Collection Title"] }, + "summary": { + "none": ["Brief description of the site and its contents."] + } +} diff --git a/config/locales/en.json b/config/locales/en.json new file mode 100644 index 0000000..154f93c --- /dev/null +++ b/config/locales/en.json @@ -0,0 +1,12 @@ +{ + "footerSourceCollection": "Source Collection", + "footerToggleTheme": "Toggle Theme", + "homepageHighlightedWorks": "Highlighted Works", + "searchButton": "Search", + "searchResults": "Results", + "searchFilter": "Filter", + "searchFilterAny": "Any", + "searchFilterClear": "Clear All", + "searchFilterClose": "Close", + "searchFilterSubmit": "View Results" +} diff --git a/config/locales/nb.json b/config/locales/nb.json new file mode 100644 index 0000000..c11bc93 --- /dev/null +++ b/config/locales/nb.json @@ -0,0 +1,12 @@ +{ + "footerSourceCollection": "Kildesamling", + "footerToggleTheme": "Skift tema", + "homepageHighlightedWorks": "Fremhevete verk", + "searchButton": "Søk", + "searchResults": "resultat", + "searchFilter": "Filter", + "searchFilterAny": "Alle", + "searchFilterClear": "Fjern filter", + "searchFilterClose": "Lukk", + "searchFilterSubmit": "Se treff" +} \ No newline at end of file diff --git a/config/locales/nn.json b/config/locales/nn.json new file mode 100644 index 0000000..9ed88ee --- /dev/null +++ b/config/locales/nn.json @@ -0,0 +1,12 @@ +{ + "footerSourceCollection": "Kjeldesamling", + "footerToggleTheme": "Endre tema", + "homepageHighlightedWorks": "Framheva verk", + "searchButton": "Søk", + "searchResults": "resultat", + "searchFilter": "Filter", + "searchFilterAny": "Alle", + "searchFilterClear": "Fjern filter", + "searchFilterClose": "Lukk", + "searchFilterSubmit": "Sjå treffa" +} \ No newline at end of file diff --git a/config/locales/no.json b/config/locales/no.json new file mode 100644 index 0000000..c11bc93 --- /dev/null +++ b/config/locales/no.json @@ -0,0 +1,12 @@ +{ + "footerSourceCollection": "Kildesamling", + "footerToggleTheme": "Skift tema", + "homepageHighlightedWorks": "Fremhevete verk", + "searchButton": "Søk", + "searchResults": "resultat", + "searchFilter": "Filter", + "searchFilterAny": "Alle", + "searchFilterClear": "Fjern filter", + "searchFilterClose": "Lukk", + "searchFilterSubmit": "Se treff" +} \ No newline at end of file diff --git a/config/locales/pt.json b/config/locales/pt.json new file mode 100644 index 0000000..06c2e2d --- /dev/null +++ b/config/locales/pt.json @@ -0,0 +1,12 @@ +{ + "footerSourceCollection": "Coleção principal", + "footerToggleTheme": "Trocar tema", + "homepageHighlightedWorks": "Destaques", + "searchButton": "Buscar", + "searchResults": "Resultados", + "searchFilter": "Filtrar", + "searchFilterAny": "Todos", + "searchFilterClear": "Limpar tudo", + "searchFilterClose": "Fechar", + "searchFilterSubmit": "Ver resultados" +} diff --git a/content/404.mdx b/content/404.mdx new file mode 100644 index 0000000..5faa927 --- /dev/null +++ b/content/404.mdx @@ -0,0 +1,7 @@ +--- +title: 404 - Page Not Found +--- + +# Page Not Found + +404 Error diff --git a/content/_meta.json b/content/_meta.json new file mode 100644 index 0000000..204a6d3 --- /dev/null +++ b/content/_meta.json @@ -0,0 +1,14 @@ +[ + { + "path": "/works", + "text": "Works" + }, + { + "path": "/metadata", + "text": "Metadata" + }, + { + "path": "/about", + "text": "About" + } +] diff --git a/content/about/_meta.json b/content/about/_meta.json new file mode 100644 index 0000000..6ac4b83 --- /dev/null +++ b/content/about/_meta.json @@ -0,0 +1,10 @@ +[ + { + "path": "/about", + "text": "About" + }, + { + "path": "/about/example", + "text": "Markdown Example" + } +] diff --git a/content/about/example.mdx b/content/about/example.mdx new file mode 100644 index 0000000..8e56e49 --- /dev/null +++ b/content/about/example.mdx @@ -0,0 +1,125 @@ +--- +title: "Markdown Example" +navigation: "about" +referencedManifests: + - "https://api.dc.library.northwestern.edu/api/v2/works/84aec8c1-42e8-4e2c-a6b2-1c7e3790217f?as=iiif" + - "https://api.dc.library.northwestern.edu/api/v2/works/cd5e1b9c-370b-40e5-b3d9-defc1d8e0777?as=iiif" + - "https://api.dc.library.northwestern.edu/api/v2/works/15871197-1616-4c37-9257-b0ad0dc5ab30?as=iiif" + - "https://api.dc.library.northwestern.edu/api/v2/works/14a6aa15-9e12-47a7-9617-91f430d4f47b?as=iiif" +--- + +# Markdown Example + +Canopy IIIF is designed to work with Markdown using the [MDX](https://mdxjs.com/) library. This allows you to use Canopy defined components in our Markdown content to easily extend IIIF resources. +This example page demonstrates some of components that are available for use reuse and remixing content in Markdown. + +This page is output from the `/content/about/example.mdx` file. + + + + + + + {navigation &&