feat: upgrade sveltekit
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
85ae5f4e94
commit
4f3d11dc02
40
package.json
40
package.json
@ -14,40 +14,40 @@
|
|||||||
"format": "prettier --write --plugin-search-dir=. ."
|
"format": "prettier --write --plugin-search-dir=. ."
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/adapter-auto": "next",
|
"@sveltejs/adapter-auto": "^1.0.0",
|
||||||
"@sveltejs/adapter-node": "^1.0.0-next.83",
|
"@sveltejs/adapter-node": "^1.0.0",
|
||||||
"@sveltejs/kit": "next",
|
"@sveltejs/kit": "^1.0.1",
|
||||||
"@types/fitvids": "^2.1.1",
|
"@types/fitvids": "^2.1.1",
|
||||||
"@types/tryghost__content-api": "^1.3.11",
|
"@types/tryghost__content-api": "^1.3.11",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
"@typescript-eslint/eslint-plugin": "^5.46.1",
|
||||||
"@typescript-eslint/parser": "^5.30.7",
|
"@typescript-eslint/parser": "^5.46.1",
|
||||||
"dayjs": "^1.11.4",
|
"dayjs": "^1.11.7",
|
||||||
"eslint": "^8.20.0",
|
"eslint": "^8.30.0",
|
||||||
"eslint-config-prettier": "^8.5.0",
|
"eslint-config-prettier": "^8.5.0",
|
||||||
"eslint-plugin-svelte3": "^4.0.0",
|
"eslint-plugin-svelte3": "^4.0.0",
|
||||||
"hast-util-from-selector": "^2.0.0",
|
"hast-util-from-selector": "^2.0.0",
|
||||||
"prettier": "^2.7.1",
|
"prettier": "^2.8.1",
|
||||||
"prettier-plugin-svelte": "^2.7.0",
|
"prettier-plugin-svelte": "^2.9.0",
|
||||||
"rehype-parse": "^8.0.4",
|
"rehype-parse": "^8.0.4",
|
||||||
"rehype-stringify": "^9.0.3",
|
"rehype-stringify": "^9.0.3",
|
||||||
"sass": "^1.54.0",
|
"sass": "^1.57.0",
|
||||||
"svelte": "^3.49.0",
|
"svelte": "^3.55.0",
|
||||||
"svelte-check": "^2.8.0",
|
"svelte-check": "^2.10.2",
|
||||||
"svelte-infinite-scroll": "^2.0.1",
|
"svelte-infinite-scroll": "^2.0.1",
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-preprocess": "^4.10.7",
|
||||||
"svelte2tsx": "^0.5.12",
|
"svelte2tsx": "^0.5.22",
|
||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.1",
|
||||||
"typescript": "^4.7.4",
|
"typescript": "^4.9.4",
|
||||||
"unified": "^10.1.2",
|
"unified": "^10.1.2",
|
||||||
"unist-util-visit": "^4.1.0",
|
"unist-util-visit": "^4.1.1",
|
||||||
"vite": "^3.0.3"
|
"vite": "^4.0.1"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@damillora/plachta": "^1.8.3",
|
"@damillora/plachta": "^2.0.2",
|
||||||
"@tryghost/content-api": "^1.11.0",
|
"@tryghost/content-api": "^1.11.5",
|
||||||
"fitvids": "^2.1.1",
|
"fitvids": "^2.1.1",
|
||||||
"svelte-material-icons": "^2.0.2",
|
"svelte-material-icons": "^2.0.4",
|
||||||
"svelte-themes": "^0.0.98"
|
"svelte-themes": "^0.0.98"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
1635
pnpm-lock.yaml
1635
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -1,16 +1,3 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
export const load: Load = async () => {
|
|
||||||
const settings = await browseSettings();
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
header: settings.codeinjection_head,
|
|
||||||
footer: settings.codeinjection_foot
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { navigating } from '$app/stores';
|
import { navigating } from '$app/stores';
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
@ -33,14 +20,14 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export let header = '';
|
export let data;
|
||||||
export let footer = '';
|
|
||||||
let loading = true;
|
let loading = true;
|
||||||
navigating.subscribe((x) => (loading = x != null));
|
navigating.subscribe((x) => (loading = x != null));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
{@html header}
|
{@html data.header}
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
<Base>
|
<Base>
|
||||||
<Header>
|
<Header>
|
||||||
@ -55,9 +42,9 @@
|
|||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<slot />
|
<slot />
|
||||||
{@html footer}
|
{@html data.footer}
|
||||||
<Footer>
|
<Footer>
|
||||||
<p>Copyright (c) 2021 Damillora</p>
|
<p>Copyright (c) 2023 Damillora</p>
|
||||||
</Footer>
|
</Footer>
|
||||||
</Base>
|
</Base>
|
||||||
|
|
11
src/routes/+layout.ts
Normal file
11
src/routes/+layout.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import type { LayoutLoad } from "./$types";
|
||||||
|
import { browseSettings } from "$lib/content/contentApi";
|
||||||
|
|
||||||
|
export const load: LayoutLoad = async () => {
|
||||||
|
const settings = await browseSettings();
|
||||||
|
|
||||||
|
return {
|
||||||
|
header: settings.codeinjection_head,
|
||||||
|
footer: settings.codeinjection_foot
|
||||||
|
};
|
||||||
|
};
|
@ -1,19 +1,7 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
import { browsePost } from '$lib/content/contentApi';
|
|
||||||
|
|
||||||
export async function load() {
|
|
||||||
const posts = await browsePost();
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
posts: posts
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import Container from '@damillora/plachta/components/Container/Container.svelte';
|
import Container from '@damillora/plachta/components/Container/Container.svelte';
|
||||||
@ -22,8 +10,10 @@
|
|||||||
import PostCard from '@damillora/plachta/components/PostCard/PostCard.svelte';
|
import PostCard from '@damillora/plachta/components/PostCard/PostCard.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import IndexSeo from '$lib/components/SEO/IndexSEO.svelte';
|
import IndexSeo from '$lib/components/SEO/IndexSEO.svelte';
|
||||||
|
import {browsePost} from '$lib/content/contentApi';
|
||||||
|
export let data;
|
||||||
|
let { posts } = data;
|
||||||
|
|
||||||
export let posts: any[] = [];
|
|
||||||
let newPosts: any[] = [];
|
let newPosts: any[] = [];
|
||||||
let page = 1;
|
let page = 1;
|
||||||
$: posts = [...posts, ...newPosts];
|
$: posts = [...posts, ...newPosts];
|
9
src/routes/+page.ts
Normal file
9
src/routes/+page.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { browsePost } from '$lib/content/contentApi';
|
||||||
|
|
||||||
|
export async function load() {
|
||||||
|
const posts = await browsePost();
|
||||||
|
|
||||||
|
return {
|
||||||
|
posts: posts
|
||||||
|
};
|
||||||
|
}
|
@ -1,25 +1,3 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
export const load: Load = async ({ params }) => {
|
|
||||||
const tagSlug = params.tag;
|
|
||||||
const tagObj = await readTag(tagSlug);
|
|
||||||
if (!tagObj) {
|
|
||||||
return {
|
|
||||||
status: 404,
|
|
||||||
error: new Error('Tag not found')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const posts = await browsePostWithTag(tagSlug);
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
tag: tagObj,
|
|
||||||
posts: posts
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Hero from '@damillora/plachta/components/Hero/Hero.svelte';
|
import Hero from '@damillora/plachta/components/Hero/Hero.svelte';
|
||||||
import PostCard from '@damillora/plachta/components/PostCard/PostCard.svelte';
|
import PostCard from '@damillora/plachta/components/PostCard/PostCard.svelte';
|
||||||
@ -30,18 +8,19 @@
|
|||||||
import { browsePostWithTag, readTag } from '$lib/content/contentApi';
|
import { browsePostWithTag, readTag } from '$lib/content/contentApi';
|
||||||
import type { Load } from '@sveltejs/kit';
|
import type { Load } from '@sveltejs/kit';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import TagSeo from '$lib/components/SEO/TagSEO.svelte';
|
import TagSeo from '$lib/components/SEO/TagSEO.svelte';
|
||||||
|
|
||||||
export let tag: any;
|
export let data;
|
||||||
export let posts: any[];
|
let { posts } = data;
|
||||||
|
|
||||||
let newPosts: any[] = [];
|
let newPosts: any[] = [];
|
||||||
let page = 1;
|
let page = 1;
|
||||||
$: posts = [...posts, ...newPosts];
|
$: posts = [...posts, ...newPosts];
|
||||||
|
|
||||||
async function loadPage() {
|
async function loadPage() {
|
||||||
const posts = await browsePostWithTag(tag.slug, page);
|
const posts = await browsePostWithTag(data.tag.slug, page);
|
||||||
newPosts = posts;
|
newPosts = posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,16 +43,16 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Tag: {tag.name} - Damillora's Virtual Memoir</title>
|
<title>Tag: {data.tag.name} - Damillora's Virtual Memoir</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<TagSeo {tag} />
|
<TagSeo tag={data.tag} />
|
||||||
|
|
||||||
<Hero background={tag.feature_image ?? `/images/default-feature.jpg`} />
|
<Hero background={data.tag.feature_image ?? `/images/default-feature.jpg`} />
|
||||||
|
|
||||||
<Container>
|
<Container>
|
||||||
<Post>
|
<Post>
|
||||||
<TagHeader accent_color={tag.accent_color} name={tag.name} description={tag.description} />
|
<TagHeader accent_color={data.tag.accent_color} name={data.tag.name} description={data.tag.description} />
|
||||||
</Post>
|
</Post>
|
||||||
|
|
||||||
<Index>
|
<Index>
|
18
src/routes/[tag]/+page.ts
Normal file
18
src/routes/[tag]/+page.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import { readTag, browsePostWithTag } from '$lib/content/contentApi';
|
||||||
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
|
export const load: PageLoad = async ({ params }) => {
|
||||||
|
const tagSlug = params.tag;
|
||||||
|
const tagObj = await readTag(tagSlug);
|
||||||
|
if (!tagObj) {
|
||||||
|
throw error(404, 'Tag not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
const posts = await browsePostWithTag(tagSlug);
|
||||||
|
|
||||||
|
return {
|
||||||
|
tag: tagObj,
|
||||||
|
posts: posts
|
||||||
|
};
|
||||||
|
};
|
@ -1,29 +1,3 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
export const load: Load = async ({ params }) => {
|
|
||||||
const postSlug = params.slug;
|
|
||||||
const post = await readPost(postSlug);
|
|
||||||
if (!post) {
|
|
||||||
return {
|
|
||||||
status: 404,
|
|
||||||
error: new Error('Post not found')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const newHtml = await processPostHtml(post.html);
|
|
||||||
post.html = newHtml;
|
|
||||||
const prevPost = await browsePrevPost(post);
|
|
||||||
const nextPost = await browseNextPost(post);
|
|
||||||
const relatedPost = await browseRelatedPost(post.primary_tag?.slug, post.id);
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
post: post,
|
|
||||||
prevPost: prevPost,
|
|
||||||
nextPost: nextPost,
|
|
||||||
relatedPost: relatedPost
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
@ -45,52 +19,49 @@
|
|||||||
browseRelatedPost,
|
browseRelatedPost,
|
||||||
readPost
|
readPost
|
||||||
} from '$lib/content/contentApi';
|
} from '$lib/content/contentApi';
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
import PostSeo from '$lib/components/SEO/PostSEO.svelte';
|
import PostSeo from '$lib/components/SEO/PostSEO.svelte';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { afterNavigate } from '$app/navigation';
|
import { afterNavigate } from '$app/navigation';
|
||||||
import ResponsiveHero from '$lib/components/ResponsiveHero.svelte';
|
import ResponsiveHero from '$lib/components/ResponsiveHero.svelte';
|
||||||
|
|
||||||
export let post: any;
|
export let data;
|
||||||
export let prevPost: any;
|
|
||||||
export let nextPost: any;
|
|
||||||
export let relatedPost: any[];
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{post.title}</title>
|
<title>{data.post.title}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<PostSeo {post} />
|
<PostSeo post={data.post} />
|
||||||
|
|
||||||
<ResponsiveHero background={post.feature_image} />
|
<ResponsiveHero background={data.post.feature_image} />
|
||||||
|
|
||||||
<Container>
|
<Container>
|
||||||
<Post>
|
<Post>
|
||||||
<PostHeader
|
<PostHeader
|
||||||
title={post.title}
|
title={data.post.title}
|
||||||
authors={post.authors}
|
authors={data.post.authors}
|
||||||
primary_tag={post.primary_tag}
|
primary_tag={data.post.primary_tag}
|
||||||
date={dayjs(post.published_at).format('DD MMM YYYY')}
|
date={dayjs(data.post.published_at).format('DD MMM YYYY')}
|
||||||
reading_time={`${post.reading_time} min read`}
|
reading_time={`${data.post.reading_time} min read`}
|
||||||
/>
|
/>
|
||||||
<PostMain>
|
<PostMain>
|
||||||
<GhostStyle>
|
<GhostStyle>
|
||||||
{@html post.html}
|
{@html data.post.html}
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
</GhostStyle>
|
</GhostStyle>
|
||||||
<svelte:fragment slot="comments" />
|
<svelte:fragment slot="comments" />
|
||||||
</PostMain>
|
</PostMain>
|
||||||
<PostNavigator prev_post={prevPost} next_post={nextPost} />
|
<PostNavigator prev_post={data.prevPost} next_post={data.nextPost} />
|
||||||
</Post>
|
</Post>
|
||||||
|
|
||||||
<PostRelated
|
<PostRelated
|
||||||
name={post.primary_tag.name}
|
name={data.post.primary_tag.name}
|
||||||
url={post.primary_tag.utl}
|
url={data.post.primary_tag.url}
|
||||||
accent_color={post.primary_tag.accent_color}
|
accent_color={data.post.primary_tag.accent_color}
|
||||||
>
|
>
|
||||||
{#each relatedPost as post}
|
{#each data.relatedPost as post}
|
||||||
<PostCard
|
<PostCard
|
||||||
title={post.title}
|
title={post.title}
|
||||||
authors={post.authors}
|
authors={post.authors}
|
23
src/routes/[tag]/[slug]/+page.ts
Normal file
23
src/routes/[tag]/[slug]/+page.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { browseNextPost, browsePrevPost, browseRelatedPost, readPost } from '$lib/content/contentApi';
|
||||||
|
import { processPostHtml } from '$lib/content/postProcessor';
|
||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
|
export const load: PageLoad = async ({ params }) => {
|
||||||
|
const postSlug = params.slug;
|
||||||
|
const post = await readPost(postSlug);
|
||||||
|
if (!post) {
|
||||||
|
throw error(404, 'Post not found');
|
||||||
|
}
|
||||||
|
const newHtml = await processPostHtml(post.html);
|
||||||
|
post.html = newHtml;
|
||||||
|
const prevPost = await browsePrevPost(post);
|
||||||
|
const nextPost = await browseNextPost(post);
|
||||||
|
const relatedPost = await browseRelatedPost(post.primary_tag?.slug, post.id);
|
||||||
|
return {
|
||||||
|
post: post,
|
||||||
|
prevPost: prevPost,
|
||||||
|
nextPost: nextPost,
|
||||||
|
relatedPost: relatedPost
|
||||||
|
};
|
||||||
|
};
|
@ -1,11 +1,11 @@
|
|||||||
import type { RequestHandler } from "@sveltejs/kit";
|
import type { RequestHandler } from "@sveltejs/kit";
|
||||||
|
|
||||||
export const GET: RequestHandler = async ({ params }) => {
|
export const GET: RequestHandler = async ({ params }) => {
|
||||||
return {
|
return new Response(undefined, {
|
||||||
status: 301,
|
status: 301,
|
||||||
headers: {
|
headers: {
|
||||||
"Location": `/${params.tag}/${params.slug}`
|
"Location": `/${params.tag}/${params.slug}`
|
||||||
},
|
}
|
||||||
};
|
});
|
||||||
};
|
};
|
||||||
|
|
@ -1,26 +1,3 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
export const load: Load = async ({ params }) => {
|
|
||||||
const authorSlug = params.author;
|
|
||||||
const authorObj = await readAuthor(authorSlug);
|
|
||||||
|
|
||||||
if (!authorObj) {
|
|
||||||
return {
|
|
||||||
status: 404,
|
|
||||||
error: new Error('Author not found')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
const posts = await browsePostWithAuthor(authorSlug);
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
author: authorObj,
|
|
||||||
posts: posts
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import PostCard from '@damillora/plachta/components/PostCard/PostCard.svelte';
|
import PostCard from '@damillora/plachta/components/PostCard/PostCard.svelte';
|
||||||
import Index from '@damillora/plachta/components/PageTypes/Index.svelte';
|
import Index from '@damillora/plachta/components/PageTypes/Index.svelte';
|
||||||
@ -30,20 +7,21 @@
|
|||||||
import type { Load } from '@sveltejs/kit';
|
import type { Load } from '@sveltejs/kit';
|
||||||
import { browsePostWithAuthor, readAuthor } from '$lib/content/contentApi';
|
import { browsePostWithAuthor, readAuthor } from '$lib/content/contentApi';
|
||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import AuthorSeo from '$lib/components/SEO/AuthorSEO.svelte';
|
import AuthorSeo from '$lib/components/SEO/AuthorSEO.svelte';
|
||||||
import Hero from '@damillora/plachta/components/Hero/Hero.svelte';
|
import Hero from '@damillora/plachta/components/Hero/Hero.svelte';
|
||||||
|
|
||||||
export let author: any;
|
export let author: any;
|
||||||
|
|
||||||
export let posts: any[];
|
export let data;
|
||||||
|
let { posts } = data;
|
||||||
let newPosts: any[] = [];
|
let newPosts: any[] = [];
|
||||||
let page = 1;
|
let page = 1;
|
||||||
$: posts = [...posts, ...newPosts];
|
$: posts = [...posts, ...newPosts];
|
||||||
|
|
||||||
async function loadPage() {
|
async function loadPage() {
|
||||||
const posts = await browsePostWithAuthor(author.slug, page);
|
const posts = await browsePostWithAuthor(data.author.slug, page);
|
||||||
newPosts = posts;
|
newPosts = posts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,22 +44,22 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>Author: {author.name} - Damillora's Virtual Memoir</title>
|
<title>Author: {data.author.name} - Damillora's Virtual Memoir</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<Hero background={author.cover_image ?? `/images/default-feature.jpg`} />
|
<Hero background={data.author.cover_image ?? `/images/default-feature.jpg`} />
|
||||||
|
|
||||||
<AuthorSeo {author} />
|
<AuthorSeo author={data.author} />
|
||||||
|
|
||||||
<Container>
|
<Container>
|
||||||
<Post>
|
<Post>
|
||||||
<AuthorHeader
|
<AuthorHeader
|
||||||
profile_image={author.profile_image}
|
profile_image={data.author.profile_image}
|
||||||
name={author.name}
|
name={data.author.name}
|
||||||
bio={author.bio}
|
bio={data.author.bio}
|
||||||
website={author.website}
|
website={data.author.website}
|
||||||
facebook={author.facebook}
|
facebook={data.author.facebook}
|
||||||
twitter={author.twitter}
|
twitter={data.author.twitter}
|
||||||
/>
|
/>
|
||||||
</Post>
|
</Post>
|
||||||
|
|
19
src/routes/author/[author]/+page.ts
Normal file
19
src/routes/author/[author]/+page.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { readAuthor, browsePostWithAuthor } from '$lib/content/contentApi';
|
||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
|
export const load: PageLoad = async ({ params }) => {
|
||||||
|
const authorSlug = params.author;
|
||||||
|
const authorObj = await readAuthor(authorSlug);
|
||||||
|
|
||||||
|
if (!authorObj) {
|
||||||
|
throw error(404, 'Author not found');
|
||||||
|
}
|
||||||
|
|
||||||
|
const posts = await browsePostWithAuthor(authorSlug);
|
||||||
|
|
||||||
|
return {
|
||||||
|
author: authorObj,
|
||||||
|
posts: posts
|
||||||
|
};
|
||||||
|
};
|
@ -1,29 +1,5 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
export const load: Load = async ({ url, fetch }) => {
|
|
||||||
const yurikoEndpoint = 'https://search.blog.nanao.moe';
|
|
||||||
const apiEndpoint = '/api/article/search?';
|
|
||||||
const queryString = 'q=';
|
|
||||||
const pageString = '&page=';
|
|
||||||
|
|
||||||
const q = url.searchParams.get('q') ?? '';
|
|
||||||
const page = url.searchParams.get('page') ?? 1;
|
|
||||||
|
|
||||||
const search = await fetch(
|
|
||||||
`${yurikoEndpoint}${apiEndpoint}${queryString}${q}${pageString}${page}`
|
|
||||||
);
|
|
||||||
const result = await search.json();
|
|
||||||
|
|
||||||
return {
|
|
||||||
props: {
|
|
||||||
query: q,
|
|
||||||
posts: result.result
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { browser } from '$app/env';
|
import { browser } from '$app/environment';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import Container from '@damillora/plachta/components/Container/Container.svelte';
|
import Container from '@damillora/plachta/components/Container/Container.svelte';
|
||||||
@ -33,16 +9,17 @@
|
|||||||
import { onMount } from 'svelte';
|
import { onMount } from 'svelte';
|
||||||
import { search } from '$lib/content/searchApi';
|
import { search } from '$lib/content/searchApi';
|
||||||
import type { Load } from '@sveltejs/kit';
|
import type { Load } from '@sveltejs/kit';
|
||||||
export let query = '';
|
export let data;
|
||||||
export let posts: any[] = [];
|
let posts: any[] = [];
|
||||||
|
|
||||||
let newPosts: any[] = [];
|
let newPosts: any[] = [];
|
||||||
let page = 1;
|
let page = 1;
|
||||||
$: posts = [...posts, ...newPosts];
|
$: posts = [...data.posts, ...newPosts];
|
||||||
|
|
||||||
async function loadPage() {
|
async function loadPage() {
|
||||||
const posts = await search(query, page);
|
const posts = await search(data.query, page);
|
||||||
|
|
||||||
newPosts = posts.result;
|
newPosts = posts.result ?? [];
|
||||||
}
|
}
|
||||||
|
|
||||||
let footer: HTMLElement;
|
let footer: HTMLElement;
|
21
src/routes/search/+page.ts
Normal file
21
src/routes/search/+page.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import type { PageLoad } from "./$types";
|
||||||
|
|
||||||
|
export const load: PageLoad = async ({ url, fetch }) => {
|
||||||
|
const yurikoEndpoint = 'https://search.blog.nanao.moe';
|
||||||
|
const apiEndpoint = '/api/article/search?';
|
||||||
|
const queryString = 'q=';
|
||||||
|
const pageString = '&page=';
|
||||||
|
|
||||||
|
const q = url.searchParams.get('q') ?? '';
|
||||||
|
const page = url.searchParams.get('page') ?? 1;
|
||||||
|
|
||||||
|
const search = await fetch(
|
||||||
|
`${yurikoEndpoint}${apiEndpoint}${queryString}${q}${pageString}${page}`
|
||||||
|
);
|
||||||
|
const result = await search.json();
|
||||||
|
|
||||||
|
return {
|
||||||
|
query: q,
|
||||||
|
posts: result.result
|
||||||
|
};
|
||||||
|
};
|
@ -1,3 +1,4 @@
|
|||||||
|
import { json } from '@sveltejs/kit';
|
||||||
import { browseAllPost } from "$lib/content/contentApi";
|
import { browseAllPost } from "$lib/content/contentApi";
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
@ -28,12 +29,16 @@ export async function GET() {
|
|||||||
return xml;
|
return xml;
|
||||||
|
|
||||||
}
|
}
|
||||||
const xml = createSitemap();
|
const xmlSitemap = createSitemap();
|
||||||
return {
|
// Suggestion (check for correctness before using):
|
||||||
status: 200,
|
// return json(xml, {
|
||||||
|
// headers: {
|
||||||
|
// 'access-control-allow-origin': '*'
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
return new Response(xmlSitemap, {
|
||||||
headers: {
|
headers: {
|
||||||
'access-control-allow-origin': '*'
|
'access-control-allow-origin': '*'
|
||||||
},
|
},
|
||||||
body: xml,
|
});
|
||||||
};
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user