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
import React, { Component } from 'react' | |
import { | |
ActivityIndicator, | |
View, | |
Text, | |
Alert | |
} from 'react-native' | |
import { Permissions, Location, Notifications, Constants } from 'expo' | |
import { graphql, gql, compose } from 'react-apollo' | |
import update from 'immutability-helper' |
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 GetAllTripsQuery = gql` | |
query GetAllTrips($tripargs: TripWhereArgs) { | |
viewer { | |
id | |
user { | |
id | |
domicile | |
abodes | |
trips(where: $tripargs, orderBy: { field: start, direction: DESC }) { | |
pageInfo { |
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
var workdays = { | |
sunday: false, | |
monday: true, | |
tuesday: true, | |
wednesday: true, | |
thursday: true, | |
friday: true, | |
saturday: false | |
} |
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
... | |
async uploadImageAsync(uri) { | |
let formData = new FormData(); | |
formData.append("query", ` | |
mutation CreateFile($input: CreateFileInput!) { | |
createFile(input: $input) { | |
changedFile { | |
id | |
name |
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 frontmatter = require('remark-frontmatter') | |
const withMDX = require('@next/mdx')({ | |
extension: /\.mdx?$/, | |
options: { | |
remarkPlugins: [frontmatter], | |
}, | |
}) | |
module.exports = withMDX({ | |
pageExtensions: ['js', 'jsx', 'mdx'], |
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
[ | |
{ | |
"name": "nextjs-workshop", | |
"size": 299, | |
"title": "nextjs-workshop", | |
"description": "public workshop for getting started with NextJS", | |
"createdAt": "2019-10-27", | |
"type": "github", | |
"tags": ["React", "NextJS"] | |
}, |
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 fs = require('fs') | |
const { promisify } = require('util') | |
const YAML = require('yaml') | |
async function getMDXInfo(content) { | |
try { | |
const files = await promisify(fs.readdir)(`./pages/${content}`) | |
const mdx = await files.filter(f => f.includes('.mdx')) | |
let list = await Promise.all( | |
mdx.map(async p => { |
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
function Projects() { | |
const [projects, setProjects] = useState([]) | |
const [error, setError] = useState() | |
useEffect(() => { | |
async function fetchProjects() { | |
try { | |
const result = await fetch(`/api/get-projects`) | |
const json = await result.json() | |
setProjects(json.projects) | |
} catch (err) { |
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
import { getMDXInfo } from 'utils/get-meta' | |
export default async (req, res) => { | |
if (req.method !== 'GET') { | |
return (res.statusCode = 401) | |
} | |
res.setHeader('Content-Type', 'application/json') | |
try { | |
const { list } = await getMDXInfo('projects') | |
res.status(200).json({ projects: list }) |
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
Projects.getInitialProps = async ({ req }) => { | |
// Prevent unnecessary refetching | |
if (process.browser) { | |
const { projects } = window.__NEXT_DATA__.props.pageProps | |
if (projects && projects.length > 0) { | |
return { projects } | |
} | |
} | |
try { | |
// Have the correct API url |
OlderNewer