Skip to content

Commit b9d1b31

Browse files
authored
Revert "Enable iframe embeds (#5)" (#6)
This reverts commit 7d470ee.
1 parent 7d470ee commit b9d1b31

27 files changed

+405
-506
lines changed

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@
66

77
A website documenting Webpack 5 Module Federation.
88

9-
#### _Set-up Locally_
10-
9+
#### *Set-up Locally*
1110
```bash
12-
#install dependencies & run dev server with yarn
11+
#install dependencies & run dev server with yarn
1312
yarn install
1413
yarn dev
1514

16-
#or with npm
15+
#or with npm
1716
npm install
1817
npm run dev
1918
```
20-
2119
This will start a dev server, navigate to localhost:3000 to check it out.

components/article-page/index.jsx

+4-5
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ export default function ArticlePage ({
3434
title,
3535
secondaryTitle,
3636
menuItems,
37-
secondaryMenuItems,
38-
isText = true
37+
secondaryMenuItems
3938
}) {
4039
return (
4140
<AppShell
@@ -54,14 +53,14 @@ export default function ArticlePage ({
5453
</Hero>
5554
)}
5655
>
57-
<Segment className={isText ? styles.articlePageContent : null} vertical>
58-
{isText ? (<Grid container stackable verticalAlign='middle' className='fb'>
56+
<Segment className={styles.articlePageContent} vertical>
57+
<Grid container stackable verticalAlign='middle' className='fb'>
5958
<Grid.Row>
6059
<Grid.Column width={16}>
6160
{children}
6261
</Grid.Column>
6362
</Grid.Row>
64-
</Grid>) : children}
63+
</Grid>
6564
</Segment>
6665
</AppShell>
6766
)

data/info.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
---
22
title: info page
3-
background_color: "#AEC4BE"
3+
background_color: '#AEC4BE'
44
---
5-
6-
## This blog was created using [TinaCMS](https://tinacms.org) & [NextJS](https://nextjs.org/)
5+
## This blog was created using [TinaCMS](https://tinacms.org) & [NextJS](https://nextjs.org/)
76

87
## To get started, read the TinaCMS [docs](https://tinacms.org/docs) or checkout the [repository](https://github.com/kendallstrautman/brevifolia-next-tinacms).
98

109
- ## Email: [[email protected]]
1110
- ## Twitter: [@tina_cms](https://twitter.com/tina_cms)
12-
- ## Github: [tinacms](https://github.com/tinacms/tinacms)
11+
- ## Github: [tinacms](https://github.com/tinacms/tinacms)

nav-items.js

+21-22
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,36 @@
88
const menuItems = {
99
menuItems: [
1010
{
11-
href: "/",
12-
children: "Home",
11+
href: '/',
12+
children: 'Home'
1313
},
1414
{
15-
href: "/blog/get-started",
16-
children: "Get Started",
15+
href: '/blog/get-started',
16+
children: 'Get Started'
1717
},
1818
{
19-
href:
20-
"https://medium.com/swlh/webpack-5-module-federation-a-game-changer-to-javascript-architecture-bcdd30e02669",
21-
children: "Learn More",
22-
rel: "noopener noreferrer",
23-
target: "blank",
19+
href: 'https://medium.com/swlh/webpack-5-module-federation-a-game-changer-to-javascript-architecture-bcdd30e02669',
20+
children: 'Learn More',
21+
rel: 'noopener noreferrer',
22+
target: 'blank'
2423
},
2524
{
26-
href: "/blog",
27-
children: "Blog",
25+
href: '/blog',
26+
children: 'Blog'
2827
},
2928
{
30-
href: "/videos",
31-
children: "Videos",
32-
},
29+
href: '/videos',
30+
children: 'Videos'
31+
}
3332
],
3433
secondaryMenuItems: [
3534
{
36-
href: "https://github.com/module-federation",
37-
children: "GitHub",
38-
rel: "noopener noreferrer",
39-
target: "blank",
40-
},
41-
],
42-
};
35+
href: 'https://github.com/module-federation',
36+
children: 'GitHub',
37+
rel: 'noopener noreferrer',
38+
target: 'blank'
39+
}
40+
]
41+
}
4342

44-
export default menuItems;
43+
export default menuItems

next.config.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// const ModuleFederationPlugin = require('webpack/lib/container/ModuleFederationPlugin');
22

3-
module.exports = {
3+
module.exports = ({
44
webpack: function (config) {
55
config.module.rules.push({
66
test: /\.md$/,
7-
use: "raw-loader",
8-
});
7+
use: 'raw-loader'
8+
})
99

1010
// config.plugins.push(new ModuleFederationPlugin({
1111
// name: 'federated_libraries',
@@ -22,6 +22,6 @@ module.exports = {
2222
// config.resolve.alias.buffer = 'buffer';
2323
// config.resolve.alias.path = 'path-browserify';
2424

25-
return config;
26-
},
27-
};
25+
return config
26+
}
27+
})

package.json

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,13 @@
1111
"start": "next start",
1212
"export": "next export",
1313
"deploy": "yarn build && yarn export",
14-
"forestry-preview": "next -p 8080 -H 0.0.0.0",
15-
"prettier": "prettier --write \"**/*.{js,json,md,ts,tsx}\"",
16-
"prettier:check": "prettier --list-different \"**/*.{js,json,md,ts,tsx}\""
14+
"forestry-preview": "next -p 8080 -H 0.0.0.0"
1715
},
1816
"dependencies": {
1917
"buffer": "^5.5.0",
2018
"gray-matter": "^4.0.2",
2119
"marksy": "^8.0.0",
2220
"next": "^9.3.3",
23-
"node-fetch": "^2.6.0",
2421
"oembed-parser": "^1.3.7",
2522
"path-browserify": "^1.0.1",
2623
"prism-themes": "^1.3.0",
@@ -32,11 +29,7 @@
3229
},
3330
"devDependencies": {
3431
"babel-plugin-prismjs": "^2.0.1",
35-
"dynamic-resource-hints": "^0.0.7",
36-
"intersection-observer": "^0.10.0",
37-
"prettier": "^2.0.5",
3832
"raw-loader": "^4.0.0",
39-
"react-intersection-observer": "^8.26.2",
4033
"sass": "^1.26.3"
4134
},
4235
"keywords": [

pages/_app.js

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import React from "react";
2-
import Head from "next/head";
3-
import "intersection-observer";
1+
import React from 'react'
2+
import Head from 'next/head'
43

5-
import "prism-themes/themes/prism-vs.css";
6-
import "semantic-ui-css/semantic.min.css";
4+
import 'prism-themes/themes/prism-vs.css'
5+
import 'semantic-ui-css/semantic.min.css'
76

8-
import config from "../data/config.json";
9-
import "../styles/bootstrap.css";
7+
import config from '../data/config.json'
8+
import '../styles/bootstrap.css'
109
const tracking = `
1110
function getUrlParams(search) {
1211
const hashes = search.slice(search.indexOf('?') + 1).split('&')
@@ -24,23 +23,23 @@ function getUrlParams(search) {
2423
gtag('config', 'UA-120967034-1');
2524
var redirect = getUrlParams(window.location.href).utm_medium
2625
if(redirect) window.location.replace(redirect)
27-
`;
28-
function MyApp({ Component, pageProps }) {
26+
`
27+
function MyApp ({ Component, pageProps }) {
2928
return (
3029
<>
3130
<Head>
3231
<title>{config.title}</title>
33-
<script src="https://www.googletagmanager.com/gtag/js?id=UA-120967034-1" />
32+
<script src='https://www.googletagmanager.com/gtag/js?id=UA-120967034-1' />
3433

35-
<meta name="description" content={config.description} />
34+
<meta name='description' content={config.description} />
3635
<script dangerouslySetInnerHTML={{ __html: tracking }} />
37-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
36+
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
3837
</Head>
3938

4039
<Component {...pageProps} />
4140
</>
42-
);
41+
)
4342
}
4443

45-
export default MyApp;
44+
export default MyApp
4645
// https://federated-libraries-next.now.sh/?utm_source=ModuleFederationExamples&utm_medium=https://github.com/sponsors/ScriptedAlchemy&utm_campaign=sponsor_link

pages/blog/[slug].js

+50-40
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,70 @@
1-
import * as React from "react";
2-
import Head from "next/head";
3-
import Prism from "prismjs";
4-
import matter from "gray-matter";
5-
import marksy from "marksy/jsx";
1+
import * as React from 'react'
2+
import Head from 'next/head'
3+
import Prism from 'prismjs'
4+
import matter from 'gray-matter'
5+
import marksy from 'marksy/jsx'
66

7-
import ArticlePage from "../../components/article-page";
8-
import navItems from "../../nav-items";
7+
import ArticlePage from '../../components/article-page'
8+
import navItems from '../../nav-items'
99

10-
import config from "../../data/config.json";
10+
import config from '../../data/config.json'
11+
12+
export function getStaticPaths () {
13+
const ctx = require.context('../../posts', true, /\.md$/)
14+
15+
const paths = ctx.keys().map((key, index) => {
16+
const slug = key.split('/')[1].replace(/ /g, '-').slice(0, -3).trim()
17+
return { params: { slug } }
18+
})
19+
20+
return {
21+
paths,
22+
fallback: false
23+
}
24+
}
25+
26+
export async function getStaticProps ({ params: { slug } }) {
27+
const markdown = await import(`../../posts/${slug}.md`)
28+
const { content, data: { date, ...rest } } = matter(markdown.default)
29+
30+
return {
31+
props: {
32+
content,
33+
data: {
34+
...rest,
35+
date: date.toISOString().substring(0, 10)
36+
}
37+
}
38+
}
39+
}
1140

1241
const compile = marksy({
1342
createElement: React.createElement,
14-
highlight(language, code) {
15-
return Prism.highlight(code, Prism.languages[language], language);
16-
},
17-
});
18-
19-
export default function BlogPostPage({ content, data }) {
20-
const body = compile(content);
21-
const embeddedArticle = data.medium_link ? (
22-
<iframe
23-
id="medium-content"
24-
referrerPolicy="no-referrer"
25-
width="100%"
26-
style={{ height: "200vh", marginTop: "-50px" }}
27-
frameBorder={0}
28-
src={data.medium_link}
29-
></iframe>
30-
) : null;
43+
highlight (language, code) {
44+
return Prism.highlight(code, Prism.languages[language], language)
45+
}
46+
})
47+
48+
export default function BlogPostPage ({ content, data }) {
49+
const body = compile(content)
50+
3151
return (
3252
<>
3353
<Head>
34-
<title>
35-
{data.title} | {config.title}
36-
</title>
37-
{data.secondary_title && (
38-
<meta name="description" content={data.secondary_title}></meta>
39-
)}
54+
<title>{data.title} | {config.title}</title>
55+
{data.secondary_title && <meta name='description' content={data.secondary_title} />}
4056
</Head>
4157

4258
<ArticlePage
4359
menuItems={navItems.menuItems}
4460
secondaryMenuItems={navItems.secondaryMenuItems}
4561
title={data.title}
4662
secondaryTitle={data.secondary_title}
47-
isText={!embeddedArticle}
4863
>
49-
<article id="frame" className="center-images">
50-
{embeddedArticle ? embeddedArticle : body.tree}
64+
<article className='center-images'>
65+
{body.tree}
5166
</article>
5267
</ArticlePage>
5368
</>
54-
);
69+
)
5570
}
56-
BlogPostPage.getInitialProps = async function (ctx) {
57-
const { slug } = ctx.query;
58-
const content = await import(`../../posts/${slug}.md`);
59-
return matter(content.default);
60-
};

pages/blog/blog.module.css

-6
This file was deleted.

0 commit comments

Comments
 (0)