mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2026-07-23 22:33:42 -04:00
Refactored Gulp build pipeline with Webpack
This commit is contained in:
@@ -20,6 +20,27 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import "../images/icons/bitbucket.svg"
|
||||
import "../images/icons/github.svg"
|
||||
import "../images/icons/gitlab.svg"
|
||||
|
||||
import "../stylesheets/application.scss"
|
||||
import "../stylesheets/application-palette.scss"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Polyfills
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
import "custom-event-polyfill"
|
||||
import "unfetch/polyfill"
|
||||
|
||||
import Promise from "promise-polyfill"
|
||||
window.Promise = window.Promise || Promise
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Dependencies
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
import Clipboard from "clipboard"
|
||||
import FastClick from "fastclick"
|
||||
|
||||
@@ -33,11 +54,10 @@ import Material from "./components/Material"
|
||||
* Return the meta tag value for the given key
|
||||
*
|
||||
* @param {string} key - Meta name
|
||||
* @param {string} [_] - Stop Flow complaining (TODO)
|
||||
*
|
||||
* @return {string} Meta content value
|
||||
*/
|
||||
const translate = (key, _) => { // eslint-disable-line no-unused-vars
|
||||
const translate = key => {
|
||||
const meta = document.getElementsByName(`lang:${key}`)[0]
|
||||
if (!(meta instanceof HTMLMetaElement))
|
||||
throw new ReferenceError
|
||||
@@ -455,6 +475,11 @@ function initialize(config) { // eslint-disable-line func-style
|
||||
* Exports
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
export {
|
||||
/* Provide this for downward compatibility for now */
|
||||
const app = {
|
||||
initialize
|
||||
}
|
||||
|
||||
export {
|
||||
app
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
*/
|
||||
|
||||
import escape from "escape-string-regexp"
|
||||
import lunr from "expose-loader?lunr!lunr"
|
||||
import lunr from "lunr" // expose-loader?lunr!lunr"
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Functions
|
||||
@@ -51,11 +51,10 @@ const truncate = (string, n) => {
|
||||
* Return the meta tag value for the given key
|
||||
*
|
||||
* @param {string} key - Meta name
|
||||
* @param {string} [_] - Stop Flow complaining (TODO)
|
||||
*
|
||||
* @return {string} Meta content value
|
||||
*/
|
||||
const translate = (key, _) => { // eslint-disable-line no-unused-vars
|
||||
const translate = key => {
|
||||
const meta = document.getElementsByName(`lang:${key}`)[0]
|
||||
if (!(meta instanceof HTMLMetaElement))
|
||||
throw new ReferenceError
|
||||
|
||||
23
src/assets/javascripts/modernizr.js
Normal file
23
src/assets/javascripts/modernizr.js
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import "../../../.modernizr-autorc"
|
||||
16
src/assets/javascripts/providers/.babelrc
Normal file
16
src/assets/javascripts/providers/.babelrc
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"presets": [
|
||||
["env", {
|
||||
"loose": true,
|
||||
"target": {
|
||||
"browsers": [
|
||||
"> 1%",
|
||||
"last 2 versions"
|
||||
]
|
||||
}
|
||||
}]
|
||||
],
|
||||
"plugins": [
|
||||
"add-module-exports"
|
||||
]
|
||||
}
|
||||
76
src/assets/javascripts/providers/jsx.js
Normal file
76
src/assets/javascripts/providers/jsx.js
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017 Martin Donath <martin.donath@squidfunk.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Module
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
/* eslint-disable no-underscore-dangle */
|
||||
export default /* JSX */ {
|
||||
|
||||
/**
|
||||
* Create a native DOM node from JSX's intermediate representation
|
||||
*
|
||||
* @param {string} tag - Tag name
|
||||
* @param {?Object} properties - Properties
|
||||
* @param {Array<string | number | { __html: string } | Array<HTMLElement>>}
|
||||
* children - Child nodes
|
||||
* @return {HTMLElement} Native DOM node
|
||||
*/
|
||||
createElement(tag, properties, ...children) {
|
||||
const el = document.createElement(tag)
|
||||
|
||||
/* Set all properties */
|
||||
if (properties)
|
||||
Array.prototype.forEach.call(Object.keys(properties), attr => {
|
||||
el.setAttribute(attr, properties[attr])
|
||||
})
|
||||
|
||||
/* Iterate child nodes */
|
||||
const iterateChildNodes = nodes => {
|
||||
Array.prototype.forEach.call(nodes, node => {
|
||||
|
||||
/* Directly append text content */
|
||||
if (typeof node === "string" ||
|
||||
typeof node === "number") {
|
||||
el.textContent += node
|
||||
|
||||
/* Recurse, if we got an array */
|
||||
} else if (Array.isArray(node)) {
|
||||
iterateChildNodes(node)
|
||||
|
||||
/* Append raw HTML */
|
||||
} else if (typeof node.__html !== "undefined") {
|
||||
el.innerHTML += node.__html
|
||||
|
||||
/* Append regular nodes */
|
||||
} else if (node instanceof Node) {
|
||||
el.appendChild(node)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/* Iterate child nodes and return element */
|
||||
iterateChildNodes(children)
|
||||
return el
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user