View index-head-sample.js
// Gatsby.js API Fetch + HeadlessCMS, sample | |
import React, { useState, useEffect } from "react" | |
const IndexPage = () => { | |
const [postItems, setPostItems] = useState([]) | |
const site_id = "123" | |
const base_url = "http://hoge.com" | |
var url = base_url+`/api/get/find?content=posts&site_id=${site_id}` | |
useEffect( ()=>{ |
View index.js
// Gatsby.js API Fetch, sample | |
// https://www.gatsbyjs.com/docs/data-fetching/#retrieving-data-with-the-fetch-api | |
import React, { useState, useEffect } from "react" | |
// import { graphql, useStaticQuery } from "gatsby" | |
const IndexPage = () => { | |
// Client-side Runtime Data Fetching | |
const [starsCount, setStarsCount] = useState(0) | |
useEffect(() => { |
View gh-pages.yml
name: github pages | |
on: | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-18.04 | |
env: |
View gh-pages.yml
name: github pages | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-deploy: | |
runs-on: ubuntu-18.04 |
View test.js
// strapi ,Related data sample | |
import React from 'react' | |
import Layout from '../components/layout' | |
import LibCommon from '../libs/LibCommon' | |
import LibPagenate from '../libs/LibPagenate' | |
import TopHeadBox from '../components/TopHeadBox' | |
import IndexRow from './IndexRow'; | |
// |
View .babelrc
{ | |
"presets": [ | |
"@babel/preset-env" | |
] | |
} |
View auth_check.js
const bcrypt = require('bcrypt'); | |
var AUTH_MAIL = "hoge@example.com" | |
var AUTH_PASSWORD="1111" | |
// | |
export default async (req, res) => { | |
try{ | |
if (req.method === "POST") { | |
var data = req.body | |
console.log(data) |
View test_login.js
// Next.js, Login sample | |
import Layout from '../components/layout' | |
import React from 'react' | |
import cookies from 'next-cookies' | |
class Page extends React.Component { | |
static async getInitialProps(ctx) { | |
return { | |
initialName: '' |
View test.js
// Next.js, flash get sample | |
import flash from 'next-flash'; | |
import Head from 'next/head'; | |
import Link from 'next/link'; | |
import React from 'react' | |
export default class Page extends React.Component { | |
static async getInitialProps (ctx) { | |
return flash.get(ctx) || {} |
View test_flash.js
// Next.js, flash set sample | |
import flash from 'next-flash'; | |
import Head from 'next/head'; | |
import Link from 'next/link'; | |
import React from 'react' | |
import Router from 'next/router' | |
export default class Page extends React.Component { | |
static async getInitialProps (ctx) { | |
return flash.get(ctx) || {} |
NewerOlder