-
Can't mix static layout and dynamic pages, this prevents define common static data requirements in the layout and then optionnally dynamic requirements in some pages below: vercel/next.js#44712 (comment)
-
RSC might be a way to colocate graphql data requirements with components, but it's not very declarative
-
i18n: since "FormattedMessage" tend to be a leaf component, we can't really server-side render it, all i18n messages thus need hydration
-
404 are delicate because route handlers can be mixed with routes : vercel/next.js#49696, and also when fetching files (you may conflate a file with the first route parameter of your app eg [lang])
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 {EditorState} = require("prosemirror-state") | |
const {EditorView} = require("prosemirror-view") | |
const {Schema, DOMParser} = require("prosemirror-model") | |
const {schema} = require("prosemirror-schema-basic") | |
const {addListNodes} = require("prosemirror-schema-list") | |
const {exampleSetup} = require("prosemirror-example-setup") | |
const { inputRules, InputRule } = require("prosemirror-inputrules") | |
const starRule = new InputRule(/\*(.+)\*/, (state, match, start, end) => { |
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 fs from "fs"; | |
import os from "os"; | |
import path from "path"; | |
const fsPromises = fs.promises; | |
// DATA STORE | |
// In a real project this belongs to the db server code | |
// We simulate a distant db by storing data in a file | |
const filePath = path.resolve(os.homedir(), ".mockdb"); | |
async function updateData<TData=any>(data:TData) { |
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
/** | |
* Run this script manually in the console and copy-paste the result to generate | |
* a TOC based on "section" layout, instead of markdown titles (that are not helpful here) | |
* | |
* NOTE: this script is loaded in index.html, | |
* so you can call generateTocFromSections easily from the slidev app, in the browser console | |
* | |
* NOTE: this could also be adapted with Cheerio or an HTML/md parser to parse the markdown directly? | |
*/ | |
function generateTocFromSections() { |
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 edits = [ | |
[ | |
"node_modules/ts-invariant/package.json", | |
{ | |
type: "module", | |
exports: { | |
".": "./lib/invariant.esm.js", | |
"./process/index.js": "./process/index.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
import { useIntlContext } from "@vulcanjs/i18n"; | |
import { useEffect, useRef } from "react"; | |
import { block } from "./block"; | |
import debug from "debug"; | |
const debugTransitions = debug("vn:route-transition"); | |
/** | |
* Can trigger an alert on unsaved changes | |
* | |
* @see https://github.com/ReactTraining/history/blob/master/docs/blocking-transitions.md |
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
// in next.config.js Webpack field | |
config.plugins.push( | |
new options.webpack.DefinePlugin({ | |
'process.env.NEXT_IS_SERVER': JSON.stringify(options.isServer.toString()), | |
}) | |
) |
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
// in next.config.js | |
import packageJson from "./package.json" | |
module.exports = { | |
env: { | |
NEXT_PUBLIC_APP_VERSION: packageJson.version | |
} | |
} |
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 snakeCase from 'lodash/snakeCase'; | |
import { Meteor } from 'meteor/meteor'; | |
import { Random } from 'meteor/random'; | |
import fs from 'fs'; | |
let bound; | |
if (Meteor.isServer) { | |
bound = Meteor.bindEnvironment(callback => callback()); | |
} |
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
// Package 1 - "my-basic-ui" | |
const MyBasicButton = ({onClick, children}) => ( | |
<button onClick={onClick}> | |
{children} | |
</button> | |
) | |
// Tell other packages they can use your component | |
// under the name "Button" | |
registerComponent({ | |
name: 'Button', |
NewerOlder