Skip to content

Commit

Permalink
Refactor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jensmtg committed Jul 16, 2022
1 parent 60f5193 commit ab9816b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 192 deletions.
18 changes: 8 additions & 10 deletions src/InfluxReactComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@ import { MarkdownRenderer } from 'obsidian';
import InfluxFile, { InlinkingFile } from './InfluxFile';

interface InfluxReactComponentProps { influxFile: InfluxFile }
type ExtendedInlinkingFile = {
type ExtendedInlinkingFile = {
inlinkingFile: InlinkingFile;
titleInnerHTML: string;
inner: HTMLDivElement[];
}

export default function InfluxReactComponent (props: InfluxReactComponentProps) {
export default function InfluxReactComponent(props: InfluxReactComponentProps) {

const { influxFile } = props

console.log('inf', influxFile)

const [components, setComponents] = React.useState(null)

const renderMarkdownBlock = async (md: string) => {
Expand All @@ -32,7 +30,7 @@ export default function InfluxReactComponent (props: InfluxReactComponentProps)
const titleAsMd = await renderMarkdownBlock(inlinkingFile.title)
const titleInnerHTML = titleAsMd.innerHTML.slice(3, -4)

const extended : ExtendedInlinkingFile = {
const extended: ExtendedInlinkingFile = {
inlinkingFile: inlinkingFile,
titleInnerHTML: titleInnerHTML,
inner: await Promise.all(inlinkingFile.contextSummaries.map(async (summary) => await renderMarkdownBlock(summary))),
Expand Down Expand Up @@ -60,11 +58,11 @@ export default function InfluxReactComponent (props: InfluxReactComponentProps)
{components.map((extended: ExtendedInlinkingFile) => {

return <div key={extended.inlinkingFile.file.basename}>
<h2>{extended.inlinkingFile.file.basename} &nbsp;
<span
style={{opacity: 0.5}}
dangerouslySetInnerHTML={{ __html: extended.titleInnerHTML }}
/>
<h2>{extended.inlinkingFile.file.basename} &nbsp;
<span
style={{ opacity: 0.5 }}
dangerouslySetInnerHTML={{ __html: extended.titleInnerHTML }}
/>
</h2>
{extended.inner.map((div: HTMLDivElement, i: number) => (
<div
Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Plugin, Vault, Workspace, App, MarkdownPostProcessorContext, PluginSettingTab, Setting } from 'obsidian';
import { Plugin, Vault, Workspace, MarkdownPostProcessorContext } from 'obsidian';
import * as React from "react";
import { createRoot } from "react-dom/client";
import InfluxReactComponent from './InfluxReactComponent';
Expand Down
181 changes: 0 additions & 181 deletions src/utils.tsx

This file was deleted.

0 comments on commit ab9816b

Please sign in to comment.