Skip to content
This repository has been archived by the owner on Jan 27, 2022. It is now read-only.

Commit

Permalink
Implement display function for links
Browse files Browse the repository at this point in the history
  • Loading branch information
piascikj committed Jan 4, 2021
1 parent 5fd8be0 commit 26999a1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion dist/lib/imdone-vue-lib.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/lib/imdone-vue-lib.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "imdone-vue-lib",
"version": "0.7.4",
"version": "0.7.5",
"description": "imdone vue components",
"author": "Jesse <[email protected]>",
"main": "dist/lib/imdone-vue-lib.min.js",
Expand Down
22 changes: 16 additions & 6 deletions src/components/card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,23 @@ export default {
let links = []
if (!this.task) return links
const frontMatter = {...this.task.frontMatter}
const { encodedText, encodedMD } = this.description
const frontMatterCopy = {props: {}, ...frontMatter}
frontMatterCopy.props.encodedText = encodedText
frontMatterCopy.props.encodedMD = encodedMD
const task = {...this.task, frontMatter: frontMatterCopy}
if (frontMatter && frontMatter.links) {
links = frontMatter.links.map(({pack, icon, title, href, action}) => {
const { encodedText, encodedMD } = this.description
const frontMatterCopy = {props: {}, ...frontMatter}
frontMatterCopy.props.encodedText = encodedText
frontMatterCopy.props.encodedMD = encodedMD
const task = {...this.task, frontMatter: frontMatterCopy}
links = frontMatter.links.filter(({display}) => {
if (!display) return true
try {
const func = display
return func.apply({...taskTextUtils.getTaskProperties(this.task), ...taskTextUtils.description(this.task)})
} catch (e) {
console.error(e)
}
return false
})
.map(({pack, icon, title, href, action}) => {
href = taskTextUtils.formatDescription(task, href).description
title = taskTextUtils.formatDescription(task, title).description
return {pack, icon, title, href, action}
Expand Down
10 changes: 5 additions & 5 deletions src/utils/task-text-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function getTaskProperties (task) {
const frontMatterComputed = _.get(task, 'frontMatter.computed') || {}
const props = {...frontMatterProps, content: CONTENT_TOKEN}
const computed = {...frontMatterComputed}
const taskProps = _.pick(task, 'progress', 'line', 'list', 'source', 'due', 'created', 'completed', 'tags', 'context', 'meta', 'allTags', 'allContext', 'allMeta')
const taskProps = _.pick(task, 'text', 'description', 'progress', 'line', 'list', 'source', 'due', 'created', 'completed', 'tags', 'context', 'meta', 'allTags', 'allContext', 'allMeta')
try {
for (let [key, value] of Object.entries(computed)) {
let computedValue = value.toString()
Expand Down Expand Up @@ -137,9 +137,8 @@ export default {
encodedMD: ''
}
}
let {description} = formatDescription(task, getCardMarkdown(task, lines).content, true)
let {encodedText, encodedMD} = formatDescription(task, getCardMarkdown(task).content, true)
const html = md.render(description)
let {encodedText, encodedMD, description} = formatDescription(task, getCardMarkdown(task).content, true)
const html = md.render(formatDescription(task, getCardMarkdown(task, lines).content, true).description)
const $ = cheerio.load(html)

$('a').each(function () {
Expand Down Expand Up @@ -182,7 +181,8 @@ export default {
return {
html: $.html(),
encodedText,
encodedMD
encodedMD,
markdown: description
}
},
formatText (text, data) {
Expand Down

0 comments on commit 26999a1

Please sign in to comment.