Skip to content

Commit

Permalink
fix: add dateArchived to the exposed variable in the article template
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed May 19, 2023
1 parent bca3f75 commit e619009
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface Article {
readingProgressPercent: number
isArchived: boolean
wordsCount?: number
dateArchived?: string
}

export interface Label {
Expand Down Expand Up @@ -120,6 +121,10 @@ export const getOmnivoreArticles = async (
content
publishedAt
readAt
isArchived
readingProgressPercent
wordsCount
dateArchived
highlights {
id
quote
Expand All @@ -135,9 +140,6 @@ export const getOmnivoreArticles = async (
labels {
name
}
isArchived
readingProgressPercent
wordsCount
}
}
pageInfo {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ const fetchOmnivore = async (inBackground = false) => {
parseDateTime(syncAt).toISO(),
endpoint
)
for (const deletedArticle of deletedArticles) {
for await (const deletedArticle of deletedArticles) {
if (!isSinglePage) {
pageName = renderPageName(
deletedArticle,
Expand Down
9 changes: 7 additions & 2 deletions src/settings/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export type ArticleView =
state: string
wordsCount?: number
readLength?: number
dateArchived?: string
}
| FunctionMap

Expand Down Expand Up @@ -138,6 +139,9 @@ const createArticleView = (
const readLength = wordsCount
? Math.round(Math.max(1, wordsCount / 235))
: undefined
const dateArchived = article.dateArchived
? formatDate(new Date(article.dateArchived), preferredDateFormat)
: undefined
return {
title: article.title,
omnivoreUrl: `https://omnivore.app/me/${article.slug}`,
Expand All @@ -156,6 +160,7 @@ const createArticleView = (
state: getArticleState(article),
wordsCount,
readLength,
dateArchived,
...functionMap,
}
}
Expand Down Expand Up @@ -196,9 +201,9 @@ export const renderPageName = (
preferredDateFormat: string
) => {
const date = formatDate(new Date(article.savedAt), preferredDateFormat)
// replace slashes and colon with dash in the title to prevent creating subpages
// replace slash with dash in the title to prevent creating subpages
// since there is no way to escape slashes in logseq
const title = article.title.replace(/[/:]/g, '-')
const title = article.title.replace(/\//g, '-')

const renderedPageName = Mustache.render(pageName, {
title,
Expand Down

0 comments on commit e619009

Please sign in to comment.