Skip to content

Commit 2bbd545

Browse files
committed
chore: project files migrated to sveltin v0.11.0
1 parent 32c5a7c commit 2bbd545

14 files changed

+159
-131
lines changed

config/defaults.js.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { sveltin } from '../sveltin.config.json';
1+
import { sveltin } from '../sveltin.json';
22

33
const sveltinVersion = sveltin.version;
44
const sveltekitVersion = process.env.VITE_SVELTEKIT_VERSION;

config/website.js.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { IWebSite } from '@sveltinio/seo/types';
1+
import type { Sveltin } from '../src/sveltin';
22

3-
const website: IWebSite = {
3+
const website: Sveltin.WebSite = {
44
name: 'docs.sveltin.io',
55
baseURL: 'https://docs.sveltin.io',
66
language: 'en-GB',
@@ -16,10 +16,6 @@ const website: IWebSite = {
1616
keywords:
1717
'sveltekit, sveltin, documentation, endpoints, slug, cli, svelte, static site generator, tailwind',
1818
contactEmail: '',
19-
sitemap: {
20-
changefreq: 'monthly',
21-
priority: 0.5
22-
},
2319
socials: {
2420
linkedin: '',
2521
twitter: '',

mdsvex.config.js

+14-10
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,32 @@
1+
import { resolve, join, dirname } from 'path';
2+
import { fileURLToPath } from 'url';
3+
14
import { defineMDSveXConfig as defineConfig } from 'mdsvex';
2-
import relativeImages from 'mdsvex-relative-images';
35

6+
import relativeImages from 'mdsvex-relative-images';
47
import emoji from 'remark-emoji';
5-
import remarkSlug from 'remark-slug';
68
import readingTime from 'remark-reading-time';
79
import rehypeAutoLinkHeadings from 'rehype-autolink-headings';
810
import rehypeExternalLinks from 'rehype-external-links';
911
import rehypeSlug from 'rehype-slug';
10-
import headings from './src/lib/utils/headings.js';
12+
import headings from '@sveltinio/remark-headings';
13+
14+
const __filename = fileURLToPath(import.meta.url);
15+
const __dirname = dirname(__filename);
1116

1217
const mdsvexConfig = defineConfig({
1318
extensions: ['.svelte.md', '.md', '.svx'],
1419
smartypants: {
1520
dashes: 'oldschool'
1621
},
17-
remarkPlugins: [remarkSlug, headings, emoji, readingTime(), relativeImages],
22+
layout: {
23+
page: resolve(join(__dirname, `./themes/dockerz/components/md-layout.svelte`))
24+
},
25+
remarkPlugins: [headings, emoji, readingTime(), relativeImages],
1826
rehypePlugins: [
27+
rehypeSlug,
1928
[rehypeExternalLinks, { target: '_blank', rel: ['noopener', 'noreferrer'] }],
20-
rehypeSlug[
21-
(rehypeAutoLinkHeadings,
22-
{
23-
behavior: 'wrap'
24-
})
25-
]
29+
[rehypeAutoLinkHeadings, { behavior: 'wrap' }]
2630
]
2731
});
2832

src/lib/cli/loadCli.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Sveltin } from 'src/sveltin';
1+
import type { Sveltin } from '$sveltin';
22

33
export async function list() {
44
const contentFiles = import.meta.glob('/content/cli/**/*.{svelte.md,md,svx}');
@@ -31,18 +31,18 @@ export async function getSingle(slug: string) {
3131
if (selected.length != 0) {
3232
const selectedItemIndex = publishedByDate.findIndex((elem) => slug === elem.meta['slug']);
3333
const selectedItem = publishedByDate[selectedItemIndex];
34-
const current: Sveltin.ContentEntry = {
34+
const current: Sveltin.ResourceContent = {
3535
resource: resourceName,
3636
metadata: selectedItem.meta as Sveltin.YAMLFrontmatter
3737
};
38-
const previous: Sveltin.ContentEntry = {
38+
const previous: Sveltin.ResourceContent = {
3939
resource: resourceName,
4040
metadata: <Sveltin.YAMLFrontmatter>{
4141
title: publishedByDate[selectedItemIndex + 1]?.meta['title'],
4242
slug: publishedByDate[selectedItemIndex + 1]?.meta['slug']
4343
}
4444
};
45-
const next: Sveltin.ContentEntry = {
45+
const next: Sveltin.ResourceContent = {
4646
resource: resourceName,
4747
metadata: <Sveltin.YAMLFrontmatter>{
4848
title: publishedByDate[selectedItemIndex - 1]?.meta['title'],

src/lib/utils/headings.js

-52
This file was deleted.

src/lib/utils/strings.js.ts

+30-12
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
1-
import type { IWebSite } from '@sveltinio/seo/types';
2-
import type { Sveltin } from 'src/sveltin';
1+
import type { Sveltin } from '$sveltin';
32

4-
export const ToTitle = (text: string): string => {
5-
return CapitalizeAll(text.replace(/-/g, ' '));
3+
export const toTitle = (text: string): string => {
4+
return capitalizeAll(text.replace(/-/g, ' '));
65
};
76

8-
export const CapitalizeAll = (text: string): string => {
7+
export const capitalizeAll = (text: string): string => {
98
const splitted = text.toLowerCase().split(' ');
109
const capitalized: Array<string> = [];
1110

1211
splitted.forEach(function (item) {
13-
capitalized.push(CapitalizeFirstLetter(item));
12+
capitalized.push(capitalizeFirstLetter(item));
1413
});
1514
return capitalized.join(' ');
1615
};
1716

18-
export const CapitalizeFirstLetter = (text: string): string => {
17+
export const capitalizeFirstLetter = (text: string): string => {
1918
return text.charAt(0).toUpperCase() + text.substring(1).toLowerCase();
2019
};
2120

22-
export const ToSlug = (text: string): string => {
21+
export const toSlug = (text: string): string => {
2322
return text
2423
.toLowerCase()
2524
.replace(/[^\w ]+/g, '')
@@ -34,19 +33,25 @@ export const removeTrailingSlash = (text: string): string => {
3433
return text.replace(/\/+$/, '');
3534
};
3635

37-
export const getPageUrl = (name: string, websiteData: IWebSite): string => {
36+
export const getPageUrl = (name: string, websiteData: Sveltin.WebSite): string => {
3837
return websiteData.baseURL.concat('/', name);
3938
};
4039

41-
export const getSlugPageUrl = (item: Sveltin.ContentEntry, websiteData: IWebSite): string => {
40+
export const getSlugPageUrl = (
41+
item: Sveltin.ResourceContent,
42+
websiteData: Sveltin.WebSite
43+
): string => {
4244
return websiteData.baseURL.concat('/', item.resource, '/', item.metadata.slug);
4345
};
4446

45-
export const getFavicon = (websiteData: IWebSite): string => {
47+
export const getFavicon = (websiteData: Sveltin.WebSite): string => {
4648
return websiteData.baseURL.concat('/', websiteData.favicon);
4749
};
4850

49-
export const getCoverImagePath = (item: Sveltin.ContentEntry, websiteData: IWebSite): string => {
51+
export const getCoverImagePath = (
52+
item: Sveltin.ResourceContent,
53+
websiteData: Sveltin.WebSite
54+
): string => {
5055
if (item.metadata.cover && isNotEmpty(item.metadata.cover)) {
5156
return websiteData.baseURL.concat(
5257
'/',
@@ -55,3 +60,16 @@ export const getCoverImagePath = (item: Sveltin.ContentEntry, websiteData: IWebS
5560
}
5661
return getFavicon(websiteData);
5762
};
63+
64+
export const canonicalPageUrl = (name: string, baseURL: string): string => baseURL.concat(name);
65+
66+
export const definePageKeywords = (keywords: Array<string>, others: string): string => {
67+
let result = '';
68+
if (keywords && keywords.length != 0) {
69+
result = keywords.join(', ');
70+
} else if (isNotEmpty(others)) {
71+
result = others;
72+
}
73+
74+
return result;
75+
};

src/routes/+layout.ts

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export const prerender = true;
2+
export const trailingSlash = 'always';

src/routes/cli/+page.server.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import type { Sveltin } from 'src/sveltin';
1+
import type { Sveltin } from '../../sveltin';
22
import { list } from '$lib/cli/loadCli';
33

44
export async function load() {
55
const resourceName = 'cli';
66
const data = await list();
77

8-
const items: Array<Sveltin.ContentEntry> = [];
8+
const items: Array<Sveltin.ResourceContent> = [];
99
data.forEach((elem) => {
10-
const item: Sveltin.ContentEntry = {
10+
const item: Sveltin.ResourceContent = {
1111
resource: resourceName,
1212
metadata: <Sveltin.YAMLFrontmatter>elem.meta,
1313
html: ''

src/sveltin.d.ts

+58-17
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,77 @@
1+
/**
2+
** Sveltin namespace reflects types exported by some of the @sveltinio/[packages].
3+
** This file exists to allow using sveltin's features with no lock-in to the sveltinio packages.
4+
*/
15
export namespace Sveltin {
2-
export interface ContentEntry {
6+
export type ResourceContent = {
37
resource: string;
48
metadata: YAMLFrontmatter;
59
html?: string;
6-
}
10+
};
711

8-
export interface ContentMetadata {
12+
export type ContentMetadata = {
913
name: string;
1014
items: Array<YAMLFrontmatter>;
11-
}
15+
};
1216

13-
export interface YAMLFrontmatter {
17+
export type TocEntry = {
18+
id: string;
19+
depth: number;
20+
value: string;
21+
children?: Array<TocEntry>;
22+
};
23+
24+
export type YAMLFrontmatter = {
1425
title: string;
1526
slug: string;
1627
draft: boolean;
17-
headline: string;
18-
headings: Array<TOCEntry>;
28+
headings?: Array<TocEntry>;
29+
keywords?: Array<string>;
1930
author?: string;
31+
headline?: string;
2032
created_at?: string;
2133
updated_at?: string;
2234
cover?: string;
23-
[key: string]: string | number | boolean | object | [];
24-
}
35+
[key: string]: string | undefined | Array<TocEntry> | boolean;
36+
};
2537

26-
export interface TOCEntry {
27-
id: string;
38+
export type DynamicObject = {
39+
[key: string]: string | number | object | [];
40+
};
41+
42+
export type MenuItem = {
43+
identifier: string;
44+
name: string;
45+
url: string;
46+
weight: number;
47+
external?: boolean;
48+
children?: Array<MenuItem>;
49+
};
50+
51+
export type WebSite = {
52+
name: string;
53+
baseURL: string;
54+
language: string;
2855
title: string;
29-
depth: number;
30-
children?: Array<TOCEntry>;
31-
}
56+
slogan?: string;
57+
description: string;
58+
seoDescription: string;
59+
favicon: string;
60+
logo: string;
61+
copyright: string;
62+
keywords: string;
63+
contactEmail: string;
64+
socials?: Socials;
65+
webmaster?: WebMaster;
66+
};
3267

33-
export interface DynamicObject {
34-
[key: string]: string | number | object | [];
35-
}
68+
export type Socials = {
69+
[key: string]: string;
70+
};
71+
72+
export type WebMaster = {
73+
name: string;
74+
address: string;
75+
contactEmail: string;
76+
};
3677
}

svelte.config.js

-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ const config = {
2323
fallback: '200.html',
2424
precompress: true
2525
}),
26-
trailingSlash: 'always',
2726
prerender: {
2827
crawl: true,
29-
enabled: true,
3028
entries: ['*']
3129
}
3230
}

sveltin.config.json

-10
This file was deleted.

sveltin.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "docs.sveltin.io",
3+
"baseurl": "https://docs.sveltin.io",
4+
"theme": {
5+
"style": "blank",
6+
"name": "dockerz",
7+
"cssLib": "tailwindcss"
8+
},
9+
"sitemap": {
10+
"changeFreq": "monthly",
11+
"priority": 0.5
12+
},
13+
"sveltekit": {
14+
"adapter": {
15+
"pages": "build",
16+
"assets": "build"
17+
}
18+
},
19+
"sveltin": {
20+
"version": "0.11.0"
21+
}
22+
}

0 commit comments

Comments
 (0)