Skip to content

Instantly share code, notes, and snippets.

Avatar

Patrick Arlt patrickarlt

View GitHub Profile
@patrickarlt
patrickarlt / gatsby-node.js
Last active May 22, 2020
Gatsby JS pre-rendering of Stencil components for Calcite Components.
View gatsby-node.js
const path = require("path");
const util = require("util");
const glob = util.promisify(require("glob"));
const workerFarm = require("worker-farm");
const workers = workerFarm(require.resolve("./hydrate-worker"));
// this runs as the last step after Gatsby has built the site/
module.exports.onPostBuild = async function onPostBuild({ reporter }, { ignore }) {
const activity = reporter.activityTimer("Prerendering Calcite Components");
activity.start();
View layout-issues.mdx

Layout Issues

  1. <MoreInfo> spacing in unordered list followed by text...

    Test

View index.js
const { read, write } = require("to-vfile");
const remark = require("remark");
const mdx = require("remark-mdx");
const visit = require("unist-util-visit");
const customPlugin = () => (tree, vfile) => {
vfile.data.plugin = "Set by custom plugin";
visit(tree, "heading", node => {
if (node.depth === 1) {
View index.js
(async () => {
const inPath = "./example.mdx";
const outPath = "./example-out.mdx";
const file = await read(inPath);
const processor = remark().use(mdx);
const tree = processor.parse(file.contents.toString());
const result = processor.stringify(tree);
console.log("result", result);
await write({
View index.js
const { read, write } = require("to-vfile");
const remark = require("remark");
const mdx = require("remark-mdx");
const visit = require("unist-util-visit");
const parse = require("@babel/parser").parse;
const generate = require("@babel/generator").default;
const traverse = require("@babel/traverse").default;
const t = require("@babel/types");
const { readFileSync } = require("fs");
const { dirname } = require("path");
View root.json
{
"version":8,
"sprite":"https://cdn.arcgis.com/sharing/rest/content/items/63c47b7177f946b49902c24129b87252/resources/styles/../sprites/sprite",
"glyphs":"https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer/resources/fonts/{fontstack}/{range}.pbf",
"sources":{
"esri":{
"type":"vector",
"url":"https://basemaps.arcgis.com/arcgis/rest/services/World_Basemap_v2/VectorTileServer"
}
},
View markdown-example.js
var unified = require("unified");
var remarkParse = require("remark-parse");
var remarkStringify = require("remark-stringify");
var { matches } = require("unist-util-select");
var remove = require("unist-util-remove");
var markdown = `
# Test
# No Really
View demo.js
// the acetate extension
function gitCloneOrUpdate(config) {
return function(context) {
let cmd;
let repoPATH = path.join(config. config.gitCloneRootDirectory, config.gitCloneDirectory);
if (!fs.existsSync(repoPATH)) {
cmd = `git -C ${context.gitCloneRootDirectory} clone ${
View search.js
require("isomorphic-fetch");
require("isomorphic-form-data");
const { SearchQueryBuilder, searchItems } = require("@esri/arcgis-rest-portal");
const { UserSession } = require("@esri/arcgis-rest-auth");
const username = "test";
const password = "test"
@patrickarlt
patrickarlt / 00 - Readme.md
Created Oct 16, 2018
An Angular service wrapping esri-loader for use
View 00 - Readme.md

This is used as a custom resolver on the route you want to load the JS API modules on as per https://blog.thoughtram.io/angular/2016/10/10/resolving-route-data-in-angular-2.html.

you can then access the modules by injecting ActivatedRoute into your component and looking at this.route.snapshot.data['esri']['Map'].

import { NgModule } from "@angular/core";
import { Routes, RouterModule } from "@angular/router";
import { EsriModuleResolveService } from "./esri-module-resolve.service";
import { MapViewComponent } from "./map-view.component";