[
  {
    "path": ".github/workflows/main.yml",
    "content": "name: Publish Notion website to GitHub Pages\n\non:\n  # Manual update only.\n  workflow_dispatch:\n  \npermissions:\n  contents: write\n\njobs:\n  deploy:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout loconotion\n        uses: actions/checkout@v3\n        with:\n          repository: leoncvlt/loconotion\n          path: loconotion\n      - name: Checkout this repo\n        uses: actions/checkout@v3\n        with:\n          path: pages_repo\n      - name: Download and install chromedriver\n        run: sudo apt install chromium-chromedriver\n      - name: Install Loconotion dependencies\n        run: pip install -r loconotion/requirements.txt\n      - name: Run Loconotion\n        run: |\n          python3 loconotion/loconotion --chromedriver chromedriver \"pages_repo/site.toml\"\n      - name: Push to GitHub pages\n        run: |\n          git config --global user.name \"github-actions[bot]\"\n          git config --global user.email \"41898282+github-actions[bot]@users.noreply.github.com\"\n          GIT_DEPLOY_DIR=../dist/site \\\n          GIT_DEPLOY_BRANCH=gh-pages \\\n          GIT_DEPLOY_REPO=\"https://${{ github.token }}@github.com/${{ github.repository }}.git\" ./deploy.sh\n        working-directory: pages_repo\n"
  },
  {
    "path": "README.md",
    "content": "# Notion website template\n\nMake a website using Notion, GitHub Pages and Loconotion in just 5 steps.\n\n1. Fork this repo or press [use this template button](https://github.com/timovv/notion-website-template/generate).\n1. Create a Notion page to be your website. This can have subpages, databases, anything supported by [Loconotion](https://github.com/leoncvlt/loconotion).\n1. Share your Notion page publicly, and update `site.toml` in your repo to point to it.\n1. Run the `Publish Notion website to GitHub Pages` action under the Actions tab of your repo.\n1. Update your repo's `Pages` settings to use the `gh-pages` branch, hit save, and voila!\n\nTo resync the website, simply run the GitHub action again. `site.toml` can be updated to use any of the settings specified in the [Loconotion README](https://github.com/leoncvlt/loconotion/blob/master/README.md).\n\n## Acknowledgements\n\nThanks to:\n- @leoncvt for creating the Loconotion script\n- @X1011 for the original script used to deploy the website to GitHub pages"
  },
  {
    "path": "deploy.sh",
    "content": "#!/usr/bin/env bash\n\n# Originally obtained from https://github.com/X1011/git-directory-deploy, with thanks to the author.\n# Used under the BSD 3-Clause License, reproduced below:\n#\n# BSD 3-Clause License:\n#\n# Copyright Daniel Smith\n# All rights reserved.\n#\n# Redistribution and use in source and binary forms, with or without modification,\n# are permitted provided that the following conditions are met:\n#\n#   Redistributions of source code must retain the above copyright notice, this\n#   list of conditions and the following disclaimer.\n#\n#   Redistributions in binary form must reproduce the above copyright notice, this\n#   list of conditions and the following disclaimer in the documentation and/or\n#   other materials provided with the distribution.\n#\n#   The names of the contributors may not be used to endorse or promote products\n#   derived from this software without specific prior written permission.\n#\n# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON\n# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nset -o errexit #abort if any command fails\nme=$(basename \"$0\")\n\nhelp_message=\"\\\nUsage: $me [-c FILE] [<options>]\nDeploy generated files to a git branch.\n\nOptions:\n\n  -h, --help               Show this help information.\n  -v, --verbose            Increase verbosity. Useful for debugging.\n  -e, --allow-empty        Allow deployment of an empty directory.\n  -m, --message MESSAGE    Specify the message used when committing on the\n                           deploy branch.\n  -n, --no-hash            Don't append the source commit's hash to the deploy\n                           commit's message.\n  -c, --config-file PATH   Override default & environment variables' values\n                           with those in set in the file at 'PATH'. Must be the\n                           first option specified.\n\nVariables:\n\n  GIT_DEPLOY_DIR      Folder path containing the files to deploy.\n  GIT_DEPLOY_BRANCH   Commit deployable files to this branch.\n  GIT_DEPLOY_REPO     Push the deploy branch to this repository.\n\nThese variables have default values defined in the script. The defaults can be\noverridden by environment variables. Any environment variables are overridden\nby values set in a '.env' file (if it exists), and in turn by those set in a\nfile specified by the '--config-file' option.\"\n\nparse_args() {\n\t# Set args from a local environment file.\n\tif [ -e \".env\" ]; then\n\t\tsource .env\n\tfi\n\n\t# Set args from file specified on the command-line.\n\tif [[ $1 = \"-c\" || $1 = \"--config-file\" ]]; then\n\t\tsource \"$2\"\n\t\tshift 2\n\tfi\n\n\t# Parse arg flags\n\t# If something is exposed as an environment variable, set/overwrite it\n\t# here. Otherwise, set/overwrite the internal variable instead.\n\twhile : ; do\n\t\tif [[ $1 = \"-h\" || $1 = \"--help\" ]]; then\n\t\t\techo \"$help_message\"\n\t\t\treturn 0\n\t\telif [[ $1 = \"-v\" || $1 = \"--verbose\" ]]; then\n\t\t\tverbose=true\n\t\t\tshift\n\t\telif [[ $1 = \"-e\" || $1 = \"--allow-empty\" ]]; then\n\t\t\tallow_empty=true\n\t\t\tshift\n\t\telif [[ ( $1 = \"-m\" || $1 = \"--message\" ) && -n $2 ]]; then\n\t\t\tcommit_message=$2\n\t\t\tshift 2\n\t\telif [[ $1 = \"-n\" || $1 = \"--no-hash\" ]]; then\n\t\t\tGIT_DEPLOY_APPEND_HASH=false\n\t\t\tshift\n\t\telse\n\t\t\tbreak\n\t\tfi\n\tdone\n\n\t# Set internal option vars from the environment and arg flags. All internal\n\t# vars should be declared here, with sane defaults if applicable.\n\n\t# Source directory & target branch.\n\tdeploy_directory=${GIT_DEPLOY_DIR:-dist}\n\tdeploy_branch=${GIT_DEPLOY_BRANCH:-gh-pages}\n\n\t#if no user identity is already set in the current git environment, use this:\n\tdefault_username=${GIT_DEPLOY_USERNAME:-deploy.sh}\n\tdefault_email=${GIT_DEPLOY_EMAIL:-}\n\n\t#repository to deploy to. must be readable and writable.\n\trepo=${GIT_DEPLOY_REPO:-origin}\n\n\t#append commit hash to the end of message by default\n\tappend_hash=${GIT_DEPLOY_APPEND_HASH:-true}\n}\n\nmain() {\n\tparse_args \"$@\"\n\n\tenable_expanded_output\n\n\tcommit_title=`git log -n 1 --format=\"%s\" HEAD`\n\tcommit_hash=` git log -n 1 --format=\"%H\" HEAD`\n\t\n\t#default commit message uses last title if a custom one is not supplied\n\tif [[ -z $commit_message ]]; then\n\t\tcommit_message=\"publish: $commit_title\"\n\tfi\n\t\n\t#append hash to commit message unless no hash flag was found\n\tif [ $append_hash = true ]; then\n\t\tcommit_message=\"$commit_message\"$'\\n\\n'\"generated from commit $commit_hash\"\n\tfi\n\t\t\n\tprevious_branch=`git rev-parse --abbrev-ref HEAD`\n\n\tif [ ! -d \"$deploy_directory\" ]; then\n\t\techo \"Deploy directory '$deploy_directory' does not exist. Aborting.\" >&2\n\t\treturn 1\n\tfi\n\t\n\t# must use short form of flag in ls for compatibility with OS X and BSD\n\tif [[ -z `ls -A \"$deploy_directory\" 2> /dev/null` && -z $allow_empty ]]; then\n\t\techo \"Deploy directory '$deploy_directory' is empty. Aborting. If you're sure you want to deploy an empty tree, use the --allow-empty / -e flag.\" >&2\n\t\treturn 1\n\tfi\n\n\tif git ls-remote --exit-code $repo \"refs/heads/$deploy_branch\" ; then\n\t\t# deploy_branch exists in $repo; make sure we have the latest version\n\t\t\n\t\tdisable_expanded_output\n\t\tgit fetch --force $repo $deploy_branch:$deploy_branch\n\t\tenable_expanded_output\n\tfi\n\n\t# check if deploy_branch exists locally\n\tif git show-ref --verify --quiet \"refs/heads/$deploy_branch\"\n\tthen incremental_deploy\n\telse initial_deploy\n\tfi\n\n\trestore_head\n}\n\ninitial_deploy() {\n\tgit --work-tree \"$deploy_directory\" checkout --orphan $deploy_branch\n\tgit --work-tree \"$deploy_directory\" add --all\n\tcommit+push\n}\n\nincremental_deploy() {\n\t#make deploy_branch the current branch\n\tgit symbolic-ref HEAD refs/heads/$deploy_branch\n\t#put the previously committed contents of deploy_branch into the index\n\tgit --work-tree \"$deploy_directory\" reset --mixed --quiet\n\tgit --work-tree \"$deploy_directory\" add --all\n\n\tset +o errexit\n\tdiff=$(git --work-tree \"$deploy_directory\" diff --exit-code --quiet HEAD --)$?\n\tset -o errexit\n\tcase $diff in\n\t\t0) echo No changes to files in $deploy_directory. Skipping commit.;;\n\t\t1) commit+push;;\n\t\t*)\n\t\t\techo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2\n\t\t\treturn $diff\n\t\t\t;;\n\tesac\n}\n\ncommit+push() {\n\tset_user_id\n\tgit --work-tree \"$deploy_directory\" commit -m \"$commit_message\"\n\n\tdisable_expanded_output\n\t#--quiet is important here to avoid outputting the repo URL, which may contain a secret token\n\tgit push --quiet $repo $deploy_branch\n\tenable_expanded_output\n}\n\n#echo expanded commands as they are executed (for debugging)\nenable_expanded_output() {\n\tif [ $verbose ]; then\n\t\tset -o xtrace\n\t\tset +o verbose\n\tfi\n}\n\n#this is used to avoid outputting the repo URL, which may contain a secret token\ndisable_expanded_output() {\n\tif [ $verbose ]; then\n\t\tset +o xtrace\n\t\tset -o verbose\n\tfi\n}\n\nset_user_id() {\n\tif [[ -z `git config user.name` ]]; then\n\t\tgit config user.name \"$default_username\"\n\tfi\n\tif [[ -z `git config user.email` ]]; then\n\t\tgit config user.email \"$default_email\"\n\tfi\n}\n\nrestore_head() {\n\tif [[ $previous_branch = \"HEAD\" ]]; then\n\t\t#we weren't on any branch before, so just set HEAD back to the commit it was on\n\t\tgit update-ref --no-deref HEAD $commit_hash $deploy_branch\n\telse\n\t\tgit symbolic-ref HEAD refs/heads/$previous_branch\n\tfi\n\t\n\tgit reset --mixed\n}\n\nfilter() {\n\tsed -e \"s|$repo|\\$repo|g\"\n}\n\nsanitize() {\n\t\"$@\" 2> >(filter 1>&2) | filter\n}\n\n[[ $1 = --source-only ]] || main \"$@\""
  },
  {
    "path": "site.toml",
    "content": "# This is the .toml file passed to Locomotion.\n# For information on the different settings available, and an example file,\n# see the Locomotion README: https://github.com/leoncvlt/loconotion/blob/master/README.md\n\n# DO NOT CHANGE THIS VALUE. The deploy script relies on the site being deployed to the\n# \"site\" directory.\nname = \"site\"\n\n# This page should be the root of your website. It's important.\npage = \"<your Notion share URL here>\"\n"
  }
]