Skip to content

Commit

Permalink
drop alias and use relative path
Browse files Browse the repository at this point in the history
  • Loading branch information
zernonia committed May 9, 2023
1 parent 2256514 commit ed89c67
Show file tree
Hide file tree
Showing 31 changed files with 335 additions and 340 deletions.
4 changes: 0 additions & 4 deletions build.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ export default defineBuildConfig({
{ builder: "mkdist", input: "./src/", format: "cjs", ext: "js" },
],

alias: {
"@": resolve(__dirname, "./src"),
},

declaration: true,
clean: true,
});
12 changes: 6 additions & 6 deletions src/blocks/bookmark.vue
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import { getTextContent } from "@/lib/utils"
import NotionTextRenderer from "@/blocks/helpers/text-renderer.vue"
import { useNotionBlock, defineNotionProps } from "../lib/blockable";
import { getTextContent } from "../lib/utils";
import NotionTextRenderer from "../blocks/helpers/text-renderer.vue";
const props = defineProps({ ...defineNotionProps })
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { f, properties, title, description, pass } = useNotionBlock(props)
const { f, properties, title, description, pass } = useNotionBlock(props);
</script>

<script lang="ts">
export default {
name: "NotionBookmark",
}
};
</script>

<template>
Expand Down
14 changes: 7 additions & 7 deletions src/blocks/callout.vue
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import NotionPageIcon from "@/blocks/helpers/page-icon.vue"
import NotionTextRenderer from "@/blocks/helpers/text-renderer.vue"
import NotionRenderer from "@/components/notion-renderer.vue"
import { useNotionBlock, defineNotionProps } from "../lib/blockable";
import NotionPageIcon from "../blocks/helpers/page-icon.vue";
import NotionTextRenderer from "../blocks/helpers/text-renderer.vue";
import NotionRenderer from "../components/notion-renderer.vue";
const props = defineProps({ ...defineNotionProps })
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { pass, title, blockColorClass, block } = useNotionBlock(props)
const { pass, title, blockColorClass, block } = useNotionBlock(props);
</script>

<script lang="ts">
export default {
name: "NotionCallout",
}
};
</script>

<template>
Expand Down
94 changes: 47 additions & 47 deletions src/blocks/code.vue
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
<script setup lang="ts">
import Prism from "prismjs"
import PrismBlock from "./helpers/prism.vue"
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import { computed } from "vue"
import Prism from "prismjs";
import PrismBlock from "./helpers/prism.vue";
import { useNotionBlock, defineNotionProps } from "../lib/blockable";
import { computed } from "vue";
import "prismjs/components/prism-markup-templating"
import "prismjs/components/prism-markup"
import "prismjs/components/prism-bash"
import "prismjs/components/prism-c"
import "prismjs/components/prism-cpp"
import "prismjs/components/prism-csharp"
import "prismjs/components/prism-docker"
import "prismjs/components/prism-java"
import "prismjs/components/prism-js-templates"
import "prismjs/components/prism-typescript"
import "prismjs/components/prism-coffeescript"
import "prismjs/components/prism-diff"
import "prismjs/components/prism-git"
import "prismjs/components/prism-go"
import "prismjs/components/prism-graphql"
import "prismjs/components/prism-handlebars"
import "prismjs/components/prism-json"
import "prismjs/components/prism-less"
import "prismjs/components/prism-makefile"
import "prismjs/components/prism-markdown"
import "prismjs/components/prism-objectivec"
import "prismjs/components/prism-ocaml"
import "prismjs/components/prism-python"
import "prismjs/components/prism-reason"
import "prismjs/components/prism-rust"
import "prismjs/components/prism-sass"
import "prismjs/components/prism-scss"
import "prismjs/components/prism-solidity"
import "prismjs/components/prism-sql"
import "prismjs/components/prism-stylus"
import "prismjs/components/prism-swift"
import "prismjs/components/prism-wasm"
import "prismjs/components/prism-yaml"
import "prismjs/components/prism-markup-templating";
import "prismjs/components/prism-markup";
import "prismjs/components/prism-bash";
import "prismjs/components/prism-c";
import "prismjs/components/prism-cpp";
import "prismjs/components/prism-csharp";
import "prismjs/components/prism-docker";
import "prismjs/components/prism-java";
import "prismjs/components/prism-js-templates";
import "prismjs/components/prism-typescript";
import "prismjs/components/prism-coffeescript";
import "prismjs/components/prism-diff";
import "prismjs/components/prism-git";
import "prismjs/components/prism-go";
import "prismjs/components/prism-graphql";
import "prismjs/components/prism-handlebars";
import "prismjs/components/prism-json";
import "prismjs/components/prism-less";
import "prismjs/components/prism-makefile";
import "prismjs/components/prism-markdown";
import "prismjs/components/prism-objectivec";
import "prismjs/components/prism-ocaml";
import "prismjs/components/prism-python";
import "prismjs/components/prism-reason";
import "prismjs/components/prism-rust";
import "prismjs/components/prism-sass";
import "prismjs/components/prism-scss";
import "prismjs/components/prism-solidity";
import "prismjs/components/prism-sql";
import "prismjs/components/prism-stylus";
import "prismjs/components/prism-swift";
import "prismjs/components/prism-wasm";
import "prismjs/components/prism-yaml";
const props = defineProps({ overrideLang: String, overrideLangClass: String, ...defineNotionProps })
const props = defineProps({ overrideLang: String, overrideLangClass: String, ...defineNotionProps });
//@ts-ignore
const { properties } = useNotionBlock(props)
const { properties } = useNotionBlock(props);
const lang = computed(() => {
return props.overrideLang || properties.value?.language?.[0]?.[0]?.toLowerCase()
})
return props.overrideLang || properties.value?.language?.[0]?.[0]?.toLowerCase();
});
const langClass = computed(() => {
return props.overrideLangClass || `language-${lang.value}`
})
return props.overrideLangClass || `language-${lang.value}`;
});
const supported = computed(() => {
return lang.value ? Prism?.languages[lang.value] : false
})
return lang.value ? Prism?.languages[lang.value] : false;
});
const computedSlot = computed(() => properties.value?.title.map((i) => i?.[0]).join(""))
const computedSlot = computed(() => properties.value?.title.map((i) => i?.[0]).join(""));
</script>

<script lang="ts">
export default {
name: "NotionCode",
}
};
</script>

<template>
Expand Down
42 changes: 21 additions & 21 deletions src/blocks/decorator.vue
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import NotionKatek from "@/blocks/helpers/katex.vue"
import { computed, PropType } from "vue"
import { useNotionBlock, defineNotionProps } from "../lib/blockable";
import NotionKatek from "../blocks/helpers/katex.vue";
import { computed, PropType } from "vue";
const props = defineProps({
content: Object as PropType<string[] | string>,
...defineNotionProps,
})
});
//@ts-ignore
const { props: blockProps, pass, type, hasPageLinkOptions, pageLinkProps } = useNotionBlock(props)
const { props: blockProps, pass, type, hasPageLinkOptions, pageLinkProps } = useNotionBlock(props);
const text = computed(() => props.content?.[0])
const decorators = computed(() => props.content?.[1] || [])
const decoratorKey = computed(() => decorators.value?.[0]?.[0])
const decoratorValue = computed(() => decorators.value?.[0]?.[1])
const text = computed(() => props.content?.[0]);
const decorators = computed(() => props.content?.[1] || []);
const decoratorKey = computed(() => decorators.value?.[0]?.[0]);
const decoratorValue = computed(() => decorators.value?.[0]?.[1]);
const unappliedDecorators = computed(() => {
const clonedDecorators = JSON.parse(JSON.stringify(decorators.value || []))
clonedDecorators.shift() // remove applied decorator
return clonedDecorators
})
const nextContent = computed(() => [text.value, unappliedDecorators.value])
const isPageLink = computed(() => text.value === "")
const isInlinePageLink = computed(() => decoratorValue.value?.[0] === "/")
const clonedDecorators = JSON.parse(JSON.stringify(decorators.value || []));
clonedDecorators.shift(); // remove applied decorator
return clonedDecorators;
});
const nextContent = computed(() => [text.value, unappliedDecorators.value]);
const isPageLink = computed(() => text.value === "");
const isInlinePageLink = computed(() => decoratorValue.value?.[0] === "/");
const pageLinkTitle = computed(
() => blockProps.blockMap?.[decoratorValue.value]?.value?.properties?.title?.[0]?.[0] || "link"
)
);
const target = computed(() => {
if (type.value === "page") {
return blockProps.pageLinkTarget
return blockProps.pageLinkTarget;
}
return blockProps.textLinkTarget
})
return blockProps.textLinkTarget;
});
</script>

<script lang="ts">
export default {
name: "NotionDecorator",
}
};
</script>

<template>
Expand Down
16 changes: 8 additions & 8 deletions src/blocks/equation.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import NotionCode from "./code.vue"
import NotionKatek from "@/blocks/helpers/katex.vue"
import { computed } from "vue"
import { useNotionBlock, defineNotionProps } from "../lib/blockable";
import NotionCode from "./code.vue";
import NotionKatek from "../blocks/helpers/katex.vue";
import { computed } from "vue";
const props = defineProps({ ...defineNotionProps })
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { properties, pass } = useNotionBlock(props)
const { properties, pass } = useNotionBlock(props);
const equation = computed(() => properties.value.title?.[0]?.[0])
const equation = computed(() => properties.value.title?.[0]?.[0]);
</script>

<script lang="ts">
export default {
name: "NotionEquation",
}
};
</script>

<template>
Expand Down
6 changes: 3 additions & 3 deletions src/blocks/header.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable";
import NotionHeaderRenderer from "@/blocks/helpers/header-renderer.vue";
import NotionRenderer from "@/components/notion-renderer.vue";
import { useNotionBlock, defineNotionProps } from "../lib/blockable";
import NotionHeaderRenderer from "../blocks/helpers/header-renderer.vue";
import NotionRenderer from "../components/notion-renderer.vue";
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
Expand Down
20 changes: 10 additions & 10 deletions src/blocks/helpers/asset.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<script setup lang="ts">
import { defineNotionProps, useNotionBlock } from "@/lib/blockable"
import { computed, StyleValue } from "vue"
import { defineNotionProps, useNotionBlock } from "../../lib/blockable";
import { computed, StyleValue } from "vue";
const props = defineProps({ ...defineNotionProps })
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { properties, f, format } = useNotionBlock(props)
const { properties, f, format } = useNotionBlock(props);
const src = computed(() => {
return f.value.display_source ?? properties.value?.source?.[0]
})
return f.value.display_source ?? properties.value?.source?.[0];
});
const aspectRatioStyle = computed(() => {
let aspectRatio =
f.value.block_width == 1 || f.value.block_height == 1
? 1 / f.value.block_aspect_ratio
: `${f.value.block_width} / ${f.value.block_height} `
: `${f.value.block_width} / ${f.value.block_height} `;
return {
width: format.value.block_full_width
Expand All @@ -26,14 +26,14 @@ const aspectRatioStyle = computed(() => {
maxWidth: "100%",
position: "relative",
aspectRatio: f.value.block_height == 1 ? aspectRatio : undefined,
} as StyleValue
})
} as StyleValue;
});
</script>

<script lang="ts">
export default {
name: "NotionAsset",
}
};
</script>

<template>
Expand Down
16 changes: 8 additions & 8 deletions src/blocks/helpers/figure.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import NotionAsset from "@/blocks/helpers/asset.vue"
import NotionImage from "@/blocks/helpers/image.vue"
import NotionGoogleDrive from "@/blocks/helpers/google-drive.vue"
import NotionTextRenderer from "@/blocks/helpers/text-renderer.vue"
import { useNotionBlock, defineNotionProps } from "../../lib/blockable";
import NotionAsset from "../../blocks/helpers/asset.vue";
import NotionImage from "../../blocks/helpers/image.vue";
import NotionGoogleDrive from "../../blocks/helpers/google-drive.vue";
import NotionTextRenderer from "../../blocks/helpers/text-renderer.vue";
const props = defineProps({ ...defineNotionProps })
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { pass, width, caption, isType } = useNotionBlock(props)
const { pass, width, caption, isType } = useNotionBlock(props);
</script>

<script lang="ts">
export default {
name: "NotionFigure",
}
};
</script>
<template>
<figure class="notion-asset-wrapper" :style="[isType('image') ? 'width:100%' : '']">
Expand Down
28 changes: 14 additions & 14 deletions src/blocks/helpers/google-drive.vue
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
<script setup lang="ts">
import { useNotionBlock, defineNotionProps } from "@/lib/blockable"
import { computed } from "vue"
import { useTimeAgo } from "@vueuse/core"
import { useNotionBlock, defineNotionProps } from "../../lib/blockable";
import { computed } from "vue";
import { useTimeAgo } from "@vueuse/core";
const props = defineProps({ ...defineNotionProps })
const props = defineProps({ ...defineNotionProps });
//@ts-ignore
const { format, block, hasPageLinkOptions, pageLinkProps } = useNotionBlock(props)
const { format, block, hasPageLinkOptions, pageLinkProps } = useNotionBlock(props);
const properties = computed(() => format.value.drive_properties)
const properties = computed(() => format.value.drive_properties);
const constructThumbnail = (src?: string) => {
if (!src) return
if (!src) return;
const q = new URLSearchParams({
table: "block",
id: block.value.value.id,
cache: "v2",
})
return "https://www.notion.so/image/" + encodeURIComponent(src) + "?" + q
}
});
return "https://www.notion.so/image/" + encodeURIComponent(src) + "?" + q;
};
const constructDomain = (src?: string) => {
if (!src) return
return new URL(src).hostname
}
if (!src) return;
return new URL(src).hostname;
};
</script>

<script lang="ts">
export default {
name: "NotionGoogleDrive",
}
};
</script>

<template>
Expand Down
Loading

0 comments on commit ed89c67

Please sign in to comment.