···11-# Astro Starter Kit: Basics
11+# gwen.works
2233-```sh
44-npm create astro@latest -- --template basics
55-```
66-77-[](https://stackblitz.com/github/withastro/astro/tree/latest/examples/basics)
88-[](https://codesandbox.io/p/sandbox/github/withastro/astro/tree/latest/examples/basics)
99-[](https://codespaces.new/withastro/astro?devcontainer_path=.devcontainer/basics/devcontainer.json)
1010-1111-> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
1212-1313-
1414-1515-## 🚀 Project Structure
1616-1717-Inside of your Astro project, you'll see the following folders and files:
1818-1919-```text
2020-/
2121-├── public/
2222-│ └── favicon.svg
2323-├── src/
2424-│ ├── layouts/
2525-│ │ └── Layout.astro
2626-│ └── pages/
2727-│ └── index.astro
2828-└── package.json
2929-```
3030-3131-To learn more about the folder structure of an Astro project, refer to [our guide on project structure](https://docs.astro.build/en/basics/project-structure/).
3232-3333-## 🧞 Commands
3434-3535-All commands are run from the root of the project, from a terminal:
3636-3737-| Command | Action |
3838-| :------------------------ | :----------------------------------------------- |
3939-| `npm install` | Installs dependencies |
4040-| `npm run dev` | Starts local dev server at `localhost:4321` |
4141-| `npm run build` | Build your production site to `./dist/` |
4242-| `npm run preview` | Preview your build locally, before deploying |
4343-| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
4444-| `npm run astro -- --help` | Get help using the Astro CLI |
4545-4646-## 👀 Want to learn more?
4747-4848-Feel free to check [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
33+my portfolio :)
···12121313As you turn around to your client code, you get that generated HTML _string_, and include it somewhere on your page, telling your templating engin / js framework “it's fine, this is safe for HTML inclusion”.
14141515-A few months pass, you add more and more features, and suddenly your API has _a lot_of fields, some that output HTML and some that output plain text.
1515+A few months pass, you add more and more features, and suddenly your API has \_a lot_of fields, some that output HTML and some that output plain text.
16161717As a documentation feature, you create a separate `HTML` scalar type to signal fields that have HTML content (and thus cannot be inserted into the page as simple text).
1818
+1-1
blog/making-an-lsp-server-in-go.md
···189189As with `Initialize`, hovering over the types of the parameters will help you greatly.
190190191191```go
192192-// IMPORTANT: You _can't_ take a pointer to your handler struct as the receiver,
192192+// IMPORTANT: You _can't_ take a pointer to your handler struct as the receiver,
193193// your handler will no longer implement protocol.Server if you do that.
194194func (h Handler) Definition(ctx context.Context, params *protocol.DefinitionParams) ([]protocol.Location, error) {
195195 // ... do your processing ...
···55mathjax: yes
66---
7788-98This is a sort of "theorem" that I made up in my mind has been itching me since my years in higher math education.
1091110## Context
12111313-Let $E$ a set and $o \in E^2 \to E$, such that $(E, o)$ forms a [monoid](https://en.wikipedia.org/wiki/Monoid).
1212+Let $E$ a set and $o \in E^2 \to E$, such that $(E, o)$ forms a [monoid](https://en.wikipedia.org/wiki/Monoid).
14131514We then define $\mathcal O$ as the _repeated variant_ of the binary operator $o$:
1615···23222423using an infix notation for $o$, defined as you would expect: $A\ o\ B = o(A, B)$.
25242626-2725This is why we need $(E, o)$ to be a monoid, instead of a unital magma: we need the operator to be associative, so that the repeated application of the operator is well-defined.
28262927Note how repeated operators have their argument in a sequence space instead of a set. This is because:
302831291. we need to _iterate_ over the elements, which requires a well-defined order on the elements (otherwise, we would need $o$ to be commutative and therefore $(E, o)$ to be a group instead of just a monoid)
32301. We also want to be able to represent repeated operations on duplicates, which sets cannot represent.
3333-34313532## Theorem
3633···585559561. $\bigwedge$ is the repeated variant of $\land$.
60571. $(\{\top, \bot\}, \land)$ is a monoid:
6161- - $\land$ is a binary operation on $\{\top, \bot\}$.
6262- - $\land$ is associative: $a \land (b \land c) = (a \land b) \land c$.
6363- - $\land$ has a unit element $\top$ (as $a \land \top = a$ for any $a$) and $\top \in \{\top, \bot\}$.
5858+ - $\land$ is a binary operation on $\{\top, \bot\}$.
5959+ - $\land$ is associative: $a \land (b \land c) = (a \land b) \land c$.
6060+ - $\land$ has a unit element $\top$ (as $a \land \top = a$ for any $a$) and $\top \in \{\top, \bot\}$.
64611. $\operatorname{unit} \{\top, \bot\} = \top$.
65626663Therefore, $\bigwedge(()) = \top$.
···134131135132## Applications
136133137137-| Operation | Application | |
138138-| --------- | ------------------------------------------------------ |-- |
139139-| $+$ | $\sum_\emptyset = 0$ | |
140140-| $\cdot$ | $\prod_\emptyset = 1$ | |
141141-| $\max$ | $\max_\emptyset = -\infty$ | |
142142-| $\min$ | $\min_\emptyset = \infty$ | |
143143-| $\land$ | $\forall \emptyset = \top$ | |
144144-| $\lor$ | $\exists \emptyset = \bot$ | |
145145-| $\cup$ | $\bigcup_\emptyset = \emptyset$ | |
146146-| $\cap$ | $\bigcap_\emptyset = \mathbb U$ | where $\mathbb U$ is the universe set |
134134+| Operation | Application | |
135135+| --------- | ------------------------------- | ------------------------------------- |
136136+| $+$ | $\sum_\emptyset = 0$ | |
137137+| $\cdot$ | $\prod_\emptyset = 1$ | |
138138+| $\max$ | $\max_\emptyset = -\infty$ | |
139139+| $\min$ | $\min_\emptyset = \infty$ | |
140140+| $\land$ | $\forall \emptyset = \top$ | |
141141+| $\lor$ | $\exists \emptyset = \bot$ | |
142142+| $\cup$ | $\bigcup_\emptyset = \emptyset$ | |
143143+| $\cap$ | $\bigcap_\emptyset = \mathbb U$ | where $\mathbb U$ is the universe set |
+255-207
public/bricks.js
···11(function (global, factory) {
22- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
33- typeof define === 'function' && define.amd ? define(factory) :
44- (global.Bricks = factory());
55-}(this, (function () { 'use strict';
22+ typeof exports === "object" && typeof module !== "undefined"
33+ ? (module.exports = factory())
44+ : typeof define === "function" && define.amd
55+ ? define(factory)
66+ : (global.Bricks = factory());
77+})(this, function () {
88+ "use strict";
6977-var _extends = Object.assign || function (target) {
88- for (var i = 1; i < arguments.length; i++) {
99- var source = arguments[i];
1010+ var _extends =
1111+ Object.assign ||
1212+ function (target) {
1313+ for (var i = 1; i < arguments.length; i++) {
1414+ var source = arguments[i];
10151111- for (var key in source) {
1212- if (Object.prototype.hasOwnProperty.call(source, key)) {
1313- target[key] = source[key];
1616+ for (var key in source) {
1717+ if (Object.prototype.hasOwnProperty.call(source, key)) {
1818+ target[key] = source[key];
1919+ }
2020+ }
1421 }
1515- }
1616- }
17221818- return target;
1919-};
2323+ return target;
2424+ };
20252121-var knot = function knot() {
2222- var extended = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2626+ var knot = function knot() {
2727+ var extended =
2828+ arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23292424- var events = Object.create(null);
3030+ var events = Object.create(null);
25312626- function on(name, handler) {
2727- events[name] = events[name] || [];
2828- events[name].push(handler);
2929- return this;
3030- }
3131-3232- function once(name, handler) {
3333- handler._once = true;
3434- on(name, handler);
3535- return this;
3636- }
3737-3838- function off(name) {
3939- var handler = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
3232+ function on(name, handler) {
3333+ events[name] = events[name] || [];
3434+ events[name].push(handler);
3535+ return this;
3636+ }
40374141- handler ? events[name].splice(events[name].indexOf(handler), 1) : delete events[name];
3838+ function once(name, handler) {
3939+ handler._once = true;
4040+ on(name, handler);
4141+ return this;
4242+ }
42434343- return this;
4444- }
4444+ function off(name) {
4545+ var handler =
4646+ arguments.length > 1 && arguments[1] !== undefined
4747+ ? arguments[1]
4848+ : false;
45494646- function emit(name) {
4747- var _this = this;
5050+ handler
5151+ ? events[name].splice(events[name].indexOf(handler), 1)
5252+ : delete events[name];
48534949- for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
5050- args[_key - 1] = arguments[_key];
5454+ return this;
5155 }
52565353- // cache the events, to avoid consequences of mutation
5454- var cache = events[name] && events[name].slice();
5757+ function emit(name) {
5858+ var _this = this;
55595656- // only fire handlers if they exist
5757- cache && cache.forEach(function (handler) {
5858- // remove handlers added with 'once'
5959- handler._once && off(name, handler);
6060+ for (
6161+ var _len = arguments.length,
6262+ args = Array(_len > 1 ? _len - 1 : 0),
6363+ _key = 1;
6464+ _key < _len;
6565+ _key++
6666+ ) {
6767+ args[_key - 1] = arguments[_key];
6868+ }
60696161- // set 'this' context, pass args to handlers
6262- handler.apply(_this, args);
6363- });
7070+ // cache the events, to avoid consequences of mutation
7171+ var cache = events[name] && events[name].slice();
64726565- return this;
6666- }
7373+ // only fire handlers if they exist
7474+ cache &&
7575+ cache.forEach(function (handler) {
7676+ // remove handlers added with 'once'
7777+ handler._once && off(name, handler);
67786868- return _extends({}, extended, {
7979+ // set 'this' context, pass args to handlers
8080+ handler.apply(_this, args);
8181+ });
69827070- on: on,
7171- once: once,
7272- off: off,
7373- emit: emit
7474- });
7575-};
8383+ return this;
8484+ }
76857777-var bricks = function bricks() {
7878- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
8686+ return _extends({}, extended, {
8787+ on: on,
8888+ once: once,
8989+ off: off,
9090+ emit: emit,
9191+ });
9292+ };
79938080- // privates
9494+ var bricks = function bricks() {
9595+ var options =
9696+ arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
81978282- var persist = void 0; // packing new elements, or all elements?
8383- var ticking = void 0; // for debounced resize
9898+ // privates
84998585- var sizeIndex = void 0;
8686- var sizeDetail = void 0;
100100+ var persist = void 0; // packing new elements, or all elements?
101101+ var ticking = void 0; // for debounced resize
871028888- var columnTarget = void 0;
8989- var columnHeights = void 0;
103103+ var sizeIndex = void 0;
104104+ var sizeDetail = void 0;
901059191- var nodeTop = void 0;
9292- var nodeLeft = void 0;
9393- var nodeWidth = void 0;
9494- var nodeHeight = void 0;
106106+ var columnTarget = void 0;
107107+ var columnHeights = void 0;
951089696- var nodes = void 0;
9797- var nodesWidths = void 0;
9898- var nodesHeights = void 0;
109109+ var nodeTop = void 0;
110110+ var nodeLeft = void 0;
111111+ var nodeWidth = void 0;
112112+ var nodeHeight = void 0;
99113100100- // resolve options
114114+ var nodes = void 0;
115115+ var nodesWidths = void 0;
116116+ var nodesHeights = void 0;
101117102102- var packed = options.packed.indexOf('data-') === 0 ? options.packed : 'data-' + options.packed;
103103- var sizes = options.sizes.slice().reverse();
104104- var position = options.position !== false;
118118+ // resolve options
105119106106- var container = options.container.nodeType ? options.container : document.querySelector(options.container);
120120+ var packed =
121121+ options.packed.indexOf("data-") === 0
122122+ ? options.packed
123123+ : "data-" + options.packed;
124124+ var sizes = options.sizes.slice().reverse();
125125+ var position = options.position !== false;
107126108108- var selectors = {
109109- all: function all() {
110110- return toArray(container.children);
111111- },
112112- new: function _new() {
113113- return toArray(container.children).filter(function (node) {
114114- return !node.hasAttribute('' + packed);
115115- });
116116- }
117117- };
127127+ var container = options.container.nodeType
128128+ ? options.container
129129+ : document.querySelector(options.container);
118130119119- // series
131131+ var selectors = {
132132+ all: function all() {
133133+ return toArray(container.children);
134134+ },
135135+ new: function _new() {
136136+ return toArray(container.children).filter(function (node) {
137137+ return !node.hasAttribute("" + packed);
138138+ });
139139+ },
140140+ };
120141121121- var setup = [setSizeIndex, setSizeDetail, setColumns];
142142+ // series
122143123123- var run = [setNodes, setNodesDimensions, setNodesStyles, setContainerStyles];
144144+ var setup = [setSizeIndex, setSizeDetail, setColumns];
124145125125- // instance
126126-127127- var instance = knot({
128128- pack: pack,
129129- update: update,
130130- resize: resize
131131- });
146146+ var run = [
147147+ setNodes,
148148+ setNodesDimensions,
149149+ setNodesStyles,
150150+ setContainerStyles,
151151+ ];
132152133133- return instance;
134134-135135- // general helpers
153153+ // instance
136154137137- function runSeries(functions) {
138138- functions.forEach(function (func) {
139139- return func();
155155+ var instance = knot({
156156+ pack: pack,
157157+ update: update,
158158+ resize: resize,
140159 });
141141- }
142160143143- // array helpers
161161+ return instance;
144162145145- function toArray(input) {
146146- var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document;
163163+ // general helpers
147164148148- return Array.prototype.slice.call(input);
149149- }
165165+ function runSeries(functions) {
166166+ functions.forEach(function (func) {
167167+ return func();
168168+ });
169169+ }
150170151151- function fillArray(length) {
152152- return Array.apply(null, Array(length)).map(function () {
153153- return 0;
154154- });
155155- }
171171+ // array helpers
156172157157- // size helpers
173173+ function toArray(input) {
174174+ var scope =
175175+ arguments.length > 1 && arguments[1] !== undefined
176176+ ? arguments[1]
177177+ : document;
158178159159- function getSizeIndex() {
160160- // find index of widest matching media query
161161- return sizes.map(function (size) {
162162- return size.mq && window.matchMedia('(min-width: ' + size.mq + ')').matches;
163163- }).indexOf(true);
164164- }
179179+ return Array.prototype.slice.call(input);
180180+ }
165181166166- function setSizeIndex() {
167167- sizeIndex = getSizeIndex();
168168- }
182182+ function fillArray(length) {
183183+ return Array.apply(null, Array(length)).map(function () {
184184+ return 0;
185185+ });
186186+ }
169187170170- function setSizeDetail() {
171171- // if no media queries matched, use the base case
172172- sizeDetail = sizeIndex === -1 ? sizes[sizes.length - 1] : sizes[sizeIndex];
173173- }
188188+ // size helpers
174189175175- // column helpers
190190+ function getSizeIndex() {
191191+ // find index of widest matching media query
192192+ return sizes
193193+ .map(function (size) {
194194+ return (
195195+ size.mq && window.matchMedia("(min-width: " + size.mq + ")").matches
196196+ );
197197+ })
198198+ .indexOf(true);
199199+ }
176200177177- function setColumns() {
178178- columnHeights = fillArray(sizeDetail.columns);
179179- }
201201+ function setSizeIndex() {
202202+ sizeIndex = getSizeIndex();
203203+ }
180204181181- // node helpers
205205+ function setSizeDetail() {
206206+ // if no media queries matched, use the base case
207207+ sizeDetail =
208208+ sizeIndex === -1 ? sizes[sizes.length - 1] : sizes[sizeIndex];
209209+ }
182210183183- function setNodes() {
184184- nodes = selectors[persist ? 'new' : 'all']();
185185- }
211211+ // column helpers
186212187187- function setNodesDimensions() {
188188- // exit if empty container
189189- if (nodes.length === 0) {
190190- return;
213213+ function setColumns() {
214214+ columnHeights = fillArray(sizeDetail.columns);
191215 }
192216193193- nodesWidths = nodes.map(function (element) {
194194- return element.clientWidth;
195195- });
196196- nodesHeights = nodes.map(function (element) {
197197- return element.clientHeight;
198198- });
199199- }
217217+ // node helpers
200218201201- function setNodesStyles() {
202202- nodes.forEach(function (element, index) {
203203- columnTarget = columnHeights.indexOf(Math.min.apply(Math, columnHeights));
219219+ function setNodes() {
220220+ nodes = selectors[persist ? "new" : "all"]();
221221+ }
204222205205- element.style.position = 'absolute';
223223+ function setNodesDimensions() {
224224+ // exit if empty container
225225+ if (nodes.length === 0) {
226226+ return;
227227+ }
228228+229229+ nodesWidths = nodes.map(function (element) {
230230+ return element.clientWidth;
231231+ });
232232+ nodesHeights = nodes.map(function (element) {
233233+ return element.clientHeight;
234234+ });
235235+ }
206236207207- nodeTop = columnHeights[columnTarget] + 'px';
208208- nodeLeft = columnTarget * nodesWidths[index] + columnTarget * sizeDetail.gutter + 'px';
237237+ function setNodesStyles() {
238238+ nodes.forEach(function (element, index) {
239239+ columnTarget = columnHeights.indexOf(
240240+ Math.min.apply(Math, columnHeights),
241241+ );
209242210210- // support positioned elements (default) or transformed elements
211211- if (position) {
212212- element.style.top = nodeTop;
213213- element.style.left = nodeLeft;
214214- } else {
215215- element.style.transform = 'translate3d(' + nodeLeft + ', ' + nodeTop + ', 0)';
216216- }
243243+ element.style.position = "absolute";
217244218218- element.setAttribute(packed, '');
245245+ nodeTop = columnHeights[columnTarget] + "px";
246246+ nodeLeft =
247247+ columnTarget * nodesWidths[index] +
248248+ columnTarget * sizeDetail.gutter +
249249+ "px";
219250220220- // ignore nodes with no width and/or height
221221- nodeWidth = nodesWidths[index];
222222- nodeHeight = nodesHeights[index];
251251+ // support positioned elements (default) or transformed elements
252252+ if (position) {
253253+ element.style.top = nodeTop;
254254+ element.style.left = nodeLeft;
255255+ } else {
256256+ element.style.transform =
257257+ "translate3d(" + nodeLeft + ", " + nodeTop + ", 0)";
258258+ }
223259224224- if (nodeWidth && nodeHeight) {
225225- columnHeights[columnTarget] += nodeHeight + sizeDetail.gutter;
226226- }
227227- });
228228- }
260260+ element.setAttribute(packed, "");
229261230230- // container helpers
262262+ // ignore nodes with no width and/or height
263263+ nodeWidth = nodesWidths[index];
264264+ nodeHeight = nodesHeights[index];
231265232232- function setContainerStyles() {
233233- container.style.position = 'relative';
234234- container.style.width = sizeDetail.columns * nodeWidth + (sizeDetail.columns - 1) * sizeDetail.gutter + 'px';
235235- container.style.height = Math.max.apply(Math, columnHeights) - sizeDetail.gutter + 'px';
236236- }
266266+ if (nodeWidth && nodeHeight) {
267267+ columnHeights[columnTarget] += nodeHeight + sizeDetail.gutter;
268268+ }
269269+ });
270270+ }
237271238238- // resize helpers
272272+ // container helpers
239273240240- function resizeFrame() {
241241- if (!ticking) {
242242- window.requestAnimationFrame(resizeHandler);
243243- ticking = true;
274274+ function setContainerStyles() {
275275+ container.style.position = "relative";
276276+ container.style.width =
277277+ sizeDetail.columns * nodeWidth +
278278+ (sizeDetail.columns - 1) * sizeDetail.gutter +
279279+ "px";
280280+ container.style.height =
281281+ Math.max.apply(Math, columnHeights) - sizeDetail.gutter + "px";
244282 }
245245- }
246283247247- function resizeHandler() {
248248- if (sizeIndex !== getSizeIndex()) {
249249- pack();
250250- instance.emit('resize', sizeDetail);
284284+ // resize helpers
285285+286286+ function resizeFrame() {
287287+ if (!ticking) {
288288+ window.requestAnimationFrame(resizeHandler);
289289+ ticking = true;
290290+ }
251291 }
252292253253- ticking = false;
254254- }
293293+ function resizeHandler() {
294294+ if (sizeIndex !== getSizeIndex()) {
295295+ pack();
296296+ instance.emit("resize", sizeDetail);
297297+ }
255298256256- // API
299299+ ticking = false;
300300+ }
257301258258- function pack() {
259259- persist = false;
260260- runSeries(setup.concat(run));
302302+ // API
261303262262- return instance.emit('pack');
263263- }
304304+ function pack() {
305305+ persist = false;
306306+ runSeries(setup.concat(run));
264307265265- function update() {
266266- persist = true;
267267- runSeries(run);
308308+ return instance.emit("pack");
309309+ }
268310269269- return instance.emit('update');
270270- }
311311+ function update() {
312312+ persist = true;
313313+ runSeries(run);
271314272272- function resize() {
273273- var flag = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
315315+ return instance.emit("update");
316316+ }
274317275275- var action = flag ? 'addEventListener' : 'removeEventListener';
318318+ function resize() {
319319+ var flag =
320320+ arguments.length > 0 && arguments[0] !== undefined
321321+ ? arguments[0]
322322+ : true;
276323277277- window[action]('resize', resizeFrame);
324324+ var action = flag ? "addEventListener" : "removeEventListener";
278325279279- return instance;
280280- }
281281-};
326326+ window[action]("resize", resizeFrame);
282327283283-return bricks;
328328+ return instance;
329329+ }
330330+ };
284331285285-})));
332332+ return bricks;
333333+});