Skip to content

Commit

Permalink
feat(banner): disable auto image
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyurec committed Aug 3, 2022
1 parent 9a724cf commit 2cd754d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Logseq banners plugin</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
</head>
<body>
<div id="app"></div>
Expand Down
27 changes: 14 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ let oldWidgetsConfig: WidgetsConfig;
let isWidgetsCustomHTMLChanged: boolean;
let timeout: number;
let hidePluginProps: boolean;
let defaultPageBannerAuto: boolean;
// let defaultPageBannerAuto: boolean;

const pluginPageProps: Array<string> = ["banner", "banner-align","page-icon", "icon"];

Expand Down Expand Up @@ -196,13 +196,13 @@ const settingsArray: SettingSchemaDesc[] = [
//@ts-expect-error
type: "heading"
},
{
key: "defaultPageBannerAuto",
title: "",
type: "boolean",
description: "(experimentral) Autogenerate banner image URL according to the page tile",
default: "false",
},
// {
// key: "defaultPageBannerAuto",
// title: "",
// type: "boolean",
// description: "(experimentral) Autogenerate banner image URL according to the page tile",
// default: "false",
// },
{
key: "customPropsConfig",
title: "Advanced custom pages banners and icons config",
Expand Down Expand Up @@ -260,7 +260,7 @@ const readPluginSettings = () => {
if (logseq.settings) {
({
hidePluginProps,
defaultPageBannerAuto,
// defaultPageBannerAuto,
widgetsEnabled: widgetsConfig.enabled,
widgetsOnlyOnJournals: widgetsConfig.onlyOnJournals,
widgetsCustomHTML: widgetsConfig.customHTML,
Expand Down Expand Up @@ -307,7 +307,8 @@ const getBase64FromUrl = async (url: string): Promise<string> => {
// Get and encode default banners for caching
// skip caching if random image from Unsplash API used
const encodeDefaultBanners = async () => {
if (defaultConfig.page.banner && !defaultPageBannerAuto && !(defaultConfig.page.banner?.includes("source.unsplash.com"))) {
if (defaultConfig.page.banner && !(defaultConfig.page.banner?.includes("source.unsplash.com"))) {
// if (defaultConfig.page.banner && !defaultPageBannerAuto && !(defaultConfig.page.banner?.includes("source.unsplash.com"))) {
defaultConfig.page.banner = await getBase64FromUrl(defaultConfig.page.banner);
}
if (defaultConfig.journal.banner && !(defaultConfig.journal.banner?.includes("source.unsplash.com"))) {
Expand Down Expand Up @@ -444,9 +445,9 @@ const renderImage = async (pageAssetsData: AssetData): Promise<boolean> => {
//remove surrounding quotations if present
pageAssetsData.banner = pageAssetsData.banner.replace(/^"(.*)"$/, '$1');
// experimental auto image
if (defaultPageBannerAuto) {
pageAssetsData.banner = `https://source.unsplash.com/1600x900?${pageAssetsData.title}`;
}
// if (defaultPageBannerAuto) {
// pageAssetsData.banner = `https://source.unsplash.com/1600x900?${pageAssetsData.title}`;
// }
// if local image from assets folder
if (pageAssetsData.banner.startsWith("../")) {
const graphPath = (await logseq.App.getCurrentGraph())?.path;
Expand Down
4 changes: 3 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import logseqDevPlugin from "vite-plugin-logseq";

// https://vitejs.dev/config/
export default defineConfig({
plugins: [logseqDevPlugin()],
plugins: [
logseqDevPlugin()
],
// Makes HMR available for development
build: {
sourcemap: true,
Expand Down

0 comments on commit 2cd754d

Please sign in to comment.