This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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 | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const Page = (props) => { | |
const [foo, setFoo] = useState('foo') | |
useForm({ | |
//... | |
loadInitialValues: async () => { | |
setFoo('bar') | |
console.log(foo) // 'bar' | |
} | |
onSubmit: async (values) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { loadData, commit } = useGithubFile({ | |
path: 'src/content/home.json', | |
parse: JSON.parse, | |
serialize: JSON.stringify, | |
}) | |
useForm({ | |
//... | |
onSubmit: async (values: any) => commit(values), | |
loadInitialValues: loadData, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [editMode] = useEditMode() | |
const { loadData } = useGithubFile({ | |
path: 'src/navigation.json', | |
parse: JSON.parse, | |
serialize: JSON.stringify, | |
}) | |
const [githubNavItems, setGithubNavItems] = useState(navigation) | |
useEffect(() => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [data] = useForm({ | |
//... | |
loadInitialValues: editMode ? loadData : async () => content | |
}) | |
const layoutContent = useMemo(() => { | |
if (editMode && data.keys().length > 0) return data | |
return content | |
}, [editMode, content, data] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
setHasError(false) | |
if (!editMode) { | |
import(`../content/${slug}.json`) | |
.then((content) => { | |
setContent(content.default) | |
}) | |
.catch((e) => { | |
setHasError(true) | |
}) |