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
let cache = {}; | |
class App extends React.Component { | |
static async getInitialProps({ req, query, asPath, pathname }) { | |
let data; | |
//if data is in cache then use the cache | |
if (cache[someID]) { | |
data = cache[someID] | |
} else { |
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 from "react"; | |
import Autosuggest from "react-autosuggest"; | |
import "../../style.css"; | |
import BuildingsSVG from "../../static/buildings.svg"; | |
import UnitsSVG from "../../static/units.svg"; | |
import match from "autosuggest-highlight/match"; | |
import parse from "autosuggest-highlight/parse"; | |
import axios from "axios"; | |
import slugify from "slugify"; | |
import Router from "next/router"; |
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
Crypto/ICO | Silicon Valley | ||
---|---|---|---|
What's used to raise money | White paper with a lot of promises that sound good on... paper... | An MVP already built through sweat equity and proven user adoption. |
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
[ | |
{ | |
"buildingaddress": "8 LEUNG TAK STREET", | |
"Name": "EIGHT REGENCY (Tuen Mun)", | |
"type": "building" | |
}, | |
{ | |
"buildingaddress": "8 LEUNG TAK STREET", | |
"Name": "31/F FLAT N - NA EIGHT REGENCY (Tuen Mun)", | |
"type": "unit" |
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
server.get("/autocomplete/:searchString", async (req, res) => { | |
let cloudSearchEndpoint = 'your endpoint here' | |
let data = await axios.get( | |
` ${endpoint}/2013-01-01/search?q=~${ | |
req.params.searchString | |
}&return=_all_fields%2C_score&highlight.label=%7B%22max_phrases%22%3A3%2C%22format%22%3A%22text%22%2C%22pre_tag%22%3A%22*%23*%22%2C%22post_tag%22%3A%22*%25*%22%7D&highlight.unitcode=%7B%22max_phrases%22%3A3%2C%22format%22%3A%22text%22%2C%22pre_tag%22%3A%22*%23*%22%2C%22post_tag%22%3A%22*%25*%22%7D&sort=_score+desc` | |
); | |
res.send(JSON.stringify(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
server.get('/post/:slug', async (req, res) => { | |
const actualPage = "/post"; | |
//get the data using '/post/i-love-nextjs' as the id | |
let data = await fetchDataWithURL(req.params.slug) | |
const postContent = { data: data }; | |
app.render(req, res, actualPage, postContent); | |
}); |
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
select * from posts where url = '/post/i-love-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
function createPageContext() { | |
return { | |
theme, | |
sheetsManager: new Map(), | |
sheetsRegistry: new SheetsRegistry(), | |
//add this to fix broken css in prod | |
generateClassName: createGenerateClassName({ | |
productionPrefix: "prod" |
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
id | title | content | url | |
---|---|---|---|---|
245 | i love next.js | because... | /post/i-love-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
class App extends React.Component { | |
static async getInitialProps({ req, query, asPath, pathname }) { | |
let baseUrl = req ? `${req.protocol}://${req.get("Host")}` : ""; | |
let data = await fetch(baseUrl + 'relativeURL') | |
return { | |
data: data |
NewerOlder