-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
1,392 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!-- | ||
- Copyright (c) 2023, Terwer . All rights reserved. | ||
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
- | ||
- This code is free software; you can redistribute it and/or modify it | ||
- under the terms of the GNU General Public License version 2 only, as | ||
- published by the Free Software Foundation. Terwer designates this | ||
- particular file as subject to the "Classpath" exception as provided | ||
- by Terwer in the LICENSE file that accompanied this code. | ||
- | ||
- This code is distributed in the hope that it will be useful, but WITHOUT | ||
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
- version 2 for more details (a copy is included in the LICENSE file that | ||
- accompanied this code). | ||
- | ||
- You should have received a copy of the GNU General Public License version | ||
- 2 along with this work; if not, write to the Free Software Foundation, | ||
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
- | ||
- Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
- or visit www.terwer.space if you need additional information or have any | ||
- questions. | ||
--> | ||
|
||
<script setup lang="ts"> | ||
// https://github.com/nuxt/nuxt/issues/15346 | ||
// 由于布局是个宏,不能动态设置了,因此只能写死 | ||
</script> | ||
|
||
<template> | ||
<el-container> | ||
<default-header /> | ||
<el-main> | ||
<default-detail :show-title-sign="true" /> | ||
</el-main> | ||
<default-footer /> | ||
</el-container> | ||
</template> | ||
|
||
<style lang="stylus"> | ||
.el-container | ||
display block !important | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<!-- | ||
- Copyright (c) 2023, Terwer . All rights reserved. | ||
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
- | ||
- This code is free software; you can redistribute it and/or modify it | ||
- under the terms of the GNU General Public License version 2 only, as | ||
- published by the Free Software Foundation. Terwer designates this | ||
- particular file as subject to the "Classpath" exception as provided | ||
- by Terwer in the LICENSE file that accompanied this code. | ||
- | ||
- This code is distributed in the hope that it will be useful, but WITHOUT | ||
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
- version 2 for more details (a copy is included in the LICENSE file that | ||
- accompanied this code). | ||
- | ||
- You should have received a copy of the GNU General Public License version | ||
- 2 along with this work; if not, write to the Free Software Foundation, | ||
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
- | ||
- Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
- or visit www.terwer.space if you need additional information or have any | ||
- questions. | ||
--> | ||
|
||
<script setup lang="ts"> | ||
// props | ||
const props = defineProps({ | ||
pageId: { | ||
type: String, | ||
default: undefined, | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<el-container> | ||
<default-header /> | ||
<el-main> | ||
<default-detail :page-id="props.pageId" :override-seo="true" /> | ||
</el-main> | ||
<default-footer /> | ||
</el-container> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!-- | ||
- Copyright (c) 2023, Terwer . All rights reserved. | ||
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
- | ||
- This code is free software; you can redistribute it and/or modify it | ||
- under the terms of the GNU General Public License version 2 only, as | ||
- published by the Free Software Foundation. Terwer designates this | ||
- particular file as subject to the "Classpath" exception as provided | ||
- by Terwer in the LICENSE file that accompanied this code. | ||
- | ||
- This code is distributed in the hope that it will be useful, but WITHOUT | ||
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
- version 2 for more details (a copy is included in the LICENSE file that | ||
- accompanied this code). | ||
- | ||
- You should have received a copy of the GNU General Public License version | ||
- 2 along with this work; if not, write to the Free Software Foundation, | ||
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
- | ||
- Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
- or visit www.terwer.space if you need additional information or have any | ||
- questions. | ||
--> | ||
|
||
<script setup lang="ts"> | ||
import { useSettingStore } from "~/stores/useSettingStore" | ||
import { StrUtil } from "zhi-common" | ||
definePageMeta({ | ||
layout: "default", | ||
}) | ||
const { t } = useI18n() | ||
const { getSetting } = useSettingStore() | ||
const setting = await getSetting() | ||
const title = `${setting?.siteTitle ?? t("blog.site.title")} - ${setting?.siteSlogan ?? t("blog.site.slogan")}` | ||
const seoMeta = { | ||
title: title, | ||
ogTitle: title, | ||
description: setting?.siteDescription, | ||
ogDescription: setting?.siteDescription, | ||
} as any | ||
useSeoMeta(seoMeta) | ||
const homePageId = setting?.homePageId ?? undefined | ||
// methods | ||
const goSetting = async () => { | ||
await navigateTo("/setting") | ||
} | ||
</script> | ||
|
||
<template> | ||
<div v-if="StrUtil.isEmptyString(homePageId)"> | ||
<el-empty :description="t('blog.index.no.home')"> | ||
<el-button type="primary" @click="goSetting">{{ t("blog.index.goto.set.home") }}</el-button> | ||
</el-empty> | ||
</div> | ||
<div v-else> | ||
<default-home :page-id="homePageId" /> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<!-- | ||
- Copyright (c) 2023, Terwer . All rights reserved. | ||
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
- | ||
- This code is free software; you can redistribute it and/or modify it | ||
- under the terms of the GNU General Public License version 2 only, as | ||
- published by the Free Software Foundation. Terwer designates this | ||
- particular file as subject to the "Classpath" exception as provided | ||
- by Terwer in the LICENSE file that accompanied this code. | ||
- | ||
- This code is distributed in the hope that it will be useful, but WITHOUT | ||
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
- version 2 for more details (a copy is included in the LICENSE file that | ||
- accompanied this code). | ||
- | ||
- You should have received a copy of the GNU General Public License version | ||
- 2 along with this work; if not, write to the Free Software Foundation, | ||
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
- | ||
- Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
- or visit www.terwer.space if you need additional information or have any | ||
- questions. | ||
--> | ||
|
||
<script setup lang="ts"> | ||
import { JsonUtil, ObjectUtil } from "zhi-common" | ||
import { Post } from "zhi-blog-api" | ||
import { createAppLogger } from "~/common/appLogger" | ||
import { getSummery } from "~/utils/utils" | ||
import { useServerAssets } from "~/plugins/renderer/useServerAssets" | ||
// https://github.com/nuxt/nuxt/issues/15346 | ||
// 由于布局是个宏,静态构建情况下,不能动态设置,只能在前面的页面写死 | ||
// props | ||
const props = defineProps({ | ||
showTitleSign: Boolean, | ||
overrideSeo: Boolean, | ||
pageId: { | ||
type: String, | ||
default: undefined, | ||
}, | ||
}) | ||
const logger = createAppLogger("static-share-page") | ||
const { t } = useI18n() | ||
const route = useRoute() | ||
const id = props.pageId ?? ((route.params.id ?? "") as string) | ||
const { getFirstImageSrc } = useServerAssets() | ||
// datas | ||
const getPostData = async () => { | ||
const mdResponse = await fetch(`/public/siyuan-blog/${id}.json`) | ||
const mdText = await mdResponse.text() | ||
formData.post = JsonUtil.safeParse<Post>(mdText, {} as Post) | ||
formData.shareEnabled = !ObjectUtil.isEmptyObject(formData.post) | ||
logger.info("post=>", formData.post) | ||
logger.info(`shareEnabled=>${formData.shareEnabled}`) | ||
} | ||
const formData = reactive({ | ||
post: {} as Post, | ||
shareEnabled: true, | ||
}) | ||
await getPostData() | ||
if (!props.overrideSeo) { | ||
const titleSign = " - " + t("blog.share") | ||
const title = `${formData?.post?.title ?? "404 Not Found"}${props.showTitleSign ? titleSign : ""}` | ||
const desc = getSummery(formData?.post?.description ?? "") | ||
const headImage = getFirstImageSrc(formData?.post?.description ?? "") | ||
const seoMeta = { | ||
title: title, | ||
ogTitle: title, | ||
description: desc, | ||
ogDescription: desc, | ||
} as any | ||
if (headImage) { | ||
logger.info("get a head image from doc=>", headImage) | ||
seoMeta.ogImage = headImage | ||
} | ||
useSeoMeta(seoMeta) | ||
} | ||
onMounted(async () => {}) | ||
const VNode = () => | ||
h("div", { | ||
class: "", | ||
innerHTML: formData.post.editorDom?.replaceAll('contenteditable="true"', 'contenteditable="false"') ?? "", | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div v-if="!formData.shareEnabled"> | ||
<el-empty :description="t('blog.index.no.permission')"> </el-empty> | ||
</div> | ||
<div v-else class="fn__flex-1 protyle" data-loading="finished"> | ||
<div class="protyle-content protyle-content--transition" data-fullwidth="true"> | ||
<div class="protyle-title protyle-wysiwyg--attr"> | ||
<div | ||
contenteditable="false" | ||
data-position="center" | ||
spellcheck="false" | ||
class="protyle-title__input" | ||
data-render="true" | ||
> | ||
{{ formData.post.title }} | ||
</div> | ||
</div> | ||
<div | ||
class="protyle-wysiwyg protyle-wysiwyg--attr" | ||
spellcheck="false" | ||
contenteditable="false" | ||
data-doc-type="NodeDocument" | ||
> | ||
<VNode v-highlight v-sbeauty v-sdomparser /> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!-- | ||
- Copyright (c) 2023, Terwer . All rights reserved. | ||
- DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
- | ||
- This code is free software; you can redistribute it and/or modify it | ||
- under the terms of the GNU General Public License version 2 only, as | ||
- published by the Free Software Foundation. Terwer designates this | ||
- particular file as subject to the "Classpath" exception as provided | ||
- by Terwer in the LICENSE file that accompanied this code. | ||
- | ||
- This code is distributed in the hope that it will be useful, but WITHOUT | ||
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
- version 2 for more details (a copy is included in the LICENSE file that | ||
- accompanied this code). | ||
- | ||
- You should have received a copy of the GNU General Public License version | ||
- 2 along with this work; if not, write to the Free Software Foundation, | ||
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
- | ||
- Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
- or visit www.terwer.space if you need additional information or have any | ||
- questions. | ||
--> | ||
|
||
<script setup lang="ts"> | ||
// https://github.com/nuxt/nuxt/issues/15346 | ||
// 由于布局是个宏,不能动态设置了,因此只能写死 | ||
</script> | ||
|
||
<template> | ||
<el-container> | ||
<static-header /> | ||
<el-main> | ||
<static-detail :show-title-sign="true" /> | ||
</el-main> | ||
<static-footer /> | ||
</el-container> | ||
</template> | ||
|
||
<style lang="stylus"> | ||
.el-container | ||
display block !important | ||
</style> |
Oops, something went wrong.