Skip to content

Commit

Permalink
Merge pull request #25 from ashcolor/develop
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
ashcolor authored Aug 26, 2023
2 parents 32c8887 + 9ee18b5 commit 86798be
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 30 deletions.
4 changes: 2 additions & 2 deletions components/pages/Top/RecentArticles.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
interface Props {
category: string;
category?: string;
}
const props = withDefaults(defineProps<Props>(), {
Expand Down Expand Up @@ -31,7 +31,7 @@ const articles = await query.find();
:link-path="article._path"
:thumbnail="article.thumbnail"
:title="article.title"
:category="article.category"
:category="article?.category"
:tags="article.tags"
:created-at="article.createdAt"
:updated-at="article.updatedAt"
Expand Down
2 changes: 1 addition & 1 deletion components/pages/Top/RecommendArticles.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
interface Props {
category: string;
category?: string;
}
const props = withDefaults(defineProps<Props>(), {
Expand Down
5 changes: 4 additions & 1 deletion components/pages/common/Footer.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<script setup lang="ts">
import { Icon } from "@iconify/vue";
import { BLOG_CATEGORIES } from "@/utils/const";
const showCategories = BLOG_CATEGORIES.filter((category) => category.isShowList);
</script>

<template>
<footer class="footer justify-evenly bg-base-200 p-10 text-base-content">
<div class="flex w-full flex-col gap-4">
<span class="footer-title">BLOG</span>
<NuxtLink
v-for="category in BLOG_CATEGORIES"
v-for="category in showCategories"
:key="category.name"
:to="category.path"
class="link-hover link"
Expand Down
2 changes: 1 addition & 1 deletion components/parts/PageToc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { Icon } from "@iconify/vue";
const route = useRoute();
const { data: article } = await useAsyncData("hello", () => queryContent(route.path).findOne());
const { data: article } = await useAsyncData(() => queryContent(route.path).findOne());
const links = article.value?.body.toc?.links;
Expand Down
3 changes: 2 additions & 1 deletion components/parts/SnsShareContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const props = withDefaults(defineProps<Props>(), {
});
const encodedTitle = computed(() => encodeURIComponent(props.title));
const url = computed(() => new URL(props.url));
const isValidUrl = computed(() => Util.isValidUrl(props.url));
const url = computed(() => (isValidUrl.value ? new URL(props.url) : ""));
const encodedHref = computed(() => encodeURIComponent(url.value.href));
const encodedHostPath = computed(() =>
encodeURIComponent(`${url.value.host}${url.value.pathname}`)
Expand Down
9 changes: 2 additions & 7 deletions content/blog/programming/0.nuxt-blog.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,8 @@ daisyUIでは2つのクラスを付けるだけで簡単に実装することが

最初は**AWS Amplify Hosting**にホスティングしていました。

しかし、NuxtJSのオプションで[SSRをオフ]{.marker}にすると

- マークダウンを編集中にホットリロードが効かない
- Google Search Consoleがsitemap.xmlを認識しない

というトラブルが発生しました。
どちらも原因を調べてはみたのですが、解決策がはっきりしなかったため、[SSRモードで動かせるようにNode環境にデプロイ]{.marker}しました。
しかし、NuxtJSのオプションで[SSRをオフ]{.marker}にすると[Google Search Consoleがsitemap.xmlを認識しない]{.marker}というトラブルが発生しました。
原因を調べてはみたのですが、解決策がはっきりしなかったため、[SSRモードで動かせるようにNode環境にデプロイ]{.marker}しました。

既に他のプロジェクトでもVercelは使っており、[設定の手間がほぼなくデプロイできる]{.marker}のも魅力です。

Expand Down
1 change: 0 additions & 1 deletion nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export default defineNuxtConfig({

content: {
// https://content.nuxtjs.org/api/configuration
documentDriven: true,
markdown: {
remarkPlugins: ["remark-breaks"],
},
Expand Down
2 changes: 1 addition & 1 deletion pages/[content].vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BLOG_TITLE } from "@/utils/const";
const route = useRoute();
const { data: article } = await useAsyncData("hello", () => queryContent(route.path).findOne());
const { data: article } = await useAsyncData(() => queryContent(route.path).findOne());
useSeoMeta({
title: `${article.value?.title} | ${BLOG_TITLE}`,
Expand Down
2 changes: 1 addition & 1 deletion pages/_story/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if (import.meta.env.PROD) {
const route = useRoute();
const { data: article } = await useAsyncData("article", () => queryContent(route.path).findOne());
const { data: article } = await useAsyncData(() => queryContent(route.path).findOne());
const links = article.value?.body.toc?.links;
</script>
Expand Down
28 changes: 14 additions & 14 deletions pages/blog/[...slug].vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ import { BLOG_TITLE, BLOG_CATEGORIES } from "@/utils/const";
const route = useRoute();
const { data: article } = await useAsyncData("hello", () => queryContent(route.path).findOne());
const { data: article } = await useAsyncData(() => queryContent(route.path).findOne());
const title = `${article.value?.title} | ${BLOG_TITLE}`;
const url = `${import.meta.env.VITE_NUXT_PUBLIC_SITE_URL}${article.value?._path}`;
const title = computed(() => `${article.value?.title} | ${BLOG_TITLE}`);
const url = computed(() => `${import.meta.env.VITE_NUXT_PUBLIC_SITE_URL}${article.value?._path}`);
useSeoMeta({
title,
ogTitle: `${article.value?.title} | ${BLOG_TITLE}`,
title: title.value,
ogTitle: title.value,
description: article.value?.description,
ogDescription: article.value?.description,
ogImage: article.value?.thumbnail,
ogUrl: url,
ogUrl: url.value,
ogType: "article",
ogSiteName: BLOG_TITLE,
twitterCard: "summary_large_image",
Expand All @@ -41,17 +41,17 @@ const navigations = computed(() => {
<div v-if="article">
<div class="mb-8">
<BreadCrumb :navigations="navigations"></BreadCrumb>
<ProseH1>{{ article.title }}</ProseH1>
<ProseH1>{{ article?.title }}</ProseH1>
<div class="flex flex-row items-center gap-2 text-sm text-slate-500">
<IconWithText v-if="article.createdAt" icon="ph:clock">
{{ article.createdAt }}
<IconWithText v-if="article?.createdAt" icon="ph:clock">
{{ article?.createdAt }}
</IconWithText>
<IconWithText v-if="article.updatedAt" icon="ph:clock-clockwise">
{{ article.updatedAt }}
<IconWithText v-if="article?.updatedAt" icon="ph:clock-clockwise">
{{ article?.updatedAt }}
</IconWithText>
<div class="flex flex-row gap-1">
<NuxtLink
v-for="tag in article.tags"
v-for="tag in article?.tags"
:key="tag"
:to="`/search?word=${tag}`"
class="badge badge-sm gap-1"
Expand All @@ -65,10 +65,10 @@ const navigations = computed(() => {
<div class="grid grid-cols-12">
<div class="col-span-12 flex flex-col gap-4 lg:col-span-8">
<div class="mx-auto mb-8">
<img :src="article.thumbnail" />
<img :src="article?.thumbnail" />
</div>
<div class="col-span-4 mb-8 block lg:hidden">
<!-- <PageToc></PageToc> -->
<PageToc></PageToc>
</div>
<ContentRenderer :value="article" />
<div class="divider"></div>
Expand Down
10 changes: 10 additions & 0 deletions utils/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@ export class Util {
static kebabToCamelCase = (kebabCase: string): string => {
return kebabCase.replace(/-([a-z])/g, (_, match) => match.toUpperCase());
};

static isValidUrl(url: string): boolean {
try {
// eslint-disable-next-line no-new
new URL(url);
return true;
} catch (err) {
return false;
}
}
}

0 comments on commit 86798be

Please sign in to comment.