[packages][m]: mv @flowershow/remark-embed here
This commit is contained in:
parent
e32332ac84
commit
395e072ee5
4
packages/remark-embed/.babelrc
Normal file
4
packages/remark-embed/.babelrc
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"presets": ["@babel/preset-env"],
|
||||
"plugins": ["@babel/plugin-transform-runtime"]
|
||||
}
|
||||
18
packages/remark-embed/.eslintrc.json
Normal file
18
packages/remark-embed/.eslintrc.json
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"extends": ["../../.eslintrc.json"],
|
||||
"ignorePatterns": ["!**/*"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.ts", "*.tsx"],
|
||||
"rules": {}
|
||||
},
|
||||
{
|
||||
"files": ["*.js", "*.jsx"],
|
||||
"rules": {}
|
||||
}
|
||||
]
|
||||
}
|
||||
3
packages/remark-embed/README.md
Normal file
3
packages/remark-embed/README.md
Normal file
@ -0,0 +1,3 @@
|
||||
# @flowershow/remark-embed
|
||||
|
||||
Converts Youtube link surrounded by newlines in markdown to embedded iframe
|
||||
16
packages/remark-embed/jest.config.ts
Normal file
16
packages/remark-embed/jest.config.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/* eslint-disable */
|
||||
export default {
|
||||
displayName: "remark-embed",
|
||||
preset: "../../jest.preset.js",
|
||||
globals: {
|
||||
"ts-jest": {
|
||||
tsconfig: "<rootDir>/tsconfig.spec.json",
|
||||
},
|
||||
},
|
||||
testEnvironment: "node",
|
||||
transform: {
|
||||
"^.+\\.[tj]sx?$": "ts-jest",
|
||||
},
|
||||
moduleFileExtensions: ["ts", "tsx", "js", "jsx"],
|
||||
coverageDirectory: "../../coverage/packages/remark-embed",
|
||||
};
|
||||
36
packages/remark-embed/package.json
Normal file
36
packages/remark-embed/package.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@flowershow/remark-embed",
|
||||
"version": "1.0.0",
|
||||
"description": "Converts youtube link in mdx to an iframe embed",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/flowershow/flowershow.git",
|
||||
"directory": "packages/remark-embed"
|
||||
},
|
||||
"keywords": [
|
||||
"remark",
|
||||
"remark-plugin",
|
||||
"markdown",
|
||||
"obsidian"
|
||||
],
|
||||
"author": "Rufus Pollock",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/flowershow/flowershow/issues"
|
||||
},
|
||||
"homepage": "https://github.com/flowershow/flowershow#readme",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"unist-util-visit": "^4.1.1"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
61
packages/remark-embed/project.json
Normal file
61
packages/remark-embed/project.json
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "remark-embed",
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"sourceRoot": "packages/remark-embed/src",
|
||||
"projectType": "library",
|
||||
"targets": {
|
||||
"lint": {
|
||||
"executor": "@nrwl/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["packages/remark-embed/**/*.ts"]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"executor": "@nrwl/jest:jest",
|
||||
"outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
|
||||
"options": {
|
||||
"jestConfig": "packages/remark-embed/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
}
|
||||
},
|
||||
"build": {
|
||||
"executor": "@nrwl/web:rollup",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"entryFile": "packages/remark-embed/src/index.ts",
|
||||
"outputPath": "packages/remark-embed/dist",
|
||||
"compiler": "babel",
|
||||
"tsConfig": "packages/remark-embed/tsconfig.lib.json",
|
||||
"project": "packages/remark-embed/package.json",
|
||||
"format": ["esm", "cjs"],
|
||||
"external": ["unist-util-visit"],
|
||||
"generateExportsField": true,
|
||||
"assets": [
|
||||
{
|
||||
"glob": "packages/remark-embed/README.md",
|
||||
"input": ".",
|
||||
"output": "."
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"publish:dry": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"commands": ["npm publish --dry-run"],
|
||||
"parallel": false,
|
||||
"cwd": "packages/remark-embed/dist"
|
||||
}
|
||||
},
|
||||
"publish": {
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"commands": ["npm publish"],
|
||||
"parallel": false,
|
||||
"cwd": "packages/remark-embed/dist"
|
||||
}
|
||||
}
|
||||
},
|
||||
"tags": []
|
||||
}
|
||||
1
packages/remark-embed/src/index.ts
Normal file
1
packages/remark-embed/src/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export { default } from "./lib/remark-embed";
|
||||
49
packages/remark-embed/src/lib/remark-embed.ts
Normal file
49
packages/remark-embed/src/lib/remark-embed.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import { visit } from "unist-util-visit";
|
||||
|
||||
function transformer(tree) {
|
||||
visit(tree, "paragraph", (node) => {
|
||||
visit(node, "text", (textNode) => {
|
||||
if (
|
||||
textNode.value.includes("https://www.youtube.com") &&
|
||||
!textNode.value.includes("\n")
|
||||
) {
|
||||
const urlSplit = textNode.value.split(/[=&]+/);
|
||||
const iframeUrl = `https://www.youtube.com/embed/${urlSplit[1]}`;
|
||||
Object.assign(node, {
|
||||
...node,
|
||||
type: "element",
|
||||
data: {
|
||||
hProperties: {
|
||||
style: "position:relative;padding-bottom:56.25%",
|
||||
},
|
||||
},
|
||||
children: [
|
||||
{
|
||||
...textNode,
|
||||
type: "element",
|
||||
tagName: "iframe",
|
||||
data: {
|
||||
hName: "iframe",
|
||||
hProperties: {
|
||||
style:
|
||||
"position:absolute;top:0;left:0;width:100%;height:100%",
|
||||
src: iframeUrl,
|
||||
allowfullscreen: true,
|
||||
frameborder: "0",
|
||||
allow:
|
||||
"accelerometer autoplay clipboard-write encrypted-media gyroscope picture-in-picture",
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function attacher() {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
export default attacher;
|
||||
13
packages/remark-embed/tsconfig.json
Normal file
13
packages/remark-embed/tsconfig.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.lib.json"
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
15
packages/remark-embed/tsconfig.lib.json
Normal file
15
packages/remark-embed/tsconfig.lib.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"target": "es2020",
|
||||
"module": "es2020",
|
||||
"types": ["node"],
|
||||
"moduleResolution": "node",
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"skipLibCheck": true
|
||||
},
|
||||
"exclude": ["**/*.spec.ts", "**/*.test.ts"],
|
||||
"include": ["src/**/*.ts"]
|
||||
}
|
||||
21
packages/remark-embed/tsconfig.spec.json
Normal file
21
packages/remark-embed/tsconfig.spec.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"module": "es2020",
|
||||
"moduleResolution": "node",
|
||||
"types": ["jest", "node"]
|
||||
},
|
||||
"include": [
|
||||
"jest.config.ts",
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.ts",
|
||||
"**/*.test.tsx",
|
||||
"**/*.spec.tsx",
|
||||
"**/*.test.js",
|
||||
"**/*.spec.js",
|
||||
"**/*.test.jsx",
|
||||
"**/*.spec.jsx",
|
||||
"**/*.d.ts"
|
||||
]
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user