@mindful-web/marko-web 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +3 -0
- package/LICENSE +21 -0
- package/browser/.eslintrc.js +1 -0
- package/browser/components/element-id.js +1 -0
- package/browser/components/gated-download/wufoo.vue +97 -0
- package/browser/components/image-slide.vue +54 -0
- package/browser/components/image-slider.vue +87 -0
- package/browser/components/index.js +15 -0
- package/browser/components/load-more-trigger.vue +129 -0
- package/browser/components/oembed.vue +133 -0
- package/browser/components/trigger-in-view-event.vue +41 -0
- package/browser/components/trigger-screen-change-event.vue +94 -0
- package/browser/event-bus.js +5 -0
- package/browser/index.js +83 -0
- package/browser/jquery-full.js +3 -0
- package/browser/jquery.js +3 -0
- package/browser/utils/clean-path.js +4 -0
- package/browser/vue.js +3 -0
- package/components/browser-component/script.marko +10 -0
- package/components/browser-component/script.marko.js +39 -0
- package/components/browser-component.marko +25 -0
- package/components/browser-component.marko.js +75 -0
- package/components/deferred-stylesheet.marko +6 -0
- package/components/deferred-stylesheet.marko.js +28 -0
- package/components/document/components/body-wrapper.marko +8 -0
- package/components/document/components/body-wrapper.marko.js +33 -0
- package/components/document/components/error.marko +26 -0
- package/components/document/components/error.marko.js +88 -0
- package/components/document/components/live-reload.marko +7 -0
- package/components/document/components/live-reload.marko.js +30 -0
- package/components/document/components/polyfill.marko +8 -0
- package/components/document/components/polyfill.marko.js +33 -0
- package/components/document/components/styles.marko +20 -0
- package/components/document/components/styles.marko.js +61 -0
- package/components/document/container.marko +15 -0
- package/components/document/container.marko.js +54 -0
- package/components/document/index.marko +63 -0
- package/components/document/index.marko.js +139 -0
- package/components/document/marko.json +46 -0
- package/components/element/array.marko +19 -0
- package/components/element/array.marko.js +67 -0
- package/components/element/audio.marko +5 -0
- package/components/element/audio.marko.js +33 -0
- package/components/element/block.marko +11 -0
- package/components/element/block.marko.js +44 -0
- package/components/element/clear.marko +4 -0
- package/components/element/clear.marko.js +32 -0
- package/components/element/components/image.marko +32 -0
- package/components/element/components/image.marko.js +62 -0
- package/components/element/components/text.marko +11 -0
- package/components/element/components/text.marko.js +37 -0
- package/components/element/content/address1.marko +14 -0
- package/components/element/content/address1.marko.js +40 -0
- package/components/element/content/address2.marko +14 -0
- package/components/element/content/address2.marko.js +40 -0
- package/components/element/content/audio.marko +13 -0
- package/components/element/content/audio.marko.js +39 -0
- package/components/element/content/authors.marko +12 -0
- package/components/element/content/authors.marko.js +43 -0
- package/components/element/content/body.marko +28 -0
- package/components/element/content/body.marko.js +66 -0
- package/components/element/content/byline.marko +15 -0
- package/components/element/content/byline.marko.js +41 -0
- package/components/element/content/city-state-zip.marko +14 -0
- package/components/element/content/city-state-zip.marko.js +40 -0
- package/components/element/content/contributors.marko +12 -0
- package/components/element/content/contributors.marko.js +43 -0
- package/components/element/content/country.marko +14 -0
- package/components/element/content/country.marko.js +40 -0
- package/components/element/content/embed-code.marko +15 -0
- package/components/element/content/embed-code.marko.js +41 -0
- package/components/element/content/end-date.marko +17 -0
- package/components/element/content/end-date.marko.js +43 -0
- package/components/element/content/ends.marko +14 -0
- package/components/element/content/ends.marko.js +40 -0
- package/components/element/content/fax.marko +14 -0
- package/components/element/content/fax.marko.js +40 -0
- package/components/element/content/images.marko +12 -0
- package/components/element/content/images.marko.js +43 -0
- package/components/element/content/marko.json +328 -0
- package/components/element/content/mobile.marko +14 -0
- package/components/element/content/mobile.marko.js +40 -0
- package/components/element/content/name.marko +15 -0
- package/components/element/content/name.marko.js +41 -0
- package/components/element/content/phone.marko +14 -0
- package/components/element/content/phone.marko.js +40 -0
- package/components/element/content/photographers.marko +12 -0
- package/components/element/content/photographers.marko.js +43 -0
- package/components/element/content/public-email.marko +19 -0
- package/components/element/content/public-email.marko.js +47 -0
- package/components/element/content/published.marko +17 -0
- package/components/element/content/published.marko.js +43 -0
- package/components/element/content/short-name.marko +15 -0
- package/components/element/content/short-name.marko.js +41 -0
- package/components/element/content/sidebar-stubs.marko +24 -0
- package/components/element/content/sidebar-stubs.marko.js +63 -0
- package/components/element/content/sidebars.marko +27 -0
- package/components/element/content/sidebars.marko.js +63 -0
- package/components/element/content/source.marko +14 -0
- package/components/element/content/source.marko.js +40 -0
- package/components/element/content/sponsors.marko +12 -0
- package/components/element/content/sponsors.marko.js +43 -0
- package/components/element/content/start-date.marko +17 -0
- package/components/element/content/start-date.marko.js +43 -0
- package/components/element/content/starts.marko +14 -0
- package/components/element/content/starts.marko.js +40 -0
- package/components/element/content/teaser.marko +15 -0
- package/components/element/content/teaser.marko.js +41 -0
- package/components/element/content/title.marko +14 -0
- package/components/element/content/title.marko.js +40 -0
- package/components/element/content/tollfree.marko +14 -0
- package/components/element/content/tollfree.marko.js +40 -0
- package/components/element/content/transcript.marko +22 -0
- package/components/element/content/transcript.marko.js +53 -0
- package/components/element/content/website.marko +22 -0
- package/components/element/content/website.marko.js +51 -0
- package/components/element/date.marko +2 -0
- package/components/element/date.marko.js +27 -0
- package/components/element/extract-render.js +1 -0
- package/components/element/image/caption.marko +15 -0
- package/components/element/image/caption.marko.js +41 -0
- package/components/element/image/credit.marko +15 -0
- package/components/element/image/credit.marko.js +41 -0
- package/components/element/image/display-name.marko +14 -0
- package/components/element/image/display-name.marko.js +40 -0
- package/components/element/image/marko.json +38 -0
- package/components/element/image/slider.marko +18 -0
- package/components/element/image/slider.marko.js +50 -0
- package/components/element/img.marko +12 -0
- package/components/element/img.marko.js +43 -0
- package/components/element/index.marko +12 -0
- package/components/element/index.marko.js +47 -0
- package/components/element/link.marko +25 -0
- package/components/element/link.marko.js +54 -0
- package/components/element/magazine-issue/description.marko +14 -0
- package/components/element/magazine-issue/description.marko.js +40 -0
- package/components/element/magazine-issue/digital-edition-url.marko +22 -0
- package/components/element/magazine-issue/digital-edition-url.marko.js +51 -0
- package/components/element/magazine-issue/marko.json +42 -0
- package/components/element/magazine-issue/name.marko +14 -0
- package/components/element/magazine-issue/name.marko.js +40 -0
- package/components/element/magazine-issue/pdf-url.marko +22 -0
- package/components/element/magazine-issue/pdf-url.marko.js +51 -0
- package/components/element/magazine-publication/cancel-url.marko +22 -0
- package/components/element/magazine-publication/cancel-url.marko.js +51 -0
- package/components/element/magazine-publication/change-address-url.marko +22 -0
- package/components/element/magazine-publication/change-address-url.marko.js +51 -0
- package/components/element/magazine-publication/description.marko +14 -0
- package/components/element/magazine-publication/description.marko.js +40 -0
- package/components/element/magazine-publication/einquiry-url.marko +22 -0
- package/components/element/magazine-publication/einquiry-url.marko.js +51 -0
- package/components/element/magazine-publication/marko.json +82 -0
- package/components/element/magazine-publication/name.marko +14 -0
- package/components/element/magazine-publication/name.marko.js +40 -0
- package/components/element/magazine-publication/renewal-url.marko +22 -0
- package/components/element/magazine-publication/renewal-url.marko.js +51 -0
- package/components/element/magazine-publication/reprints-url.marko +22 -0
- package/components/element/magazine-publication/reprints-url.marko.js +51 -0
- package/components/element/magazine-publication/subscribe-url.marko +22 -0
- package/components/element/magazine-publication/subscribe-url.marko.js +51 -0
- package/components/element/marko.json +211 -0
- package/components/element/obj-array.marko +17 -0
- package/components/element/obj-array.marko.js +56 -0
- package/components/element/obj-audio.marko +20 -0
- package/components/element/obj-audio.marko.js +50 -0
- package/components/element/obj-date.marko +25 -0
- package/components/element/obj-date.marko.js +55 -0
- package/components/element/obj-nodes.marko +20 -0
- package/components/element/obj-nodes.marko.js +62 -0
- package/components/element/obj-text.marko +23 -0
- package/components/element/obj-text.marko.js +53 -0
- package/components/element/obj.marko +23 -0
- package/components/element/obj.marko.js +61 -0
- package/components/element/object-link.js +49 -0
- package/components/element/object-type.js +9 -0
- package/components/element/picture.marko +38 -0
- package/components/element/picture.marko.js +85 -0
- package/components/element/show-element.js +8 -0
- package/components/element/text.marko +37 -0
- package/components/element/text.marko.js +76 -0
- package/components/element/website-section/description.marko +16 -0
- package/components/element/website-section/description.marko.js +44 -0
- package/components/element/website-section/hierarchy.marko +19 -0
- package/components/element/website-section/hierarchy.marko.js +60 -0
- package/components/element/website-section/marko.json +31 -0
- package/components/element/website-section/name.marko +18 -0
- package/components/element/website-section/name.marko.js +46 -0
- package/components/font/google.marko +6 -0
- package/components/font/google.marko.js +41 -0
- package/components/font/link.marko +14 -0
- package/components/font/link.marko.js +45 -0
- package/components/font/marko.json +21 -0
- package/components/font/typekit.marko +5 -0
- package/components/font/typekit.marko.js +38 -0
- package/components/load-more/index.marko +53 -0
- package/components/load-more/index.marko.js +119 -0
- package/components/load-more/marko.json +30 -0
- package/components/load-more/trigger.marko +11 -0
- package/components/load-more/trigger.marko.js +40 -0
- package/components/marko.json +37 -0
- package/components/node/body.marko +40 -0
- package/components/node/body.marko.js +112 -0
- package/components/node/element.marko +6 -0
- package/components/node/element.marko.js +39 -0
- package/components/node/footer.marko +19 -0
- package/components/node/footer.marko.js +63 -0
- package/components/node/header.marko +19 -0
- package/components/node/header.marko.js +63 -0
- package/components/node/image-inner-wrapper.marko +61 -0
- package/components/node/image-inner-wrapper.marko.js +116 -0
- package/components/node/image-wrapper.marko +34 -0
- package/components/node/image-wrapper.marko.js +98 -0
- package/components/node/image.marko +51 -0
- package/components/node/image.marko.js +93 -0
- package/components/node/index.marko +35 -0
- package/components/node/index.marko.js +100 -0
- package/components/node/marko.json +189 -0
- package/components/node/utils/image-height.js +3 -0
- package/components/node/utils/image-values.js +17 -0
- package/components/node-list/body.marko +19 -0
- package/components/node-list/body.marko.js +50 -0
- package/components/node-list/element.marko +3 -0
- package/components/node-list/element.marko.js +35 -0
- package/components/node-list/footer.marko +19 -0
- package/components/node-list/footer.marko.js +50 -0
- package/components/node-list/header.marko +19 -0
- package/components/node-list/header.marko.js +50 -0
- package/components/node-list/index.marko +36 -0
- package/components/node-list/index.marko.js +93 -0
- package/components/node-list/marko.json +121 -0
- package/components/node-list/node.marko +15 -0
- package/components/node-list/node.marko.js +49 -0
- package/components/node-list/nodes.marko +82 -0
- package/components/node-list/nodes.marko.js +126 -0
- package/components/page/container.marko +13 -0
- package/components/page/container.marko.js +46 -0
- package/components/page/description.marko +4 -0
- package/components/page/description.marko.js +26 -0
- package/components/page/image.marko +50 -0
- package/components/page/image.marko.js +122 -0
- package/components/page/layouts/content.marko +23 -0
- package/components/page/layouts/content.marko.js +63 -0
- package/components/page/layouts/default.marko +20 -0
- package/components/page/layouts/default.marko.js +61 -0
- package/components/page/layouts/dynamic-page.marko +19 -0
- package/components/page/layouts/dynamic-page.marko.js +59 -0
- package/components/page/layouts/magazine-issue.marko +19 -0
- package/components/page/layouts/magazine-issue.marko.js +59 -0
- package/components/page/layouts/magazine-publication.marko +19 -0
- package/components/page/layouts/magazine-publication.marko.js +59 -0
- package/components/page/layouts/marko.json +86 -0
- package/components/page/layouts/website-section.marko +25 -0
- package/components/page/layouts/website-section.marko.js +78 -0
- package/components/page/marko.json +93 -0
- package/components/page/metadata/components/common.marko +54 -0
- package/components/page/metadata/components/common.marko.js +117 -0
- package/components/page/metadata/content.marko +147 -0
- package/components/page/metadata/content.marko.js +216 -0
- package/components/page/metadata/default.marko +2 -0
- package/components/page/metadata/default.marko.js +29 -0
- package/components/page/metadata/dynamic-page.marko +40 -0
- package/components/page/metadata/dynamic-page.marko.js +84 -0
- package/components/page/metadata/google-structured-data/content.js +138 -0
- package/components/page/metadata/magazine-issue.marko +39 -0
- package/components/page/metadata/magazine-issue.marko.js +83 -0
- package/components/page/metadata/magazine-publication.marko +35 -0
- package/components/page/metadata/magazine-publication.marko.js +79 -0
- package/components/page/metadata/marko.json +32 -0
- package/components/page/metadata/website-section.marko +48 -0
- package/components/page/metadata/website-section.marko.js +92 -0
- package/components/page/rel-canonical.marko +13 -0
- package/components/page/rel-canonical.marko.js +42 -0
- package/components/page/title.marko +18 -0
- package/components/page/title.marko.js +46 -0
- package/components/page/wrapper.marko +16 -0
- package/components/page/wrapper.marko.js +63 -0
- package/components/resolve/marko.json +6 -0
- package/components/resolve/page.marko +10 -0
- package/components/resolve/page.marko.js +49 -0
- package/components/rss/marko.json +10 -0
- package/components/rss/website-section.marko +17 -0
- package/components/rss/website-section.marko.js +46 -0
- package/config/abstract-config.js +42 -0
- package/config/core.js +48 -0
- package/config/site.js +6 -0
- package/express/apollo.js +34 -0
- package/express/asset-loader.js +55 -0
- package/express/cdn.js +27 -0
- package/express/css-loader.js +117 -0
- package/express/embedded-media.js +31 -0
- package/express/error-handlers.js +113 -0
- package/express/find-content-alias.js +30 -0
- package/express/get-redirect.js +44 -0
- package/express/graphql-proxy.js +17 -0
- package/express/index.js +153 -0
- package/express/json-error-handler.js +30 -0
- package/express/load-document.js +3 -0
- package/express/load-more.js +6 -0
- package/express/load-object.js +10 -0
- package/express/oembed.js +18 -0
- package/express/rss.js +19 -0
- package/express/sitemaps.js +16 -0
- package/express/website-context.js +19 -0
- package/index.js +8 -0
- package/integration/test-website-boot.js +198 -0
- package/marko.json +6 -0
- package/middleware/disabled-features.js +15 -0
- package/middleware/index.js +15 -0
- package/middleware/page-node/index.js +45 -0
- package/middleware/page-node/resolved.js +26 -0
- package/middleware/with-content.js +54 -0
- package/middleware/with-dynamic-page.js +37 -0
- package/middleware/with-load-more.js +9 -0
- package/middleware/with-magazine-issue.js +24 -0
- package/middleware/with-magazine-publication.js +24 -0
- package/middleware/with-website-section.js +47 -0
- package/package.json +64 -0
- package/scss/carousel.scss +42 -0
- package/scss/document.scss +55 -0
- package/scss/fonts/alata-fallback.scss +7 -0
- package/scss/fonts/alegreya-fallback.scss +6 -0
- package/scss/fonts/arimo-fallback.scss +7 -0
- package/scss/fonts/fira-sans-fallback.scss +7 -0
- package/scss/fonts/ibm-plex-sans-fallback.scss +7 -0
- package/scss/fonts/informapro-fallback.scss +6 -0
- package/scss/fonts/lato-fallback.scss +7 -0
- package/scss/fonts/manrope-fallback.scss +6 -0
- package/scss/fonts/merriweather-fallback.scss +7 -0
- package/scss/fonts/montserrat-fallback.scss +7 -0
- package/scss/fonts/open-sans-condensed-fallback.scss +6 -0
- package/scss/fonts/open-sans-fallback.scss +7 -0
- package/scss/fonts/oswald-fallback.scss +7 -0
- package/scss/fonts/poppins-fallback.scss +6 -0
- package/scss/fonts/pt-sans-fallback.scss +6 -0
- package/scss/fonts/pt-serif-fallback.scss +6 -0
- package/scss/fonts/public-sans-fallback.scss +7 -0
- package/scss/fonts/raleway-fallback.scss +6 -0
- package/scss/fonts/roboto-condensed-fallback.scss +7 -0
- package/scss/fonts/roboto-fallback.scss +7 -0
- package/scss/fonts/roboto-slab-fallback.scss +7 -0
- package/scss/fonts/solitaire-mvb-pro-fallback.scss +6 -0
- package/scss/fonts/source-sans-4-fallback.scss +7 -0
- package/scss/fonts/source-serif-pro-fallback.scss +7 -0
- package/scss/fonts/synthese-fallback.scss +6 -0
- package/scss/fonts/zilla-slab-fallback.scss +6 -0
- package/scss/load-more.scss +3 -0
- package/scss/node-list.scss +144 -0
- package/scss/node.scss +371 -0
- package/scss/page-image.scss +15 -0
- package/start-server.js +169 -0
- package/utils/apply-query-params.js +16 -0
- package/utils/build-content-input.js +9 -0
- package/utils/build-marko-global.js +1 -0
- package/utils/default-value.js +1 -0
- package/utils/embedded-media/facebook-oembed.js +50 -0
- package/utils/embedded-media/image.js +71 -0
- package/utils/embedded-media/index.js +8 -0
- package/utils/embedded-media/instagram-oembed.js +57 -0
- package/utils/embedded-media/oembed.js +18 -0
- package/utils/hierarchy-aliases.js +3 -0
- package/utils/hierarchy-ids.js +3 -0
- package/utils/index.js +11 -0
- package/utils/is-dev.js +1 -0
- package/utils/published-content/description.js +1 -0
- package/utils/render-ssr-component-from-marko.js +18 -0
- package/utils/render-ssr-component.js +15 -0
- package/utils/should-collapse.js +1 -0
package/scss/node.scss
ADDED
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
|
|
2
|
+
@use "sass:math";
|
|
3
|
+
|
|
4
|
+
$marko-web-node-image-aspect-ratios: () !default;
|
|
5
|
+
// stylelint-disable-next-line scss/dollar-variable-default
|
|
6
|
+
$marko-web-node-image-aspect-ratios: join(
|
|
7
|
+
(
|
|
8
|
+
(21 9),
|
|
9
|
+
(16 9),
|
|
10
|
+
(6 5),
|
|
11
|
+
(4 3),
|
|
12
|
+
(3 2),
|
|
13
|
+
(2 1),
|
|
14
|
+
(1 1),
|
|
15
|
+
),
|
|
16
|
+
$marko-web-node-image-aspect-ratios
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
$marko-web-node-bg-color: #fff !default;
|
|
20
|
+
$marko-web-node-padding: .75rem !default;
|
|
21
|
+
$marko-web-node-spacer: .375rem !default;
|
|
22
|
+
$marko-web-node-overlay-image-padding: 1.25rem !default;
|
|
23
|
+
$marko-web-node-overlay-image-gradient: linear-gradient(to top, rgba(0, 0, 0, .65), transparent) !default;
|
|
24
|
+
$marko-web-node-overlay-image-link-color: #fff !default;
|
|
25
|
+
$marko-web-node-overlay-image-text-shadow: 1px 1px 4px rgba(0, 0, 0, .65) !default;
|
|
26
|
+
|
|
27
|
+
$marko-web-node-placeholder-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='40'%3E%3Cpath d='M0 38.59l2.83-2.83 1.41 1.41L1.41 40H0v-1.41zM0 1.4l2.83 2.83 1.41-1.41L1.41 0H0v1.41zM38.59 40l-2.83-2.83 1.41-1.41L40 38.59V40h-1.41zM40 1.41l-2.83 2.83-1.41-1.41L38.59 0H40v1.41zM20 18.6l2.83-2.83 1.41 1.41L21.41 20l2.83 2.83-1.41 1.41L20 21.41l-2.83 2.83-1.41-1.41L18.59 20l-2.83-2.83 1.41-1.41L20 18.59z' fill-rule='evenodd'/%3E%3C/svg%3E") !default;
|
|
28
|
+
$marko-web-node-placeholder-image-bg-color: #007bff !default;
|
|
29
|
+
$marko-web-node-placeholder-image-bg-position: .5rem .5rem !default;
|
|
30
|
+
$marko-web-node-placeholder-image-opacity: .2 !default;
|
|
31
|
+
|
|
32
|
+
@mixin marko-web-node-fluid-image($ratio-x, $ratio-y) {
|
|
33
|
+
position: relative;
|
|
34
|
+
display: block;
|
|
35
|
+
width: 100%;
|
|
36
|
+
padding: 0;
|
|
37
|
+
overflow: hidden;
|
|
38
|
+
|
|
39
|
+
&::before {
|
|
40
|
+
display: block;
|
|
41
|
+
content: "";
|
|
42
|
+
@if $ratio-y and $ratio-x {
|
|
43
|
+
padding-top: percentage(math.div($ratio-y, $ratio-x));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@mixin marko-web-node-fluid-image-item() {
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 0;
|
|
51
|
+
bottom: 0;
|
|
52
|
+
left: 0;
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
border: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.node {
|
|
59
|
+
*,
|
|
60
|
+
::after,
|
|
61
|
+
::before {
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
$self: &;
|
|
66
|
+
display: flex;
|
|
67
|
+
flex: 1 1 auto;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
width: 100%;
|
|
70
|
+
padding: $marko-web-node-padding;
|
|
71
|
+
background-color: $marko-web-node-bg-color;
|
|
72
|
+
|
|
73
|
+
&__header {
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: row;
|
|
76
|
+
justify-content: space-between;
|
|
77
|
+
margin-bottom: $marko-web-node-spacer;
|
|
78
|
+
&:empty {
|
|
79
|
+
display: none;
|
|
80
|
+
}
|
|
81
|
+
&--overlay {
|
|
82
|
+
position: absolute;
|
|
83
|
+
top: 0;
|
|
84
|
+
right: 0;
|
|
85
|
+
left: 0;
|
|
86
|
+
padding: $marko-web-node-padding;
|
|
87
|
+
margin-bottom: initial;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
&__header-left,
|
|
92
|
+
&__header-right {
|
|
93
|
+
&:empty {
|
|
94
|
+
display: none;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&__footer {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: row;
|
|
101
|
+
justify-content: space-between;
|
|
102
|
+
margin-top: auto;
|
|
103
|
+
&:empty {
|
|
104
|
+
display: none;
|
|
105
|
+
}
|
|
106
|
+
&--body {
|
|
107
|
+
margin-top: auto;
|
|
108
|
+
#{ $self } {
|
|
109
|
+
&__footer-left,
|
|
110
|
+
&__footer-right {
|
|
111
|
+
margin-top: auto;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
&__footer-left,
|
|
118
|
+
&__footer-right {
|
|
119
|
+
margin-top: $marko-web-node-spacer;
|
|
120
|
+
&:empty {
|
|
121
|
+
display: none;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
&__header-right,
|
|
126
|
+
&__footer-right {
|
|
127
|
+
text-align: right;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
&__contents {
|
|
131
|
+
position: relative;
|
|
132
|
+
display: flex;
|
|
133
|
+
flex: 1 1 auto;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
width: 100%;
|
|
136
|
+
|
|
137
|
+
&--body {
|
|
138
|
+
margin-bottom: $marko-web-node-spacer;
|
|
139
|
+
> :last-child {
|
|
140
|
+
margin-bottom: 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&__body {
|
|
146
|
+
display: flex;
|
|
147
|
+
flex: 1 1 auto;
|
|
148
|
+
flex-direction: column;
|
|
149
|
+
width: 100%;
|
|
150
|
+
&--overlay {
|
|
151
|
+
position: absolute;
|
|
152
|
+
right: 0;
|
|
153
|
+
bottom: 0;
|
|
154
|
+
left: 0;
|
|
155
|
+
padding: $marko-web-node-padding;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
> :last-child {
|
|
159
|
+
margin-bottom: 0;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
&__title {
|
|
164
|
+
&:empty {
|
|
165
|
+
display: none;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
&__text {
|
|
170
|
+
&:empty {
|
|
171
|
+
display: none;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
&__image-wrapper {
|
|
176
|
+
position: relative;
|
|
177
|
+
color: #fff;
|
|
178
|
+
text-shadow: $marko-web-node-overlay-image-text-shadow;
|
|
179
|
+
a {
|
|
180
|
+
color: #fff;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
&--align-middle {
|
|
184
|
+
margin-top: auto;
|
|
185
|
+
margin-bottom: auto;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
&--align-center {
|
|
189
|
+
margin-right: auto;
|
|
190
|
+
margin-left: auto;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
&__image-inner-wrapper {
|
|
195
|
+
display: inline-block;
|
|
196
|
+
|
|
197
|
+
&--placeholder {
|
|
198
|
+
background-color: $marko-web-node-placeholder-image-bg-color;
|
|
199
|
+
#{ $self } {
|
|
200
|
+
&__image {
|
|
201
|
+
background-image: $marko-web-node-placeholder-image;
|
|
202
|
+
background-position: $marko-web-node-placeholder-image-bg-position;
|
|
203
|
+
opacity: $marko-web-node-placeholder-image-opacity;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
&--gradient {
|
|
209
|
+
&::after {
|
|
210
|
+
position: absolute;
|
|
211
|
+
top: 0;
|
|
212
|
+
right: 0;
|
|
213
|
+
bottom: 0;
|
|
214
|
+
left: 0;
|
|
215
|
+
content: "";
|
|
216
|
+
background: $marko-web-node-overlay-image-gradient;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
&--fluid {
|
|
221
|
+
#{ $self } {
|
|
222
|
+
&__image {
|
|
223
|
+
width: 100%;
|
|
224
|
+
height: auto;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
@each $ar in $marko-web-node-image-aspect-ratios {
|
|
230
|
+
$x: nth($ar, 1);
|
|
231
|
+
$y: nth($ar, 2);
|
|
232
|
+
|
|
233
|
+
&--fluid-#{$x}by#{$y} {
|
|
234
|
+
@include marko-web-node-fluid-image($x, $y);
|
|
235
|
+
#{ $self } {
|
|
236
|
+
&__image {
|
|
237
|
+
@include marko-web-node-fluid-image-item();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
// Add the inverse ratios (16by9 becomes 9by16, 4by3 becomes 3by4, etc)
|
|
242
|
+
@if $x != $y {
|
|
243
|
+
&--fluid-#{$y}by#{$x} {
|
|
244
|
+
@include marko-web-node-fluid-image($y, $x);
|
|
245
|
+
#{ $self } {
|
|
246
|
+
&__image {
|
|
247
|
+
@include marko-web-node-fluid-image-item();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
&--full-height {
|
|
256
|
+
height: 100%;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
&--flush {
|
|
260
|
+
padding: 0;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
&--flush-x {
|
|
264
|
+
padding-right: 0;
|
|
265
|
+
padding-left: 0;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
&--flush-y {
|
|
269
|
+
padding-top: 0;
|
|
270
|
+
padding-bottom: 0;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
&--image-flush {
|
|
274
|
+
padding: 0;
|
|
275
|
+
> #{ $self } {
|
|
276
|
+
&__header {
|
|
277
|
+
padding-top: $marko-web-node-padding;
|
|
278
|
+
padding-right: $marko-web-node-padding;
|
|
279
|
+
padding-left: $marko-web-node-padding;
|
|
280
|
+
}
|
|
281
|
+
&__footer {
|
|
282
|
+
padding-right: $marko-web-node-padding;
|
|
283
|
+
padding-bottom: $marko-web-node-padding;
|
|
284
|
+
padding-left: $marko-web-node-padding;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
#{ $self } {
|
|
289
|
+
&__body {
|
|
290
|
+
padding-right: $marko-web-node-padding;
|
|
291
|
+
padding-left: $marko-web-node-padding;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
&--image-top {
|
|
297
|
+
#{ $self } {
|
|
298
|
+
&__image-wrapper + #{ $self }__body {
|
|
299
|
+
margin-top: $marko-web-node-spacer * 2;
|
|
300
|
+
}
|
|
301
|
+
&__body {
|
|
302
|
+
&--overlay {
|
|
303
|
+
margin-top: 0;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
&--image-left {
|
|
310
|
+
#{ $self } {
|
|
311
|
+
&__contents {
|
|
312
|
+
flex-direction: row;
|
|
313
|
+
&--body {
|
|
314
|
+
flex-direction: column;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
&__image-wrapper + #{ $self }__body {
|
|
318
|
+
margin-left: $marko-web-node-padding;
|
|
319
|
+
}
|
|
320
|
+
&__body {
|
|
321
|
+
&--overlay {
|
|
322
|
+
margin-left: 0;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
&#{ $self }--image-flush #{ $self }__image-wrapper + #{ $self }__body {
|
|
327
|
+
padding-left: 0;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
&--image-bottom {
|
|
332
|
+
#{ $self } {
|
|
333
|
+
&__contents {
|
|
334
|
+
flex-direction: column-reverse;
|
|
335
|
+
&--body {
|
|
336
|
+
flex-direction: column;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
&__image-wrapper + #{ $self }__body {
|
|
340
|
+
margin-bottom: $marko-web-node-spacer;
|
|
341
|
+
}
|
|
342
|
+
&__body {
|
|
343
|
+
&--overlay {
|
|
344
|
+
margin-bottom: 0;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
&--image-right {
|
|
351
|
+
#{ $self } {
|
|
352
|
+
&__contents {
|
|
353
|
+
flex-direction: row-reverse;
|
|
354
|
+
&--body {
|
|
355
|
+
flex-direction: column;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
&__image-wrapper + #{ $self }__body {
|
|
359
|
+
margin-right: $marko-web-node-padding;
|
|
360
|
+
}
|
|
361
|
+
&__body {
|
|
362
|
+
&--overlay {
|
|
363
|
+
margin-right: 0;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
&#{ $self }--image-flush #{ $self }__image-wrapper + #{ $self }__body {
|
|
368
|
+
padding-right: 0;
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
package/start-server.js
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/* eslint-disable import/no-dynamic-require, global-require */
|
|
2
|
+
require('@mindful-web/marko-node-require');
|
|
3
|
+
const http = require('http');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { createTerminus } = require('@godaddy/terminus');
|
|
6
|
+
const { isFunction: isFn, parseBooleanHeader } = require('@mindful-web/utils');
|
|
7
|
+
const { getAsObject } = require('@mindful-web/object-path');
|
|
8
|
+
|
|
9
|
+
const { env } = process;
|
|
10
|
+
if (!process.env.LIVERELOAD_PORT) process.env.LIVERELOAD_PORT = 4010;
|
|
11
|
+
if (!process.env.EXPOSED_HOST) process.env.EXPOSED_HOST = env.HOST || 'localhost';
|
|
12
|
+
|
|
13
|
+
process.on('unhandledRejection', (e) => setImmediate(() => { throw e; }));
|
|
14
|
+
|
|
15
|
+
const wait = (ms) => new Promise((resolve) => {
|
|
16
|
+
setTimeout(resolve, ms);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
module.exports = async ({
|
|
20
|
+
rootDir,
|
|
21
|
+
siteConfig,
|
|
22
|
+
coreConfig,
|
|
23
|
+
helmetConfig,
|
|
24
|
+
host = env.HOST,
|
|
25
|
+
port = env.PORT || 4008,
|
|
26
|
+
exposedPort = env.EXPOSED_PORT || env.PORT || 4008,
|
|
27
|
+
exposedHost = env.EXPOSED_HOST,
|
|
28
|
+
routes,
|
|
29
|
+
errorTemplate,
|
|
30
|
+
document, // custom marko-web-document component
|
|
31
|
+
components, // components to register globally (e.g. for load more, etc)
|
|
32
|
+
fragments, // fragments to register globally
|
|
33
|
+
embeddedMediaHandlers,
|
|
34
|
+
onAsyncBlockError,
|
|
35
|
+
onFatalError,
|
|
36
|
+
redirectHandler,
|
|
37
|
+
sitemapsHeaders,
|
|
38
|
+
|
|
39
|
+
// Cache settings.
|
|
40
|
+
gqlCacheResponses = parseBooleanHeader(env.CACHE_GQL_RESPONSES),
|
|
41
|
+
gqlCacheSiteContext = parseBooleanHeader(env.CACHE_GQL_SITE_CONTEXT),
|
|
42
|
+
|
|
43
|
+
// Terminus settings.
|
|
44
|
+
timeout = 1000,
|
|
45
|
+
signals = ['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGQUIT'],
|
|
46
|
+
healthCheckPath = '/_health',
|
|
47
|
+
onSignal,
|
|
48
|
+
onShutdown,
|
|
49
|
+
onStart,
|
|
50
|
+
beforeShutdown,
|
|
51
|
+
onHealthCheck,
|
|
52
|
+
} = {}) => {
|
|
53
|
+
if (!rootDir) throw new Error('The root project directory is required.');
|
|
54
|
+
// load the site package file.
|
|
55
|
+
const sitePackage = require(path.resolve(rootDir, 'package.json'));
|
|
56
|
+
// load config from package `website` option but allow env values to override.
|
|
57
|
+
const site = getAsObject(sitePackage, 'website');
|
|
58
|
+
if (!process.env.TENANT_KEY && site.tenant) process.env.TENANT_KEY = site.tenant;
|
|
59
|
+
if (!process.env.SITE_ID && site.id) process.env.SITE_ID = site.id;
|
|
60
|
+
if (!process.env.GRAPHQL_URI && site.stack) process.env.GRAPHQL_URI = `https://graphql.${site.stack}.mindful-web.parameter1.com`;
|
|
61
|
+
if (!process.env.OEMBED_URI && site.stack) process.env.OEMBED_URI = `https://oembed.${site.stack}.mindful-web.parameter1.com`;
|
|
62
|
+
if (!process.env.RSS_URI && site.stack) process.env.RSS_URI = `https://rss.${site.stack}.mindful-web.parameter1.com`;
|
|
63
|
+
if (!process.env.SITEMAPS_URI && site.stack) process.env.SITEMAPS_URI = `https://sitemaps.${site.stack}.mindful-web.parameter1.com`;
|
|
64
|
+
|
|
65
|
+
// ensure core envs are set.
|
|
66
|
+
['TENANT_KEY', 'SITE_ID', 'GRAPHQL_URI', 'OEMBED_URI', 'RSS_URI', 'SITEMAPS_URI'].forEach((key) => {
|
|
67
|
+
if (!process.env[key]) throw new Error(`The ${key} value must be set either from env or via the website package config.`);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// base browse (optional)
|
|
71
|
+
if (!process.env.BASE_BROWSE_GRAPHQL_URI && site.stack) process.env.BASE_BROWSE_GRAPHQL_URI = `https://base-browse.${site.stack}.mindful-web.parameter1.com/graphql`;
|
|
72
|
+
|
|
73
|
+
const graphqlUri = process.env.GRAPHQL_URI;
|
|
74
|
+
const siteId = process.env.SITE_ID;
|
|
75
|
+
const tenantKey = process.env.TENANT_KEY;
|
|
76
|
+
const baseBrowseGraphqlUri = process.env.BASE_BROWSE_GRAPHQL_URI;
|
|
77
|
+
|
|
78
|
+
// require core packages after env values have been processed so they are set when imported
|
|
79
|
+
const errorHandlers = require('./express/error-handlers');
|
|
80
|
+
const express = require('./express');
|
|
81
|
+
const loadMore = require('./express/load-more');
|
|
82
|
+
const disabledFeatures = require('./middleware/disabled-features');
|
|
83
|
+
|
|
84
|
+
const app = express({
|
|
85
|
+
rootDir,
|
|
86
|
+
siteConfig,
|
|
87
|
+
coreConfig,
|
|
88
|
+
helmetConfig,
|
|
89
|
+
graphqlUri,
|
|
90
|
+
tenantKey,
|
|
91
|
+
siteId,
|
|
92
|
+
onAsyncBlockError,
|
|
93
|
+
onFatalError,
|
|
94
|
+
document,
|
|
95
|
+
components,
|
|
96
|
+
fragments,
|
|
97
|
+
sitePackage,
|
|
98
|
+
embeddedMediaHandlers,
|
|
99
|
+
sitemapsHeaders,
|
|
100
|
+
gqlCacheResponses,
|
|
101
|
+
gqlCacheSiteContext,
|
|
102
|
+
baseBrowseGraphqlUri,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
app.use(disabledFeatures());
|
|
106
|
+
|
|
107
|
+
// Await required services here...
|
|
108
|
+
if (isFn(onStart)) await onStart(app);
|
|
109
|
+
|
|
110
|
+
// Register load more after onStart to ensure userland middleware is available.
|
|
111
|
+
loadMore(app);
|
|
112
|
+
|
|
113
|
+
// Load website routes.
|
|
114
|
+
if (!isFn(routes)) throw new Error('A routes function is required.');
|
|
115
|
+
routes(app);
|
|
116
|
+
|
|
117
|
+
// Apply error handlers.
|
|
118
|
+
errorHandlers(app, {
|
|
119
|
+
template: errorTemplate,
|
|
120
|
+
redirectHandler,
|
|
121
|
+
onFatalError: onFatalError || onAsyncBlockError,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const server = http.createServer(app);
|
|
125
|
+
|
|
126
|
+
createTerminus(server, {
|
|
127
|
+
timeout: env.TERMINUS_TIMEOUT || timeout,
|
|
128
|
+
signals,
|
|
129
|
+
// Add health checks of services here...
|
|
130
|
+
healthChecks: {
|
|
131
|
+
[healthCheckPath]: async () => {
|
|
132
|
+
if (isFn(onHealthCheck)) return onHealthCheck();
|
|
133
|
+
return { ping: 'pong' };
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
onSignal: async () => {
|
|
137
|
+
// Stop required services here...
|
|
138
|
+
if (isFn(onSignal)) await onSignal();
|
|
139
|
+
},
|
|
140
|
+
onShutdown: async () => {
|
|
141
|
+
if (isFn(onShutdown)) await onShutdown();
|
|
142
|
+
},
|
|
143
|
+
beforeShutdown: async () => {
|
|
144
|
+
if (isFn(beforeShutdown)) await beforeShutdown();
|
|
145
|
+
const { TERMINUS_SHUTDOWN_DELAY } = env;
|
|
146
|
+
if (TERMINUS_SHUTDOWN_DELAY) await wait(TERMINUS_SHUTDOWN_DELAY);
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
return new Promise((res, rej) => {
|
|
151
|
+
server.listen(port, host, function listen(err) {
|
|
152
|
+
if (err) {
|
|
153
|
+
rej(err);
|
|
154
|
+
} else {
|
|
155
|
+
res(this);
|
|
156
|
+
if (process.send) {
|
|
157
|
+
process.send({
|
|
158
|
+
event: 'ready',
|
|
159
|
+
name: sitePackage.name,
|
|
160
|
+
siteId,
|
|
161
|
+
graphqlUri,
|
|
162
|
+
baseBrowseGraphqlUri,
|
|
163
|
+
location: `http://${exposedHost}:${exposedPort}`,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}).catch((e) => setImmediate(() => { throw e; }));
|
|
169
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { URLSearchParams } = require('url');
|
|
2
|
+
const { asObject } = require('@mindful-web/utils');
|
|
3
|
+
|
|
4
|
+
module.exports = ({ path, query } = {}) => {
|
|
5
|
+
const params = new URLSearchParams(asObject(query));
|
|
6
|
+
if (!`${params}`) return path;
|
|
7
|
+
const cleaned = path.replace(/^\/+/, '');
|
|
8
|
+
const isExternal = /^http/.test(cleaned);
|
|
9
|
+
|
|
10
|
+
// Must put a "fake" host in front of the path to properly parse.
|
|
11
|
+
const to = isExternal ? cleaned : `http://localhost/${cleaned}`;
|
|
12
|
+
const toUrl = new URL(to);
|
|
13
|
+
toUrl.searchParams.forEach((value, key) => params.set(key, value));
|
|
14
|
+
const origin = isExternal ? toUrl.origin : '';
|
|
15
|
+
return `${origin}${toUrl.pathname}?${params}`;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@mindful-web/marko-core/utils/build-marko-global');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('@mindful-web/marko-core/utils/default-value');
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { URL } = require('url');
|
|
2
|
+
|
|
3
|
+
const buildFacebookElement = ({
|
|
4
|
+
href,
|
|
5
|
+
lazy = true,
|
|
6
|
+
width,
|
|
7
|
+
showText,
|
|
8
|
+
}) => {
|
|
9
|
+
const params = {
|
|
10
|
+
href: decodeURIComponent(href),
|
|
11
|
+
...(lazy && { lazy: true }),
|
|
12
|
+
...(width && { width }),
|
|
13
|
+
...(showText && { 'show-text': true }),
|
|
14
|
+
};
|
|
15
|
+
const data = Object.keys(params).map((key) => `data-${key}="${params[key]}"`);
|
|
16
|
+
return `<div class="fb-post" ${data.join(' ')}></div><script async defer src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v3.2"></script>`;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const facebook = (url) => {
|
|
20
|
+
const pattern = /facebook\.com/i;
|
|
21
|
+
if (!pattern.test(url)) return null; // not a facebook URL.
|
|
22
|
+
|
|
23
|
+
const { href, host, searchParams } = new URL(url);
|
|
24
|
+
|
|
25
|
+
if (/facebook\.com\/plugins\//i.test(url)) {
|
|
26
|
+
// matches a plugin url, e.g. plugins/video.php plugins/post.php, etc
|
|
27
|
+
if (!searchParams.has('href')) return '<div></div>'; // no `href` query param found. remove.
|
|
28
|
+
// return facebook div element
|
|
29
|
+
return buildFacebookElement({
|
|
30
|
+
href: searchParams.get('href'),
|
|
31
|
+
showText: searchParams.get('show_text') === 'true',
|
|
32
|
+
// @todo determine if the requested width should be preserved
|
|
33
|
+
// width: searchParams.get('width'),
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
// after checking for facebook plugin URLs, treat all other facebook URLs as posts.
|
|
37
|
+
if (!pattern.test(host)) return null; // facebook.com appears somewhere else in the URL.
|
|
38
|
+
// return facebook div element
|
|
39
|
+
return buildFacebookElement({ href, showText: true });
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
*/
|
|
45
|
+
module.exports = (url) => {
|
|
46
|
+
// convert embeds, as they no longer support oembed without auth
|
|
47
|
+
const fbPost = facebook(url);
|
|
48
|
+
if (fbPost) return fbPost;
|
|
49
|
+
return null;
|
|
50
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const { buildImgixUrl } = require('@mindful-web/image');
|
|
2
|
+
|
|
3
|
+
const stringifyAttrs = (attrs) => Object.keys(attrs).reduce((arr, key) => {
|
|
4
|
+
const value = attrs[key];
|
|
5
|
+
if (value) arr.push(`${key}="${value}"`);
|
|
6
|
+
return arr;
|
|
7
|
+
}, []).join(' ');
|
|
8
|
+
|
|
9
|
+
const buildWrapperClass = ({ caption, credit }) => {
|
|
10
|
+
const classes = [];
|
|
11
|
+
if (caption) classes.push('image-with-caption');
|
|
12
|
+
if (credit) classes.push('image-with-credit');
|
|
13
|
+
return classes.join(' ');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
module.exports = (tag, { config } = {}, { lazyloadImages } = {}) => {
|
|
17
|
+
const lazyload = lazyloadImages == null ? config.lazyloadImages() : lazyloadImages;
|
|
18
|
+
const src = tag.get('src');
|
|
19
|
+
const alt = tag.get('alt');
|
|
20
|
+
const caption = tag.get('caption');
|
|
21
|
+
const credit = tag.get('credit');
|
|
22
|
+
const align = tag.get('align');
|
|
23
|
+
|
|
24
|
+
const width = tag.get('width');
|
|
25
|
+
const height = tag.get('height');
|
|
26
|
+
|
|
27
|
+
const wrapperClass = buildWrapperClass({ caption, credit });
|
|
28
|
+
|
|
29
|
+
const attrs = {
|
|
30
|
+
'data-embed-type': tag.type,
|
|
31
|
+
'data-embed-id': tag.id,
|
|
32
|
+
'data-embed-align': align,
|
|
33
|
+
...(wrapperClass && { class: wrapperClass }),
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const minWidth = 400;
|
|
37
|
+
const maxWidth = (align) ? minWidth : 700;
|
|
38
|
+
|
|
39
|
+
const maxSrcset = `${buildImgixUrl(src, { w: maxWidth })}, ${buildImgixUrl(src, { w: maxWidth, dpr: 2 })} 2x`;
|
|
40
|
+
|
|
41
|
+
const sources = [
|
|
42
|
+
{
|
|
43
|
+
srcset: lazyload ? null : maxSrcset,
|
|
44
|
+
'data-srcset': lazyload ? maxSrcset : null,
|
|
45
|
+
media: '(min-width: 576px)',
|
|
46
|
+
},
|
|
47
|
+
].map((source) => `<source ${stringifyAttrs(source)}>`).join('');
|
|
48
|
+
|
|
49
|
+
const minSrc = buildImgixUrl(src, { w: minWidth });
|
|
50
|
+
const minSrcset = `${buildImgixUrl(src, { w: minWidth, dpr: 2 })} 2x`;
|
|
51
|
+
|
|
52
|
+
const transparentImg = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
|
|
53
|
+
const imgAttrs = {
|
|
54
|
+
class: lazyload ? 'lazyload' : null,
|
|
55
|
+
src: lazyload ? transparentImg : minSrc,
|
|
56
|
+
srcset: lazyload ? null : minSrcset,
|
|
57
|
+
'data-src': lazyload ? minSrc : null,
|
|
58
|
+
'data-srcset': lazyload ? minSrcset : null,
|
|
59
|
+
'data-image-id': tag.id,
|
|
60
|
+
alt,
|
|
61
|
+
width: (width && height) ? minWidth : null,
|
|
62
|
+
height: (height && height) ? Math.round((height / width) * minWidth) : null,
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const captionElement = caption ? `<span class="caption">${caption}</span>` : '';
|
|
66
|
+
const creditElement = credit ? `<span class="credit">${credit}</span>` : '';
|
|
67
|
+
|
|
68
|
+
const img = `<img ${stringifyAttrs(imgAttrs)}>`;
|
|
69
|
+
const picture = `<picture>${sources}${img}${captionElement}${creditElement}</picture>`;
|
|
70
|
+
return `<span ${stringifyAttrs(attrs)}>${picture}</span>`;
|
|
71
|
+
};
|