Skip to content

Instantly share code, notes, and snippets.

@pagelab
Last active August 5, 2021 21:42
Show Gist options
  • Save pagelab/b75c488cd0e873e8ba092342cb15d729 to your computer and use it in GitHub Desktop.
Save pagelab/b75c488cd0e873e8ba092342cb15d729 to your computer and use it in GitHub Desktop.
Codekit custom hook to process TXT files in a folder to form the theme.json for the WordPress site editor.
#!/bin/bash
rm -f -- "$CK_PROJECT_ROOT/theme.json" && cat "$CK_PROJECT_ROOT/src/json/"*.txt >> "$CK_PROJECT_ROOT/theme.json"
@pagelab
Copy link
Author

pagelab commented Aug 5, 2021

Codekit docs for reference.

  • Separate your theme.json in several TXT files as you wish and put them in the src/json folder. The TXT files should be built in a way to result in a valid JSON structure for the resulting theme.json file. They will be concatenated only, so no validation will occur.
  • Add your theme project to Codekit.
  • Configure the TXT files in Codekit to process them in place (no copying or changing directories).
  • Click on any TXT file to reveal the “Edit hook” button.
  • Open the hook interface and add the shell script above in the window.

Now, when you edit any of the TXT files, a new theme.json will be created at the project root.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment