{{$formatDate(post.post_date)}}
6 |Written {{$formatDate(post.post_date)}}
8 |
9 | by
65 |
66 |
67 | Result:
68 |
69 |
70 |
71 | ### PostList
72 |
73 | In the backend:
74 |
75 |
76 |
77 | Result:
78 |
79 |
80 |
81 | ## License
82 |
83 | [MIT](http://opensource.org/licenses/MIT)
84 |
--------------------------------------------------------------------------------
/src/themes/basic/components/post/PostContent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
40 |
41 |
141 |
--------------------------------------------------------------------------------
/src/themes/multi-user/components/post/PostContent.vue:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
40 |
41 |
141 |
--------------------------------------------------------------------------------
/src/core/vue-apollo.js:
--------------------------------------------------------------------------------
1 | import Vue from "vue";
2 | import VueApollo from "vue-apollo";
3 | import {
4 | createApolloClient,
5 | restartWebsockets
6 | } from "vue-cli-plugin-apollo/graphql-client";
7 | import config from "config";
8 |
9 | const { wordexpressServerHost } = config;
10 |
11 | // Install the vue plugin
12 | Vue.use(VueApollo);
13 |
14 | // Name of the localStorage item
15 | const AUTH_TOKEN = "apollo-token";
16 |
17 | // Http endpoint
18 | const httpEndpoint = wordexpressServerHost;
19 |
20 | // Files URL root
21 | export const filesRoot =
22 | process.env.VUE_APP_FILES_ROOT ||
23 | httpEndpoint.substr(0, httpEndpoint.indexOf("/graphql"));
24 |
25 | Object.defineProperty(Vue.prototype, "$filesRoot", {
26 | get: () => filesRoot
27 | });
28 |
29 | // Config
30 | const defaultOptions = {
31 | // You can use `https` for secure connection (recommended in production)
32 | httpEndpoint,
33 | // You can use `wss` for secure connection (recommended in production)
34 | // Use `null` to disable subscriptions
35 | wsEndpoint: null,
36 | // LocalStorage token
37 | tokenName: AUTH_TOKEN,
38 | // Enable Automatic Query persisting with Apollo Engine
39 | persisting: false,
40 | // Use websockets for everything (no HTTP)
41 | // You need to pass a `wsEndpoint` for this to work
42 | websocketsOnly: false,
43 | // Is being rendered on the server?
44 | ssr: true
45 |
46 | // Override default http link
47 | // link: myLink
48 |
49 | // Override default cache
50 | // cache: myCache
51 |
52 | // Override the way the Authorization header is set
53 | // getAuth: (tokenName) => ...
54 |
55 | // Additional ApolloClient options
56 | // apollo: { ... }
57 |
58 | // Client local data (see apollo-link-state)
59 | // clientState: { resolvers: { ... }, defaults: { ... } }
60 | };
61 |
62 | // Call this in the Vue app file
63 | export function createProvider(options = {}) {
64 | // Create apollo client
65 | const { apolloClient, wsClient } = createApolloClient({
66 | ...defaultOptions,
67 | ...options
68 | });
69 | apolloClient.wsClient = wsClient;
70 |
71 | // Create vue apollo provider
72 | const apolloProvider = new VueApollo({
73 | defaultClient: apolloClient,
74 | defaultOptions: {
75 | $query: {
76 | // fetchPolicy: 'cache-and-network',
77 | }
78 | },
79 | errorHandler(error) {
80 | // eslint-disable-next-line no-console
81 | console.log(
82 | "%cError",
83 | "background: red; color: white; padding: 2px 4px; border-radius: 3px; font-weight: bold;",
84 | error.message
85 | );
86 | }
87 | });
88 |
89 | return apolloProvider;
90 | }
91 |
92 | // Manually call this when user log in
93 | export async function onLogin(apolloClient, token) {
94 | localStorage.setItem(AUTH_TOKEN, token);
95 | if (apolloClient.wsClient) restartWebsockets(apolloClient.wsClient);
96 | try {
97 | await apolloClient.resetStore();
98 | } catch (e) {
99 | // eslint-disable-next-line no-console
100 | console.log("%cError on cache reset (login)", "color: orange;", e.message);
101 | }
102 | }
103 |
104 | // Manually call this when user log out
105 | export async function onLogout(apolloClient) {
106 | localStorage.removeItem(AUTH_TOKEN);
107 | if (apolloClient.wsClient) restartWebsockets(apolloClient.wsClient);
108 | try {
109 | await apolloClient.resetStore();
110 | } catch (e) {
111 | // eslint-disable-next-line no-console
112 | console.log("%cError on cache reset (logout)", "color: orange;", e.message);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/acf-export.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "key": "group_5a32cdd1b53f1",
4 | "title": "Page Fields",
5 | "fields": [
6 | {
7 | "key": "field_5699475fcd949",
8 | "label": "Layout Component",
9 | "name": "page_layout_component",
10 | "type": "select",
11 | "instructions": "",
12 | "required": 0,
13 | "conditional_logic": 0,
14 | "wrapper": {
15 | "width": "",
16 | "class": "",
17 | "id": ""
18 | },
19 | "choices": {
20 | "Default": "Default",
21 | "PageWithHeader": "PageWithHeader",
22 | "PostList": "PostList",
23 | "AboutPage": "AboutPage"
24 | },
25 | "default_value": [
26 | "Default"
27 | ],
28 | "allow_null": 0,
29 | "multiple": 0,
30 | "ui": 0,
31 | "ajax": 0,
32 | "return_format": "value",
33 | "placeholder": ""
34 | },
35 | {
36 | "key": "field_5a43baa53bf80",
37 | "label": "Post Type",
38 | "name": "post_type",
39 | "type": "select",
40 | "instructions": "",
41 | "required": 0,
42 | "conditional_logic": [
43 | [
44 | {
45 | "field": "field_5699475fcd949",
46 | "operator": "==",
47 | "value": "PostList"
48 | }
49 | ]
50 | ],
51 | "wrapper": {
52 | "width": "",
53 | "class": "",
54 | "id": ""
55 | },
56 | "choices": {
57 | "post": "Post",
58 | "tutorial": "Tutorial"
59 | },
60 | "default_value": [
61 | "post"
62 | ],
63 | "allow_null": 0,
64 | "multiple": 0,
65 | "ui": 0,
66 | "ajax": 0,
67 | "return_format": "value",
68 | "placeholder": ""
69 | },
70 | {
71 | "key": "field_5a43c2c5ab175",
72 | "label": "Post Item Component",
73 | "name": "post_item_component",
74 | "type": "select",
75 | "instructions": "",
76 | "required": 0,
77 | "conditional_logic": [
78 | [
79 | {
80 | "field": "field_5699475fcd949",
81 | "operator": "==",
82 | "value": "PostList"
83 | }
84 | ]
85 | ],
86 | "wrapper": {
87 | "width": "",
88 | "class": "",
89 | "id": ""
90 | },
91 | "choices": {
92 | "PostListItem": "PostListItem",
93 | "TutorialListItem": "TutorialListItem"
94 | },
95 | "default_value": [],
96 | "allow_null": 0,
97 | "multiple": 0,
98 | "ui": 0,
99 | "ajax": 0,
100 | "return_format": "value",
101 | "placeholder": ""
102 | },
103 | {
104 | "key": "field_5a4423fc9061e",
105 | "label": "About Image",
106 | "name": "about_image",
107 | "type": "image",
108 | "instructions": "",
109 | "required": 0,
110 | "conditional_logic": [
111 | [
112 | {
113 | "field": "field_5699475fcd949",
114 | "operator": "==",
115 | "value": "AboutPage"
116 | }
117 | ]
118 | ],
119 | "wrapper": {
120 | "width": "",
121 | "class": "",
122 | "id": ""
123 | },
124 | "return_format": "url",
125 | "preview_size": "thumbnail",
126 | "library": "all",
127 | "min_width": "",
128 | "min_height": "",
129 | "min_size": "",
130 | "max_width": "",
131 | "max_height": "",
132 | "max_size": "",
133 | "mime_types": ""
134 | }
135 | ],
136 | "location": [
137 | [
138 | {
139 | "param": "post_type",
140 | "operator": "==",
141 | "value": "page"
142 | }
143 | ]
144 | ],
145 | "menu_order": 0,
146 | "position": "acf_after_title",
147 | "style": "seamless",
148 | "label_placement": "top",
149 | "instruction_placement": "label",
150 | "hide_on_screen": "",
151 | "active": 1,
152 | "description": ""
153 | }
154 | ]
--------------------------------------------------------------------------------