Skip to content

Instantly share code, notes, and snippets.

useEffect(() => {
setHasError(false)
if (!editMode) {
import(`../content/${slug}.json`)
.then((content) => {
setContent(content.default)
})
.catch((e) => {
setHasError(true)
})
const [data] = useForm({
//...
loadInitialValues: editMode ? loadData : async () => content
})
const layoutContent = useMemo(() => {
if (editMode && data.keys().length > 0) return data
return content
}, [editMode, content, data]
const [editMode] = useEditMode()
const { loadData } = useGithubFile({
path: 'src/navigation.json',
parse: JSON.parse,
serialize: JSON.stringify,
})
const [githubNavItems, setGithubNavItems] = useState(navigation)
useEffect(() => {
const { loadData, commit } = useGithubFile({
path: 'src/content/home.json',
parse: JSON.parse,
serialize: JSON.stringify,
})
useForm({
//...
onSubmit: async (values: any) => commit(values),
loadInitialValues: loadData,
export const Page = (props) => {
const [foo, setFoo] = useState('foo')
useForm({
//...
loadInitialValues: async () => {
setFoo('bar')
console.log(foo) // 'bar'
}
onSubmit: async (values) => {
/**
* This is an example gulpfile.js for orchestrating a Webpack build alongside the Hugo static site generator.
*
* This example assumes you already have Webpack installed and configured in your project.
*
* To get started, install Gulp and BrowserSync with the following command:
* npm install gulp browser-sync
*
* Then add this file to your project and name it gulpfile.js
*/
@dwalkr
dwalkr / gist:af450931a1dceb5ac0f25a2bd7471197
Created April 24, 2018 20:51
create-static-site output
npx create-static-site testhugo3 --template hugo
npx: installed 64 in 3.889s
Creating a new Static Site in /home/dj/Forestry/testhugo3.
Installing packages. This might take a couple of minutes.
Installing static-scripts...
yarn add v1.6.0
warning package.json: No license field